Skip to content

Unconditionally enable f16 & f128 to see what passes with llvm21 #1004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions builtins-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions builtins-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -403,3 +404,30 @@ macro_rules! apfloat_fallback {
$apfloat_op($($arg),+)
}};
}

mod bootstrap {
// Needed for testing other symbols,
#[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(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)
}

#[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(i)
}
}
6 changes: 4 additions & 2 deletions compiler-builtins/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
13 changes: 10 additions & 3 deletions libm/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ impl Config {
.map(|s| s.to_lowercase().replace("_", "-"))
.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_f16 = target_arch == "s390x";
let bootstrapping_f128 = 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(),
Expand All @@ -48,8 +53,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: 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,
}
}
}
Expand Down
Loading