Skip to content

Commit a09218f

Browse files
authored
Merge pull request #730 from tgross35/f16-f128-config-update
Disable `f16` on platforms that have recursion problems
2 parents e344295 + 077f018 commit a09218f

File tree

1 file changed

+35
-20
lines changed

1 file changed

+35
-20
lines changed

configure.rs

+35-20
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,46 @@ impl Target {
5151
/// Configure whether or not `f16` and `f128` support should be enabled.
5252
pub fn configure_f16_f128(target: &Target) {
5353
// Set whether or not `f16` and `f128` are supported at a basic level by LLVM. This only means
54-
// that the backend will not crash when using these types. This does not mean that the
55-
// backend does the right thing, or that the platform doesn't have ABI bugs.
54+
// that the backend will not crash when using these types and generates code that can be called
55+
// without crashing (no infinite recursion). This does not mean that the platform doesn't have
56+
// ABI or other bugs.
5657
//
5758
// We do this here rather than in `rust-lang/rust` because configuring via cargo features is
5859
// not straightforward.
5960
//
6061
// Original source of this list:
6162
// <https://github.com/rust-lang/compiler-builtins/pull/652#issuecomment-2266151350>
62-
let (f16_ok, f128_ok) = match target.arch.as_str() {
63-
// `f16` and `f128` both crash <https://github.com/llvm/llvm-project/issues/94434>
64-
"arm64ec" => (false, false),
65-
// `f16` crashes <https://github.com/llvm/llvm-project/issues/50374>
66-
"s390x" => (false, true),
67-
// FIXME(llvm): `f16` test failures fixed by <https://github.com/llvm/llvm-project/pull/107791>
68-
"loongarch64" => (false, true),
69-
// `f128` crashes <https://github.com/llvm/llvm-project/issues/96432>
70-
"mips64" | "mips64r6" => (true, false),
71-
// `f128` crashes <https://github.com/llvm/llvm-project/issues/101545>
72-
"powerpc64" if &target.os == "aix" => (true, false),
73-
// `f128` crashes <https://github.com/llvm/llvm-project/issues/41838>
74-
"sparc" => (true, false),
75-
// `f16` miscompiles <https://github.com/llvm/llvm-project/issues/96438>
76-
"wasm32" | "wasm64" => (false, true),
63+
let f16_enabled = match target.arch.as_str() {
64+
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
65+
"arm64ec" => false,
66+
// Selection failure <https://github.com/llvm/llvm-project/issues/50374>
67+
"s390x" => false,
68+
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
69+
// FIXME(llvm): loongarch fixed by <https://github.com/llvm/llvm-project/pull/107791>
70+
"csky" => false,
71+
"hexagon" => false,
72+
"loongarch64" => false,
73+
"mips" | "mips64" | "mips32r6" | "mips64r6" => false,
74+
"powerpc" | "powerpc64" => false,
75+
"sparc" | "sparc64" => false,
76+
"wasm32" | "wasm64" => false,
7777
// Most everything else works as of LLVM 19
78-
_ => (true, true),
78+
_ => true,
79+
};
80+
81+
let f128_enabled = match target.arch.as_str() {
82+
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
83+
"arm64ec" => false,
84+
// Selection failure <https://github.com/llvm/llvm-project/issues/96432>
85+
"mips64" | "mips64r6" => false,
86+
// Selection failure <https://github.com/llvm/llvm-project/issues/95471>
87+
"nvptx64" => false,
88+
// Selection failure <https://github.com/llvm/llvm-project/issues/101545>
89+
"powerpc64" if &target.os == "aix" => false,
90+
// Selection failure <https://github.com/llvm/llvm-project/issues/41838>
91+
"sparc" => false,
92+
// Most everything else works as of LLVM 19
93+
_ => true,
7994
};
8095

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

87-
if f16_ok && !disable_both {
102+
if f16_enabled && !disable_both {
88103
println!("cargo::rustc-cfg=f16_enabled");
89104
}
90105

91-
if f128_ok && !disable_both {
106+
if f128_enabled && !disable_both {
92107
println!("cargo::rustc-cfg=f128_enabled");
93108
}
94109
}

0 commit comments

Comments
 (0)