Skip to content

Commit 5d96870

Browse files
committed
std float tests: special-case Miri in feature detection
also fix some cfg logic
1 parent 9337f7a commit 5d96870

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

library/std/build.rs

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ fn main() {
1111
.expect("CARGO_CFG_TARGET_POINTER_WIDTH was not set")
1212
.parse()
1313
.unwrap();
14+
let is_miri = env::var_os("CARGO_CFG_MIRI").is_some();
1415

1516
println!("cargo:rustc-check-cfg=cfg(netbsd10)");
1617
if target_os == "netbsd" && env::var("RUSTC_STD_NETBSD10").is_ok() {
@@ -91,6 +92,8 @@ fn main() {
9192
println!("cargo:rustc-check-cfg=cfg(reliable_f128_math)");
9293

9394
let has_reliable_f16 = match (target_arch.as_str(), target_os.as_str()) {
95+
// We can always enable these in Miri as that is not affected by codegen bugs.
96+
_ if is_miri => true,
9497
// Selection failure until recent LLVM <https://github.com/llvm/llvm-project/issues/93894>
9598
// FIXME(llvm19): can probably be removed at the version bump
9699
("loongarch64", _) => false,
@@ -118,6 +121,8 @@ fn main() {
118121
};
119122

120123
let has_reliable_f128 = match (target_arch.as_str(), target_os.as_str()) {
124+
// We can always enable these in Miri as that is not affected by codegen bugs.
125+
_ if is_miri => true,
121126
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
122127
("arm64ec", _) => false,
123128
// ABI and precision bugs <https://github.com/rust-lang/rust/issues/125109>
@@ -141,6 +146,8 @@ fn main() {
141146
// LLVM is currenlty adding missing routines, <https://github.com/llvm/llvm-project/issues/93566>
142147
let has_reliable_f16_math = has_reliable_f16
143148
&& match (target_arch.as_str(), target_os.as_str()) {
149+
// FIXME: Disabled on Miri as the intrinsics are not implemented yet.
150+
_ if is_miri => false,
144151
// Currently nothing special. Hooray!
145152
// This will change as platforms gain better better support for standard ops but math
146153
// lags behind.
@@ -149,6 +156,8 @@ fn main() {
149156

150157
let has_reliable_f128_math = has_reliable_f128
151158
&& match (target_arch.as_str(), target_os.as_str()) {
159+
// FIXME: Disabled on Miri as the intrinsics are not implemented yet.
160+
_ if is_miri => false,
152161
// LLVM lowers `fp128` math to `long double` symbols even on platforms where
153162
// `long double` is not IEEE binary128. See
154163
// <https://github.com/llvm/llvm-project/issues/44744>.

library/std/src/f16/tests.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
use crate::f16::consts;
55
use crate::num::{FpCategory as Fp, *};
66

7-
/// Tolerance for results on the order of 10.0e-2;
8-
#[cfg(reliable_f16_math)]
7+
/// Tolerance for results on the order of 10.0e-2
8+
#[allow(unused)]
99
const TOL_N2: f16 = 0.0001;
1010

1111
/// Tolerance for results on the order of 10.0e+0
12-
#[cfg(reliable_f16_math)]
12+
#[allow(unused)]
1313
const TOL_0: f16 = 0.01;
1414

1515
/// Tolerance for results on the order of 10.0e+2
16-
#[cfg(reliable_f16_math)]
16+
#[allow(unused)]
1717
const TOL_P2: f16 = 0.5;
1818

1919
/// Tolerance for results on the order of 10.0e+4
20-
#[cfg(reliable_f16_math)]
20+
#[allow(unused)]
2121
const TOL_P4: f16 = 10.0;
2222

2323
/// Smallest number

0 commit comments

Comments
 (0)