From 6e892aaf8d6350a62a66325c5732b7c81a15d472 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 5 May 2025 03:16:49 +0000 Subject: [PATCH] Disable aarch64 assembly if `target_abi = "softfloat"` The target `aarch64-unknown-none-softfloat` still sets the `neon` target feature, so the assembly implementations are incorrectly being enabled. Update gates to differentiate the `softfloat` ABI. --- libm/src/math/arch/mod.rs | 3 ++- libm/src/math/fma.rs | 4 ++-- libm/src/math/rint.rs | 4 ++-- libm/src/math/sqrt.rs | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libm/src/math/arch/mod.rs b/libm/src/math/arch/mod.rs index 984ae7f31..c6881b8e8 100644 --- a/libm/src/math/arch/mod.rs +++ b/libm/src/math/arch/mod.rs @@ -19,7 +19,8 @@ cfg_if! { pub use x86::{sqrt, sqrtf, fma, fmaf}; } else if #[cfg(all( any(target_arch = "aarch64", target_arch = "arm64ec"), - target_feature = "neon" + target_feature = "neon", + not(target_abi = "softfloat"), ))] { mod aarch64; diff --git a/libm/src/math/fma.rs b/libm/src/math/fma.rs index 5bf473cfe..9714e1cf1 100644 --- a/libm/src/math/fma.rs +++ b/libm/src/math/fma.rs @@ -20,7 +20,7 @@ pub fn fmaf(x: f32, y: f32, z: f32) -> f32 { select_implementation! { name: fmaf, use_arch: any( - all(target_arch = "aarch64", target_feature = "neon"), + all(target_arch = "aarch64", target_feature = "neon", not(target_abi = "softfloat")), target_feature = "sse2", ), args: x, y, z, @@ -37,7 +37,7 @@ pub fn fma(x: f64, y: f64, z: f64) -> f64 { select_implementation! { name: fma, use_arch: any( - all(target_arch = "aarch64", target_feature = "neon"), + all(target_arch = "aarch64", target_feature = "neon", not(target_abi = "softfloat")), target_feature = "sse2", ), args: x, y, z, diff --git a/libm/src/math/rint.rs b/libm/src/math/rint.rs index e1c32c943..aa2dc546b 100644 --- a/libm/src/math/rint.rs +++ b/libm/src/math/rint.rs @@ -19,7 +19,7 @@ pub fn rintf(x: f32) -> f32 { select_implementation! { name: rintf, use_arch: any( - all(target_arch = "aarch64", target_feature = "neon"), + all(target_arch = "aarch64", target_feature = "neon", not(target_abi = "softfloat")), all(target_arch = "wasm32", intrinsics_enabled), ), args: x, @@ -34,7 +34,7 @@ pub fn rint(x: f64) -> f64 { select_implementation! { name: rint, use_arch: any( - all(target_arch = "aarch64", target_feature = "neon"), + all(target_arch = "aarch64", target_feature = "neon", not(target_abi = "softfloat")), all(target_arch = "wasm32", intrinsics_enabled), ), args: x, diff --git a/libm/src/math/sqrt.rs b/libm/src/math/sqrt.rs index 76bc240cf..843157d7c 100644 --- a/libm/src/math/sqrt.rs +++ b/libm/src/math/sqrt.rs @@ -17,7 +17,7 @@ pub fn sqrtf(x: f32) -> f32 { select_implementation! { name: sqrtf, use_arch: any( - all(target_arch = "aarch64", target_feature = "neon"), + all(target_arch = "aarch64", target_feature = "neon", not(target_abi = "softfloat")), all(target_arch = "wasm32", intrinsics_enabled), target_feature = "sse2" ), @@ -33,7 +33,7 @@ pub fn sqrt(x: f64) -> f64 { select_implementation! { name: sqrt, use_arch: any( - all(target_arch = "aarch64", target_feature = "neon"), + all(target_arch = "aarch64", target_feature = "neon", not(target_abi = "softfloat")), all(target_arch = "wasm32", intrinsics_enabled), target_feature = "sse2" ),