From d43b1d08969e33e41d4a5e4438a9f4fe840e83ff Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 7 Aug 2025 00:49:27 -0500 Subject: [PATCH 1/9] Unconditionally enable f16 & f128 to see what passes with llvm21 --- compiler-builtins/configure.rs | 6 ++++-- libm/configure.rs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler-builtins/configure.rs b/compiler-builtins/configure.rs index 79e238ab..5d8744fc 100644 --- a/compiler-builtins/configure.rs +++ b/compiler-builtins/configure.rs @@ -55,8 +55,10 @@ impl Target { .collect(), // Note that these are unstable options, so only show up with the nightly compiler or // with `RUSTC_BOOTSTRAP=1` (which is required to use the types anyway). - reliable_f128: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F128").is_some(), - reliable_f16: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F16").is_some(), + // reliable_f128: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F128").is_some(), + // reliable_f16: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F16").is_some(), + reliable_f16: true, + reliable_f128: true, } } diff --git a/libm/configure.rs b/libm/configure.rs index 76186e63..aa6a33d9 100644 --- a/libm/configure.rs +++ b/libm/configure.rs @@ -48,8 +48,10 @@ impl Config { target_features, // Note that these are unstable options, so only show up with the nightly compiler or // with `RUSTC_BOOTSTRAP=1` (which is required to use the types anyway). - reliable_f128: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F128").is_some(), - reliable_f16: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F16").is_some(), + // reliable_f128: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F128").is_some(), + // reliable_f16: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F16").is_some(), + reliable_f16: true, + reliable_f128: true, } } } From 0437efba9eaafd403d8897e164e3157d9ac91303 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 7 Aug 2025 03:39:32 -0500 Subject: [PATCH 2/9] don't test against system symbols s390x --- builtins-test/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtins-test/build.rs b/builtins-test/build.rs index 5b2dcd12..b14a822b 100644 --- a/builtins-test/build.rs +++ b/builtins-test/build.rs @@ -69,6 +69,8 @@ fn main() { || target.arch == "powerpc64" || target.arch == "powerpc64le" || target.arch == "loongarch64" + // ABI only recently got specified + || target.arch == "s390x" || (target.arch == "x86" && !target.has_feature("sse")) || target.os == "windows" // Linking says "error: function signature mismatch: __extendhfsf2" and seems to From 77d042f54ef6b20eddb4da2f4b996519eb9177f8 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 7 Aug 2025 19:41:16 +0000 Subject: [PATCH 3/9] provide extend for bootstrapping --- builtins-test/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/builtins-test/src/lib.rs b/builtins-test/src/lib.rs index f1673133..ccab0338 100644 --- a/builtins-test/src/lib.rs +++ b/builtins-test/src/lib.rs @@ -15,6 +15,7 @@ #![no_std] #![cfg_attr(f128_enabled, feature(f128))] #![cfg_attr(f16_enabled, feature(f16))] +#![feature(linkage)] pub mod bench; extern crate alloc; @@ -403,3 +404,13 @@ macro_rules! apfloat_fallback { $apfloat_op($($arg),+) }}; } + +#[cfg(target_arch = "s390x")] +mod bootstrap { + // Needed for testing other symbols, + #[linkage = "weak"] + #[unsafe(no_mangle)] + pub extern "C" fn __extendhfsf2(a: f16) -> f32 { + compiler_builtins::float::extend::__extendhfsf2(a) + } +} From 3824d158ab7f64661893f338725aa899375515a6 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 7 Aug 2025 19:47:43 +0000 Subject: [PATCH 4/9] fixes --- builtins-test/src/lib.rs | 3 ++- libm/configure.rs | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/builtins-test/src/lib.rs b/builtins-test/src/lib.rs index ccab0338..fad87ad4 100644 --- a/builtins-test/src/lib.rs +++ b/builtins-test/src/lib.rs @@ -405,11 +405,12 @@ macro_rules! apfloat_fallback { }}; } -#[cfg(target_arch = "s390x")] mod bootstrap { // Needed for testing other symbols, #[linkage = "weak"] #[unsafe(no_mangle)] + #[cfg(f16_enabled)] + #[cfg(target_arch = "s390x")] pub extern "C" fn __extendhfsf2(a: f16) -> f32 { compiler_builtins::float::extend::__extendhfsf2(a) } diff --git a/libm/configure.rs b/libm/configure.rs index aa6a33d9..dece6aa3 100644 --- a/libm/configure.rs +++ b/libm/configure.rs @@ -33,13 +33,16 @@ impl Config { .map(|s| s.to_lowercase().replace("_", "-")) .collect(); + let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + let bootstrapping_f16 = target_arch == "x86"; + Self { target_triple, manifest_dir: PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()), out_dir: PathBuf::from(env::var("OUT_DIR").unwrap()), opt_level: env::var("OPT_LEVEL").unwrap(), cargo_features, - target_arch: env::var("CARGO_CFG_TARGET_ARCH").unwrap(), + target_arch, target_env: env::var("CARGO_CFG_TARGET_ENV").unwrap(), target_family: env::var("CARGO_CFG_TARGET_FAMILY").ok(), target_os: env::var("CARGO_CFG_TARGET_OS").unwrap(), @@ -50,7 +53,7 @@ impl Config { // with `RUSTC_BOOTSTRAP=1` (which is required to use the types anyway). // reliable_f128: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F128").is_some(), // reliable_f16: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F16").is_some(), - reliable_f16: true, + reliable_f16: !bootstrapping_f16, reliable_f128: true, } } From c7e595ae9aa898e8cd5dae8aa2e43e91b390757d Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 7 Aug 2025 19:53:30 +0000 Subject: [PATCH 5/9] more bootstrapping --- builtins-test/src/lib.rs | 13 +++++++++++-- libm/configure.rs | 6 +++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/builtins-test/src/lib.rs b/builtins-test/src/lib.rs index fad87ad4..a7d5922a 100644 --- a/builtins-test/src/lib.rs +++ b/builtins-test/src/lib.rs @@ -407,11 +407,20 @@ macro_rules! apfloat_fallback { mod bootstrap { // Needed for testing other symbols, - #[linkage = "weak"] - #[unsafe(no_mangle)] #[cfg(f16_enabled)] #[cfg(target_arch = "s390x")] + #[linkage = "weak"] + #[unsafe(no_mangle)] pub extern "C" fn __extendhfsf2(a: f16) -> f32 { compiler_builtins::float::extend::__extendhfsf2(a) } + + #[cfg(f16_enabled)] + #[cfg(f128_enabled)] + #[cfg(target_arch = "x86")] + #[linkage = "weak"] + #[unsafe(no_mangle)] + pub extern "C" fn __extenddftf2(a: f64) -> f128 { + compiler_builtins::float::extend::__extenddftf2(a) + } } diff --git a/libm/configure.rs b/libm/configure.rs index dece6aa3..c5bfc2dd 100644 --- a/libm/configure.rs +++ b/libm/configure.rs @@ -34,7 +34,7 @@ impl Config { .collect(); let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); - let bootstrapping_f16 = target_arch == "x86"; + let bootstrapping_f128 = target_arch == "x86"; Self { target_triple, @@ -53,8 +53,8 @@ impl Config { // with `RUSTC_BOOTSTRAP=1` (which is required to use the types anyway). // reliable_f128: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F128").is_some(), // reliable_f16: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F16").is_some(), - reliable_f16: !bootstrapping_f16, - reliable_f128: true, + reliable_f16: true, + reliable_f128: bootstrapping_f128, } } } From d1be246033e8d8bbdff2dc148da8be50743f6892 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 7 Aug 2025 20:00:47 +0000 Subject: [PATCH 6/9] more bootstrapping --- builtins-test/src/lib.rs | 9 ++++++++- libm/configure.rs | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/builtins-test/src/lib.rs b/builtins-test/src/lib.rs index a7d5922a..a72b8afb 100644 --- a/builtins-test/src/lib.rs +++ b/builtins-test/src/lib.rs @@ -415,7 +415,6 @@ mod bootstrap { compiler_builtins::float::extend::__extendhfsf2(a) } - #[cfg(f16_enabled)] #[cfg(f128_enabled)] #[cfg(target_arch = "x86")] #[linkage = "weak"] @@ -423,4 +422,12 @@ mod bootstrap { pub extern "C" fn __extenddftf2(a: f64) -> f128 { compiler_builtins::float::extend::__extenddftf2(a) } + + #[cfg(f128_enabled)] + #[cfg(target_arch = "x86")] + #[linkage = "weak"] + #[unsafe(no_mangle)] + pub extern "C" fn __floattitf(i: i128) -> f128 { + compiler_builtins::float::conv::__floattitf(a) + } } diff --git a/libm/configure.rs b/libm/configure.rs index c5bfc2dd..7d9a6b8c 100644 --- a/libm/configure.rs +++ b/libm/configure.rs @@ -34,6 +34,7 @@ impl Config { .collect(); let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + // Symbols are missing so we can't test until they get to nightly let bootstrapping_f128 = target_arch == "x86"; Self { @@ -51,10 +52,10 @@ impl Config { target_features, // Note that these are unstable options, so only show up with the nightly compiler or // with `RUSTC_BOOTSTRAP=1` (which is required to use the types anyway). - // reliable_f128: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F128").is_some(), // reliable_f16: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F16").is_some(), reliable_f16: true, - reliable_f128: bootstrapping_f128, + reliable_f128: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F128").is_some() + && !bootstrapping_f128, } } } From 03e375bd63e9e092325957b1517136a2e2a1ca9e Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 7 Aug 2025 20:01:55 +0000 Subject: [PATCH 7/9] s390x still disable libm --- libm/configure.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libm/configure.rs b/libm/configure.rs index 7d9a6b8c..c7a3a14d 100644 --- a/libm/configure.rs +++ b/libm/configure.rs @@ -35,7 +35,7 @@ impl Config { let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); // Symbols are missing so we can't test until they get to nightly - let bootstrapping_f128 = target_arch == "x86"; + let bootstrapping_f128 = target_arch == "x86" || target_arch == "s390x"; Self { target_triple, From a71d97eb1f69abddb7ee255ea068763082cf63e8 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 7 Aug 2025 20:04:03 +0000 Subject: [PATCH 8/9] update --- builtins-test/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtins-test/src/lib.rs b/builtins-test/src/lib.rs index a72b8afb..09e8c6db 100644 --- a/builtins-test/src/lib.rs +++ b/builtins-test/src/lib.rs @@ -428,6 +428,6 @@ mod bootstrap { #[linkage = "weak"] #[unsafe(no_mangle)] pub extern "C" fn __floattitf(i: i128) -> f128 { - compiler_builtins::float::conv::__floattitf(a) + compiler_builtins::float::conv::__floattitf(i) } } From 15049e1f55b2493103867c8234aa4dd003fc7df5 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 7 Aug 2025 20:17:01 +0000 Subject: [PATCH 9/9] update --- libm/configure.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libm/configure.rs b/libm/configure.rs index c7a3a14d..44dee856 100644 --- a/libm/configure.rs +++ b/libm/configure.rs @@ -35,7 +35,8 @@ impl Config { let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); // Symbols are missing so we can't test until they get to nightly - let bootstrapping_f128 = target_arch == "x86" || target_arch == "s390x"; + let bootstrapping_f16 = target_arch == "s390x"; + let bootstrapping_f128 = target_arch == "x86"; Self { target_triple, @@ -52,8 +53,8 @@ impl Config { target_features, // Note that these are unstable options, so only show up with the nightly compiler or // with `RUSTC_BOOTSTRAP=1` (which is required to use the types anyway). - // reliable_f16: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F16").is_some(), - reliable_f16: true, + reliable_f16: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F16").is_some() + && !bootstrapping_f16, reliable_f128: env::var_os("CARGO_CFG_TARGET_HAS_RELIABLE_F128").is_some() && !bootstrapping_f128, }