Skip to content

Commit 471b669

Browse files
committed
Enable tests and compiler-builtins for f16/f128
1 parent 076b447 commit 471b669

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
@@ -201,14 +201,36 @@ impl CodegenBackend for CraneliftCodegenBackend {
201201
// FIXME do `unstable_target_features` properly
202202
let unstable_target_features = target_features.clone();
203203

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

0 commit comments

Comments
 (0)