Skip to content

Commit

Permalink
Merge pull request #730 from tgross35/f16-f128-config-update
Browse files Browse the repository at this point in the history
Disable `f16` on platforms that have recursion problems
  • Loading branch information
tgross35 authored Nov 5, 2024
2 parents e344295 + 077f018 commit a09218f
Showing 1 changed file with 35 additions and 20 deletions.
55 changes: 35 additions & 20 deletions configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,46 @@ impl Target {
/// Configure whether or not `f16` and `f128` support should be enabled.
pub 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.
// that the backend will not crash when using these types and generates code that can be called
// without crashing (no infinite recursion). This does not mean that the platform doesn't have
// ABI or other 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),
// FIXME(llvm): `f16` test failures fixed by <https://github.com/llvm/llvm-project/pull/107791>
"loongarch64" => (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" => (true, false),
// `f16` miscompiles <https://github.com/llvm/llvm-project/issues/96438>
"wasm32" | "wasm64" => (false, true),
let f16_enabled = match target.arch.as_str() {
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
"arm64ec" => false,
// Selection failure <https://github.com/llvm/llvm-project/issues/50374>
"s390x" => false,
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
// FIXME(llvm): loongarch fixed by <https://github.com/llvm/llvm-project/pull/107791>
"csky" => false,
"hexagon" => false,
"loongarch64" => false,
"mips" | "mips64" | "mips32r6" | "mips64r6" => false,
"powerpc" | "powerpc64" => false,
"sparc" | "sparc64" => false,
"wasm32" | "wasm64" => false,
// Most everything else works as of LLVM 19
_ => (true, true),
_ => true,
};

let f128_enabled = match target.arch.as_str() {
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
"arm64ec" => false,
// Selection failure <https://github.com/llvm/llvm-project/issues/96432>
"mips64" | "mips64r6" => false,
// Selection failure <https://github.com/llvm/llvm-project/issues/95471>
"nvptx64" => false,
// Selection failure <https://github.com/llvm/llvm-project/issues/101545>
"powerpc64" if &target.os == "aix" => false,
// Selection failure <https://github.com/llvm/llvm-project/issues/41838>
"sparc" => false,
// Most everything else works as of LLVM 19
_ => true,
};

// If the feature is set, disable these types.
Expand All @@ -84,11 +99,11 @@ pub fn configure_f16_f128(target: &Target) {
println!("cargo::rustc-check-cfg=cfg(f16_enabled)");
println!("cargo::rustc-check-cfg=cfg(f128_enabled)");

if f16_ok && !disable_both {
if f16_enabled && !disable_both {
println!("cargo::rustc-cfg=f16_enabled");
}

if f128_ok && !disable_both {
if f128_enabled && !disable_both {
println!("cargo::rustc-cfg=f128_enabled");
}
}

0 comments on commit a09218f

Please sign in to comment.