Configure which platforms get f16 and f128 enabled by default
By moving the logic for which platforms get symbols to `compiler_builtins` rather than rust-lang/rust, we can control where symbols get enabled without relying on Cargo features. Using Cargo features turned out to be a problem in [1]. This will help resolve errors like [2]. [1]: https://github.com/rust-lang/rust/issues/128358 [2]: https://github.com/rust-lang/rust/issues/128401
This commit is contained in:
parent
b32758cdc2
commit
b168f56dd4
1 changed files with 44 additions and 2 deletions
|
|
@ -42,11 +42,12 @@ impl Target {
|
|||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
configure_check_cfg();
|
||||
|
||||
let target = Target::from_env();
|
||||
let cwd = env::current_dir().unwrap();
|
||||
|
||||
configure_check_cfg();
|
||||
configure_f16_f128(&target);
|
||||
|
||||
println!("cargo:compiler-rt={}", cwd.join("compiler-rt").display());
|
||||
|
||||
// Activate libm's unstable features to make full use of Nightly.
|
||||
|
|
@ -259,6 +260,47 @@ fn configure_check_cfg() {
|
|||
println!("cargo::rustc-check-cfg=cfg(assert_no_panic)");
|
||||
}
|
||||
|
||||
/// Configure whether or not `f16` and `f128` support should be enabled.
|
||||
fn configure_f16_f128(target: &Target) {
|
||||
// Set whether or not `f16` and `f128` are supported at a basic level by LLVM. This only means
|
||||
// that the backend will not crash when using these types. This does not mean that the
|
||||
// backend does the right thing, or that the platform doesn't have ABI bugs.
|
||||
//
|
||||
// We do this here rather than in `rust-lang/rust` because configuring via cargo features is
|
||||
// not straightforward.
|
||||
//
|
||||
// Original source of this list:
|
||||
// <https://github.com/rust-lang/compiler-builtins/pull/652#issuecomment-2266151350>
|
||||
let (f16_ok, f128_ok) = match target.arch.as_str() {
|
||||
// `f16` and `f128` both crash <https://github.com/llvm/llvm-project/issues/94434>
|
||||
"arm64ec" => (false, false),
|
||||
// `f16` crashes <https://github.com/llvm/llvm-project/issues/50374>
|
||||
"s390x" => (false, true),
|
||||
// `f128` crashes <https://github.com/llvm/llvm-project/issues/96432>
|
||||
"mips64" | "mips64r6" => (true, false),
|
||||
// `f128` crashes <https://github.com/llvm/llvm-project/issues/101545>
|
||||
"powerpc64" if &target.os == "aix" => (true, false),
|
||||
// `f128` crashes <https://github.com/llvm/llvm-project/issues/41838>
|
||||
"sparc" | "sparcv9" => (true, false),
|
||||
// Most everything else works as of LLVM 19
|
||||
_ => (true, true),
|
||||
};
|
||||
|
||||
// If the feature is set, disable these types.
|
||||
let disable_both = env::var_os("CARGO_FEATURE_NO_F16_F128").is_some();
|
||||
|
||||
println!("cargo::rustc-check-cfg=cfg(f16_enabled)");
|
||||
println!("cargo::rustc-check-cfg=cfg(f128_enabled)");
|
||||
|
||||
if f16_ok && !disable_both {
|
||||
println!("cargo::rustc-cfg=f16_enabled");
|
||||
}
|
||||
|
||||
if f128_ok && !disable_both {
|
||||
println!("cargo::rustc-cfg=f128_enabled");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "c")]
|
||||
mod c {
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue