about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTrevor Gross <tmgross@umich.edu>2025-02-24 00:01:04 +0000
committerTrevor Gross <t.gross35@gmail.com>2025-02-23 21:10:11 -0500
commitba8f07282e233413ed34aaf7576690265aeed25f (patch)
tree6aa049c9d0ee4369b5dd0de8764d45a16624b2c1
parentc32bc8398a546c0346dbb3e563c8658d1d772349 (diff)
downloadrust-ba8f07282e233413ed34aaf7576690265aeed25f.tar.gz
rust-ba8f07282e233413ed34aaf7576690265aeed25f.zip
Make the compiler-builtins test more accurately mirror compiler-builtins
In `compiler-builtins`, `libm` is contained within a `math` module. The
smoke test in this repo has a slightly different layout so some things
were passing that shouldn't be.

Change module layouts in `compiler-builtins-smoke-test` to match
`compiler-builtins` and update a few instances of broken paths.
-rw-r--r--library/compiler-builtins/libm/crates/compiler-builtins-smoke-test/src/lib.rs185
-rw-r--r--library/compiler-builtins/libm/crates/compiler-builtins-smoke-test/src/math.rs182
-rw-r--r--library/compiler-builtins/libm/src/math/fma.rs2
-rw-r--r--library/compiler-builtins/libm/src/math/fma_wide.rs2
4 files changed, 186 insertions, 185 deletions
diff --git a/library/compiler-builtins/libm/crates/compiler-builtins-smoke-test/src/lib.rs b/library/compiler-builtins/libm/crates/compiler-builtins-smoke-test/src/lib.rs
index 77a4666a102..f9e6e75a870 100644
--- a/library/compiler-builtins/libm/crates/compiler-builtins-smoke-test/src/lib.rs
+++ b/library/compiler-builtins/libm/crates/compiler-builtins-smoke-test/src/lib.rs
@@ -10,187 +10,6 @@
 #![allow(internal_features)]
 #![no_std]
 
-#[allow(dead_code)]
-#[allow(clippy::all)] // We don't get `libm`'s list of `allow`s, so just ignore Clippy.
-#[path = "../../../src/math/mod.rs"]
-pub mod libm;
-
-use core::ffi::c_int;
-
+mod math;
 // Required for macro paths.
