diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c index c5913f763dd244..7651e84f876c08 100644 --- a/compiler-rt/lib/builtins/cpu_model.c +++ b/compiler-rt/lib/builtins/cpu_model.c @@ -801,12 +801,23 @@ _Bool __aarch64_have_lse_atomics #if defined(__ANDROID__) #include #include +#elif defined(__Fuchsia__) +#include +#include #endif static void CONSTRUCTOR_ATTRIBUTE init_have_lse_atomics(void) { #if defined(__FreeBSD__) unsigned long hwcap; int result = elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap); __aarch64_have_lse_atomics = result == 0 && (hwcap & HWCAP_ATOMICS) != 0; +#elif defined(__Fuchsia__) + // This ensures the vDSO is a direct link-time dependency of anything that + // needs this initializer code. +#pragma comment(lib, "zircon") + uint32_t features; + zx_status_t status = _zx_system_get_features(ZX_FEATURE_KIND_CPU, &features); + __aarch64_have_lse_atomics = + status == ZX_OK && (features & ZX_ARM64_FEATURE_ISA_ATOMICS) != 0; #else unsigned long hwcap = getauxval(AT_HWCAP); _Bool result = (hwcap & HWCAP_ATOMICS) != 0;