1 Answer
- Newest
- Most votes
- Most comments
0
For ARM64 workloads in Nitro Enclaves, here are recommendations regarding compiler flags:
- Regarding CPU target selection:
- For Graviton2-based instances,
-mcpu=neoverse-n1is the most appropriate choice - For Graviton3-based instances,
-mcpu=neoverse-v1would be appropriate - For Graviton4-based instances,
-mcpu=neoverse-v2would be appropriate - Using
-mcpu=nativeis not recommended for enclave builds as it detects features from the host environment which may not match the enclave environment
- Regarding specific optimizations:
- Amazon Linux 2023 packages are built with
-march=armv8.2-a+crypto -mtune=neoverse-n1for aarch64, suggesting these are safe baseline options - Auto-vectorization (like
-ftree-vectorize) is used in AL2023 packages - Link Time Optimization (LTO) is also enabled in AL2023 packages
- Standard optimization flags like
-O2or-O3are generally safe
- Regarding unsafe flags:
- There's no explicit information about flags that are unsafe specifically in enclaves but safe on the host
- However, the issue you're experiencing suggests that assuming identical CPU feature sets between host and enclave may be problematic
- Regarding differences between host and enclave:
- Your observation about binaries working on the host but crashing in the enclave suggests there may indeed be differences in the CPU feature sets exposed
- This could be due to how the Nitro Enclave virtualizes or exposes CPU features differently than the host environment
- To address this, using more conservative compiler flags that target a baseline feature set (like those used in AL2023) would be safer than assuming full feature parity
To resolve your crashing issues, I would recommend:
- Start with conservative flags like
-march=armv8.2-a+crypto -mtune=neoverse-n1 - Avoid
-mcpu=nativesince it detects features from the build environment - Incrementally test additional optimizations to find what works reliably in your enclave environment
- Consider using the same compiler flags that Amazon Linux 2023 uses for its packages as a safe baseline
Sources
Performance gains with AWS Graviton4 – a DevitoPRO case study | AWS HPC Blog
Performance and operational optimizations - Amazon Linux 2023
AWS Nitro Enclaves
answered a year ago
