From 445de2fb9c611d0307e57791bad8205290e3919c Mon Sep 17 00:00:00 2001 From: Jonah Petri Date: Mon, 13 Nov 2023 09:29:17 -0500 Subject: [PATCH] getauxval isn't defined on uclibc, so disable dynamic feature detection --- src/cpu.rs | 2 +- src/cpu/arm.rs | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/cpu.rs b/src/cpu.rs index e7530baf0d..d2f85ebe36 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -57,7 +57,7 @@ pub(crate) fn features() -> Features { any( target_os = "android", target_os = "fuchsia", - target_os = "linux", + all(target_os = "linux", not(target_env = "uclibc")), target_os = "windows" ) ))] diff --git a/src/cpu/arm.rs b/src/cpu/arm.rs index 9a568475a4..887a18768d 100644 --- a/src/cpu/arm.rs +++ b/src/cpu/arm.rs @@ -17,9 +17,18 @@ allow(dead_code) )] +// uclibc: When linked statically, uclibc doesn't provide getauxval. +// When linked dynamically, recent versions do provide it, but we +// want to support older versions too. Assume that if uclibc is being +// used, this is an embedded target where the user cares a lot about +// minimizing code size and also that they know in advance exactly +// what target features are supported, so rely only on static feature +// detection. + #[cfg(all( any(target_os = "android", target_os = "linux"), - any(target_arch = "aarch64", target_arch = "arm") + any(target_arch = "aarch64", target_arch = "arm"), + not(target_env = "uclibc") ))] fn detect_features() -> u32 { use libc::c_ulong; @@ -196,7 +205,7 @@ impl Feature { any( target_os = "android", target_os = "fuchsia", - target_os = "linux", + all(target_os = "linux", not(target_env = "uclibc")), target_os = "windows" ), any(target_arch = "arm", target_arch = "aarch64") @@ -251,7 +260,7 @@ features! { any( target_os = "android", target_os = "fuchsia", - target_os = "linux", + all(target_os = "linux", not(target_env = "uclibc")), target_os = "windows" ) ))]