-use libm::support;
-
-/// Mark functions `#[no_mangle]` and with the C ABI.
-macro_rules! no_mangle {
-    ($( $name:ident( $($tt:tt)+ ) -> $ret:ty; )+) => {
-        $( no_mangle!(@inner $name( $($tt)+ ) -> $ret); )+
-    };
-
-    // Handle simple functions with single return types
-    (@inner $name:ident( $($arg:ident: $aty:ty),+ ) -> $ret:ty) => {
-        #[no_mangle]
-        extern "C" fn $name($($arg: $aty),+) -> $ret {
-            libm::$name($($arg),+)
-        }
-    };
-
-
-    // Functions with `&mut` return values need to be handled differently, use `|` to
-    // separate inputs vs. outputs.
-    (
-        @inner $name:ident( $($arg:ident: $aty:ty),+ | $($rarg:ident: $rty:ty),+) -> $ret:ty
-    ) => {
-        #[no_mangle]
-        extern "C" fn $name($($arg: $aty,)+ $($rarg: $rty),+) -> $ret {
-            let ret;
-            (ret, $(*$rarg),+) = libm::$name($($arg),+);
-            ret
-        }
-    };
-}
-
-no_mangle! {
-    frexp(x: f64 | y: &mut c_int) -> f64;
-    frexpf(x: f32 | y: &mut c_int) -> f32;
-    acos(x: f64) -> f64;
-    acosf(x: f32) -> f32;
-    acosh(x: f64) -> f64;
-    acoshf(x: f32) -> f32;
-    asin(x: f64) -> f64;
-    asinf(x: f32) -> f32;
-    asinh(x: f64) -> f64;
-    asinhf(x: f32) -> f32;
-    atan(x: f64) -> f64;
-    atan2(x: f64, y: f64) -> f64;
-    atan2f(x: f32, y: f32) -> f32;
-    atanf(x: f32) -> f32;
-    atanh(x: f64) -> f64;
-    atanhf(x: f32) -> f32;
-    cbrt(x: f64) -> f64;
-    cbrtf(x: f32) -> f32;
-    ceil(x: f64) -> f64;
-    ceilf(x: f32) -> f32;
-    ceilf128(x: f128) -> f128;
-    ceilf16(x: f16) -> f16;
-    copysign(x: f64, y: f64) -> f64;
-    copysignf(x: f32, y: f32) -> f32;
-    copysignf128(x: f128, y: f128) -> f128;
-    copysignf16(x: f16, y: f16) -> f16;
-    cos(x: f64) -> f64;
-    cosf(x: f32) -> f32;
-    cosh(x: f64) -> f64;
-    coshf(x: f32) -> f32;
-    erf(x: f64) -> f64;
-    erfc(x: f64) -> f64;
-    erfcf(x: f32) -> f32;
-    erff(x: f32) -> f32;
-    exp(x: f64) -> f64;
-    exp10(x: f64) -> f64;
-    exp10f(x: f32) -> f32;
-    exp2(x: f64) -> f64;
-    exp2f(x: f32) -> f32;
-    expf(x: f32) -> f32;
-    expm1(x: f64) -> f64;
-    expm1f(x: f32) -> f32;
-    fabs(x: f64) -> f64;
-    fabsf(x: f32) -> f32;
-    fabsf128(x: f128) -> f128;
-    fabsf16(x: f16) -> f16;
-    fdim(x: f64, y: f64) -> f64;
-    fdimf(x: f32, y: f32) -> f32;
-    fdimf128(x: f128, y: f128) -> f128;
-    fdimf16(x: f16, y: f16) -> f16;
-    floor(x: f64) -> f64;
-    floorf(x: f32) -> f32;
-    floorf128(x: f128) -> f128;
-    floorf16(x: f16) -> f16;
-    fma(x: f64, y: f64, z: f64) -> f64;
-    fmaf(x: f32, y: f32, z: f32) -> f32;
-    fmax(x: f64, y: f64) -> f64;
-    fmaxf(x: f32, y: f32) -> f32;
-    fmin(x: f64, y: f64) -> f64;
-    fminf(x: f32, y: f32) -> f32;
-    fmod(x: f64, y: f64) -> f64;
-    fmodf(x: f32, y: f32) -> f32;
-    hypot(x: f64, y: f64) -> f64;
-    hypotf(x: f32, y: f32) -> f32;
-    ilogb(x: f64) -> c_int;
-    ilogbf(x: f32) -> c_int;
-    j0(x: f64) -> f64;
-    j0f(x: f32) -> f32;
-    j1(x: f64) -> f64;
-    j1f(x: f32) -> f32;
-    jn(x: c_int, y: f64) -> f64;
-    jnf(x: c_int, y: f32) -> f32;
-    ldexp(x: f64, y: c_int) -> f64;
-    ldexpf(x: f32, y: c_int) -> f32;
-    lgamma(x: f64) -> f64;
-    lgamma_r(x: f64 | r: &mut c_int) -> f64;
-    lgammaf(x: f32) -> f32;
-    lgammaf_r(x: f32 | r: &mut c_int) -> f32;
-    log(x: f64) -> f64;
-    log10(x: f64) -> f64;
-    log10f(x: f32) -> f32;
-    log1p(x: f64) -> f64;
-    log1pf(x: f32) -> f32;
-    log2(x: f64) -> f64;
-    log2f(x: f32) -> f32;
-    logf(x: f32) -> f32;
-    modf(x: f64 | r: &mut f64) -> f64;
-    modff(x: f32 | r: &mut f32) -> f32;
-    nextafter(x: f64, y: f64) -> f64;
-    nextafterf(x: f32, y: f32) -> f32;
-    pow(x: f64, y: f64) -> f64;
-    powf(x: f32, y: f32) -> f32;
-    remainder(x: f64, y: f64) -> f64;
-    remainderf(x: f32, y: f32) -> f32;
-    remquo(x: f64, y: f64 | q: &mut c_int) -> f64;
-    remquof(x: f32, y: f32 | q: &mut c_int) -> f32;
-    rint(x: f64) -> f64;
-    rintf(x: f32) -> f32;
-    rintf128(x: f128) -> f128;
-    rintf16(x: f16) -> f16;
-    round(x: f64) -> f64;
-    roundf(x: f32) -> f32;
-    scalbn(x: f64, y: c_int) -> f64;
-    scalbnf(x: f32, y: c_int) -> f32;
-    sin(x: f64) -> f64;
-    sinf(x: f32) -> f32;
-    sinh(x: f64) -> f64;
-    sinhf(x: f32) -> f32;
-    sqrt(x: f64) -> f64;
-    sqrtf(x: f32) -> f32;
-    tan(x: f64) -> f64;
-    tanf(x: f32) -> f32;
-    tanh(x: f64) -> f64;
-    tanhf(x: f32) -> f32;
-    tgamma(x: f64) -> f64;
-    tgammaf(x: f32) -> f32;
-    trunc(x: f64) -> f64;
-    truncf(x: f32) -> f32;
-    truncf128(x: f128) -> f128;
-    truncf16(x: f16) -> f16;
-    y0(x: f64) -> f64;
-    y0f(x: f32) -> f32;
-    y1(x: f64) -> f64;
-    y1f(x: f32) -> f32;
-    yn(x: c_int, y: f64) -> f64;
-    ynf(x: c_int, y: f32) -> f32;
-}
-
-/* sincos has no direct return type, not worth handling in the macro */
-
-#[no_mangle]
-extern "C" fn sincos(x: f64, s: &mut f64, c: &mut f64) {
-    (*s, *c) = libm::sincos(x);
-}
-
-#[no_mangle]
-extern "C" fn sincosf(x: f32, s: &mut f32, c: &mut f32) {
-    (*s, *c) = libm::sincosf(x);
-}
-
-#[panic_handler]
-fn panic(_info: &core::panic::PanicInfo) -> ! {
-    loop {}
-}
+use math::libm::support;
diff --git a/library/compiler-builtins/libm/crates/compiler-builtins-smoke-test/src/math.rs b/library/compiler-builtins/libm/crates/compiler-builtins-smoke-test/src/math.rs
new file mode 100644
index 00000000000..7e0146998aa
--- /dev/null
+++ b/library/compiler-builtins/libm/crates/compiler-builtins-smoke-test/src/math.rs
@@ -0,0 +1,182 @@
+use core::ffi::c_int;
+
+#[allow(dead_code)]
+#[allow(clippy::all)] // We don't get `libm`'s list of `allow`s, so just ignore Clippy.
+#[allow(unused_imports)]
+#[path = "../../../src/math/mod.rs"]
+pub mod libm;
+
+/// Mark functions `#[no_mangle]` and with the C ABI.
+macro_rules! no_mangle {
+    ($( $name:ident( $($tt:tt)+ ) -> $ret:ty; )+) => {
+        $( no_mangle!(@inner $name( $($tt)+ ) -> $ret); )+
+    };
+
+    // Handle simple functions with single return types
+    (@inner $name:ident( $($arg:ident: $aty:ty),+ ) -> $ret:ty) => {
+        #[no_mangle]
+        extern "C" fn $name($($arg: $aty),+) -> $ret {
+            libm::$name($($arg),+)
+        }
+    };
+
+
+    // Functions with `&mut` return values need to be handled differently, use `|` to
+    // separate inputs vs. outputs.
+    (
+        @inner $name:ident( $($arg:ident: $aty:ty),+ | $($rarg:ident: $rty:ty),+) -> $ret:ty
+    ) => {
+        #[no_mangle]
+        extern "C" fn $name($($arg: $aty,)+ $($rarg: $rty),+) -> $ret {
+            let ret;
+            (ret, $(*$rarg),+) = libm::$name($($arg),+);
+            ret
+        }
+    };
+}
+
+no_mangle! {
+    frexp(x: f64 | y: &mut c_int) -> f64;
+    frexpf(x: f32 | y: &mut c_int) -> f32;
+    acos(x: f64) -> f64;
+    acosf(x: f32) -> f32;
+    acosh(x: f64) -> f64;
+    acoshf(x: f32) -> f32;
+    asin(x: f64) -> f64;
+    asinf(x: f32) -> f32;
+    asinh(x: f64) -> f64;
+    asinhf(x: f32) -> f32;
+    atan(x: f64) -> f64;
+    atan2(x: f64, y: f64) -> f64;
+    atan2f(x: f32, y: f32) -> f32;
+    atanf(x: f32) -> f32;
+    atanh(x: f64) -> f64;
+    atanhf(x: f32) -> f32;
+    cbrt(x: f64) -> f64;
+    cbrtf(x: f32) -> f32;
+    ceil(x: f64) -> f64;
+    ceilf(x: f32) -> f32;
+    ceilf128(x: f128) -> f128;
+    ceilf16(x: f16) -> f16;
+    copysign(x: f64, y: f64) -> f64;
+    copysignf(x: f32, y: f32) -> f32;
+    copysignf128(x: f128, y: f128) -> f128;
+    copysignf16(x: f16, y: f16) -> f16;
+    cos(x: f64) -> f64;
+    cosf(x: f32) -> f32;
+    cosh(x: f64) -> f64;
+    coshf(x: f32) -> f32;
+    erf(x: f64) -> f64;
+    erfc(x: f64) -> f64;
+    erfcf(x: f32) -> f32;
+    erff(x: f32) -> f32;
+    exp(x: f64) -> f64;
+    exp10(x: f64) -> f64;
+    exp10f(x: f32) -> f32;
+    exp2(x: f64) -> f64;
+    exp2f(x: f32) -> f32;
+    expf(x: f32) -> f32;
+    expm1(x: f64) -> f64;
+    expm1f(x: f32) -> f32;
+    fabs(x: f64) -> f64;
+    fabsf(x: f32) -> f32;
+    fabsf128(x: f128) -> f128;
+    fabsf16(x: f16) -> f16;
+    fdim(x: f64, y: f64) -> f64;
+    fdimf(x: f32, y: f32) -> f32;
+    fdimf128(x: f128, y: f128) -> f128;
+    fdimf16(x: f16, y: f16) -> f16;
+    floor(x: f64) -> f64;
+    floorf(x: f32) -> f32;
+    floorf128(x: f128) -> f128;
+    floorf16(x: f16) -> f16;
+    fma(x: f64, y: f64, z: f64) -> f64;
+    fmaf(x: f32, y: f32, z: f32) -> f32;
+    fmax(x: f64, y: f64) -> f64;
+    fmaxf(x: f32, y: f32) -> f32;
+    fmin(x: f64, y: f64) -> f64;
+    fminf(x: f32, y: f32) -> f32;
+    fmod(x: f64, y: f64) -> f64;
+    fmodf(x: f32, y: f32) -> f32;
+    hypot(x: f64, y: f64) -> f64;
+    hypotf(x: f32, y: f32) -> f32;
+    ilogb(x: f64) -> c_int;
+    ilogbf(x: f32) -> c_int;
+    j0(x: f64) -> f64;
+    j0f(x: f32) -> f32;
+    j1(x: f64) -> f64;
+    j1f(x: f32) -> f32;
+    jn(x: c_int, y: f64) -> f64;
+    jnf(x: c_int, y: f32) -> f32;
+    ldexp(x: f64, y: c_int) -> f64;
+    ldexpf(x: f32, y: c_int) -> f32;
+    lgamma(x: f64) -> f64;
+    lgamma_r(x: f64 | r: &mut c_int) -> f64;
+    lgammaf(x: f32) -> f32;
+    lgammaf_r(x: f32 | r: &mut c_int) -> f32;
+    log(x: f64) -> f64;
+    log10(x: f64) -> f64;
+    log10f(x: f32) -> f32;
+    log1p(x: f64) -> f64;
+    log1pf(x: f32) -> f32;
+    log2(x: f64) -> f64;
+    log2f(x: f32) -> f32;
+    logf(x: f32) -> f32;
+    modf(x: f64 | r: &mut f64) -> f64;
+    modff(x: f32 | r: &mut f32) -> f32;
+    nextafter(x: f64, y: f64) -> f64;
+    nextafterf(x: f32, y: f32) -> f32;
+    pow(x: f64, y: f64) -> f64;
+    powf(x: f32, y: f32) -> f32;
+    remainder(x: f64, y: f64) -> f64;
+    remainderf(x: f32, y: f32) -> f32;
+    remquo(x: f64, y: f64 | q: &mut c_int) -> f64;
+    remquof(x: f32, y: f32 | q: &mut c_int) -> f32;
+    rint(x: f64) -> f64;
+    rintf(x: f32) -> f32;
+    rintf128(x: f128) -> f128;
+    rintf16(x: f16) -> f16;
+    round(x: f64) -> f64;
+    roundf(x: f32) -> f32;
+    scalbn(x: f64, y: c_int) -> f64;
+    scalbnf(x: f32, y: c_int) -> f32;
+    sin(x: f64) -> f64;
+    sinf(x: f32) -> f32;
+    sinh(x: f64) -> f64;
+    sinhf(x: f32) -> f32;
+    sqrt(x: f64) -> f64;
+    sqrtf(x: f32) -> f32;
+    tan(x: f64) -> f64;
+    tanf(x: f32) -> f32;
+    tanh(x: f64) -> f64;
+    tanhf(x: f32) -> f32;
+    tgamma(x: f64) -> f64;
+    tgammaf(x: f32) -> f32;
+    trunc(x: f64) -> f64;
+    truncf(x: f32) -> f32;
+    truncf128(x: f128) -> f128;
+    truncf16(x: f16) -> f16;
+    y0(x: f64) -> f64;
+    y0f(x: f32) -> f32;
+    y1(x: f64) -> f64;
+    y1f(x: f32) -> f32;
+    yn(x: c_int, y: f64) -> f64;
+    ynf(x: c_int, y: f32) -> f32;
+}
+
+/* sincos has no direct return type, not worth handling in the macro */
+
+#[no_mangle]
+extern "C" fn sincos(x: f64, s: &mut f64, c: &mut f64) {
+    (*s, *c) = libm::sincos(x);
+}
+
+#[no_mangle]
+extern "C" fn sincosf(x: f32, s: &mut f32, c: &mut f32) {
+    (*s, *c) = libm::sincosf(x);
+}
+
+#[panic_handler]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+    loop {}
+}
diff --git a/library/compiler-builtins/libm/src/math/fma.rs b/library/compiler-builtins/libm/src/math/fma.rs
index a54984c936b..049f573cc92 100644
--- a/library/compiler-builtins/libm/src/math/fma.rs
+++ b/library/compiler-builtins/libm/src/math/fma.rs
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: MIT */
 /* origin: musl src/math/fma.c. Ported to generic Rust algorithm in 2025, TG. */
 
-use super::super::support::{DInt, FpResult, HInt, IntTy, Round, Status};
+use super::support::{DInt, FpResult, HInt, IntTy, Round, Status};
 use super::{CastFrom, CastInto, Float, Int, MinInt};
 
 /// Fused multiply add (f64)
diff --git a/library/compiler-builtins/libm/src/math/fma_wide.rs b/library/compiler-builtins/libm/src/math/fma_wide.rs
index a8c1a548879..d0cf33baf7a 100644
--- a/library/compiler-builtins/libm/src/math/fma_wide.rs
+++ b/library/compiler-builtins/libm/src/math/fma_wide.rs
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: MIT */
 /* origin: musl src/math/fmaf.c. Ported to generic Rust algorithm in 2025, TG. */
 
-use super::super::support::{FpResult, IntTy, Round, Status};
+use super::support::{FpResult, IntTy, Round, Status};
 use super::{CastFrom, CastInto, DFloat, Float, HFloat, MinInt};
 
 // Placeholder so we can have `fmaf16` in the `Float` trait.