Skip to content

Commit cc6d538

Browse files
committed
Enable tests and compiler-builtins for f16/f128
1 parent b8af805 commit cc6d538

File tree

4 files changed

+29
-15
lines changed

4 files changed

+29
-15
lines changed

build_system/build_sysroot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ fn build_clif_sysroot_for_triple(
235235
compiler.rustflags.extend(rustflags);
236236
let mut build_cmd = STANDARD_LIBRARY.build(&compiler, dirs);
237237
build_cmd.arg("--release");
238-
build_cmd.arg("--features").arg("backtrace panic-unwind compiler-builtins-no-f16-f128");
238+
build_cmd.arg("--features").arg("backtrace panic-unwind");
239239
build_cmd.arg(format!("-Zroot-dir={}", STDLIB_SRC.to_path(dirs).display()));
240240
build_cmd.env("CARGO_PROFILE_RELEASE_DEBUG", "true");
241241
build_cmd.env("__CARGO_DEFAULT_LIB_METADATA", "cg_clif");

scripts/setup_rust_fork.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ verbose-tests = false
4343
# disabled bootstrap will crash trying to copy llvm tools for the bootstrap
4444
# compiler.
4545
llvm-tools = false
46-
std-features = ["panic-unwind", "compiler-builtins-no-f16-f128"]
46+
std-features = ["panic-unwind"]
4747
4848
EOF
4949

scripts/test_rustc_tests.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,6 @@ rm tests/ui/consts/precise-drop-with-coverage.rs
7272
rm tests/ui/issues/issue-85461.rs
7373
rm -r tests/ui/instrument-coverage/
7474

75-
# missing f16/f128 support
76-
rm tests/ui/half-open-range-patterns/half-open-range-pats-semantics.rs
77-
rm tests/ui/asm/aarch64/type-f16.rs
78-
rm tests/ui/float/conv-bits-runtime-const.rs
79-
rm tests/ui/consts/const-eval/float_methods.rs
80-
rm tests/ui/match/match-float.rs
81-
rm tests/ui/float/target-has-reliable-nightly-float.rs
82-
8375
# optimization tests
8476
# ==================
8577
rm tests/ui/codegen/issue-28950.rs # depends on stack size optimizations

src/lib.rs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,36 @@ impl CodegenBackend for CraneliftCodegenBackend {
198198
// FIXME do `unstable_target_features` properly
199199
let unstable_target_features = target_features.clone();
200200

201+
// FIXME(f16_f128): LLVM 20 (currently used by `rustc`) passes `f128` in XMM registers on
202+
// Windows, whereas LLVM 21+ and Cranelift pass it indirectly. This means that `f128` won't
203+
// work when linking against a LLVM-built sysroot.
204+
let has_reliable_f128 = !sess.target.is_like_windows;
205+
let has_reliable_f16 = match &*sess.target.arch {
206+
// FIXME(f16_f128): LLVM 20 does not support `f16` on s390x, meaning the required
207+
// builtins are not available in `compiler-builtins`.
208+
"s390x" => false,
209+
// FIXME(f16_f128): `rustc_codegen_llvm` currently disables support on Windows GNU
210+
// targets due to GCC using a different ABI than LLVM. Therefore `f16` won't be
211+
// available when using a LLVM-built sysroot.
212+
"x86_64"
213+
if sess.target.os == "windows"
214+
&& sess.target.env == "gnu"
215+
&& sess.target.abi != "llvm" =>
216+
{
217+
false
218+
}
219+
_ => true,
220+
};
221+
201222
TargetConfig {
202223
target_features,
203224
unstable_target_features,
204-
// Cranelift does not yet support f16 or f128
205-
has_reliable_f16: false,
206-
has_reliable_f16_math: false,
207-
has_reliable_f128: false,
208-
has_reliable_f128_math: false,
225+
// `rustc_codegen_cranelift` polyfills functionality not yet
226+
// available in Cranelift.
227+
has_reliable_f16,
228+
has_reliable_f16_math: has_reliable_f16,
229+
has_reliable_f128,
230+
has_reliable_f128_math: has_reliable_f128,
209231
}
210232
}
211233

0 commit comments

Comments
 (0)