Skip to content

Commit 0fab77e

Browse files
committed
Don't include math for unix and wasi targets
This fixes such as (rust-lang/rust#128386) where, our implementation is being used on systems where there is already `math` library and its more performant and accurate. So with this change, linux will go back to the previous behavior and not include these functions, windows and apple were generally not affected. Looking at the targets we have builtin now in rust, everything else is probably good to have the math symbols. > A note on the above, the `hermit` os uses `libm` directly for itself, > but I think its Ok to keep providing math in `compiler_builtin` for it, > its technically the same implementation either from `compiler_builtin` > or `hermit-builtins`. Signed-off-by: Amjad Alsharafi <[email protected]>
1 parent 081192c commit 0fab77e

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/lib.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,16 @@ mod macros;
4747
pub mod float;
4848
pub mod int;
4949

50-
// Disabled on x86 without sse2 due to ABI issues
51-
// <https://github.com/rust-lang/rust/issues/114479>
52-
#[cfg(not(all(target_arch = "x86", not(target_feature = "sse2"))))]
50+
// Disable for any of the following:
51+
// - x86 without sse2 due to ABI issues
52+
// - <https://github.com/rust-lang/rust/issues/114479>
53+
// - All unix targets (linux, macos, freebsd, android, etc)
54+
// - wasm with known target_os
55+
#[cfg(not(any(
56+
all(target_arch = "x86", not(target_feature = "sse2")),
57+
unix,
58+
all(target_family = "wasm", not(target_os = "unknown"))
59+
)))]
5360
pub mod math;
5461
pub mod mem;
5562

src/math.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ macro_rules! no_mangle {
1717
}
1818
}
1919

20-
#[cfg(all(not(windows), not(target_vendor = "apple")))]
20+
#[cfg(not(windows))]
2121
no_mangle! {
2222
fn acos(x: f64) -> f64;
2323
fn asin(x: f64) -> f64;
@@ -92,6 +92,7 @@ no_mangle! {
9292
fn fmodf(x: f32, y: f32) -> f32;
9393
}
9494

95+
// allow for windows (and other targets)
9596
intrinsics! {
9697
pub extern "C" fn lgamma_r(x: f64, s: &mut i32) -> f64 {
9798
let r = self::libm::lgamma_r(x);

0 commit comments

Comments
 (0)