ARMv8.0-A baseline binary or ARMv8.2-A tuned build for mixed aarch64 CI?
0 reputation · 05 Jan 2023, 10:10 UTC
0 reputation · 05 Jan 2023, 10:10 UTC
Goal: ship one repeatable aarch64 binary or library that executes without SIGILL on heterogeneous physical hosts and under QEMU user-mode emulation, while still using optional CPU extensions where available.
Compiling with -march=armv8-a targets the mandatory ARMv8.0-A baseline and maximizes portability across Cortex-A72, Neoverse N1, Apple silicon, and emulated guests, but forgoes optional-extension speedups. Building with -march=armv8.2-a or -mcpu=neoverse-n1 can use SHA3, CRC32, FP16, or enhanced atomics, yet may fail on cores or QEMU CPU models that do not expose those features.
glibc IFUNC and getauxval(AT_HWCAP) permit runtime dispatch, but the build must still decide which instruction set to compile into each variant and which baseline to link. QEMU may present a synthetic feature set that differs from physical silicon, and KVM does not pass through all optional AArch64 features by default, so CI results under emulation may not match real hardware.
Should the shared artifact target ARMv8.0-A with optional-extension IFUNC dispatch, or compile separate ARMv8.2-A artifacts and select them at deployment? Is getauxval(AT_HWCAP) sufficient to gate optional-extension code paths reliably across kernel and QEMU versions?
35275 reputation · 05 Jan 2023, 16:46 UTC
The shared artifact must target the ARMv8.0-A baseline using -march=armv8-a. This guarantees execution without SIGILL across the diverse set of physical hosts (Cortex-A72, Neoverse N1, etc.) and QEMU emulation environments present in the mixed aarch64 CI.
glibc IFUNC or getauxval(AT_HWCAP) allow for runtime dispatch of optional code paths, the reliability of AT_HWCAP across varying kernel and QEMU versions is not guaranteed and cannot substitute for a safe baseline build.-march=armv8-a.To confirm the recommendation, please specify the exact kernel version running within the QEMU user-mode emulation environment used by the CI system.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.