Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b1025c9

Browse files
committedApr 26, 2025·
Use feature(target_has_reliable_f16_f128) in library tests
New compiler configuration has been introduced that is designed to replace the build script configuration `reliable_f16`, `reliable_f128`, `reliable_f16_math`, and `reliable_f128_math`. Do this replacement here, which allows us to clean up `std`'s build script. All tests are gated by `#[cfg(bootstrap)]` rather than doing a more complicated `cfg(bootstrap)` / `cfg(not(bootstrap))` split since the next beta split is within two weeks.
1 parent 9c98618 commit b1025c9

File tree

6 files changed

+552
-262
lines changed

6 files changed

+552
-262
lines changed
 

‎library/std/build.rs

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ fn main() {
77
let target_vendor =
88
env::var("CARGO_CFG_TARGET_VENDOR").expect("CARGO_CFG_TARGET_VENDOR was not set");
99
let target_env = env::var("CARGO_CFG_TARGET_ENV").expect("CARGO_CFG_TARGET_ENV was not set");
10-
let target_abi = env::var("CARGO_CFG_TARGET_ABI").expect("CARGO_CFG_TARGET_ABI was not set");
11-
let target_pointer_width: u32 = env::var("CARGO_CFG_TARGET_POINTER_WIDTH")
12-
.expect("CARGO_CFG_TARGET_POINTER_WIDTH was not set")
13-
.parse()
14-
.unwrap();
15-
let is_miri = env::var_os("CARGO_CFG_MIRI").is_some();
1610

1711
println!("cargo:rustc-check-cfg=cfg(netbsd10)");
1812
if target_os == "netbsd" && env::var("RUSTC_STD_NETBSD10").is_ok() {
@@ -80,108 +74,4 @@ fn main() {
8074
println!("cargo:rustc-cfg=backtrace_in_libstd");
8175

8276
println!("cargo:rustc-env=STD_ENV_ARCH={}", env::var("CARGO_CFG_TARGET_ARCH").unwrap());
83-
84-
// Emit these on platforms that have no known ABI bugs, LLVM selection bugs, lowering bugs,
85-
// missing symbols, or other problems, to determine when tests get run.
86-
// If more broken platforms are found, please update the tracking issue at
87-
// <https://github.com/rust-lang/rust/issues/116909>
88-
//
89-
// Some of these match arms are redundant; the goal is to separate reasons that the type is
90-
// unreliable, even when multiple reasons might fail the same platform.
91-
println!("cargo:rustc-check-cfg=cfg(reliable_f16)");
92-
println!("cargo:rustc-check-cfg=cfg(reliable_f128)");
93-
94-
// This is a step beyond only having the types and basic functions available. Math functions
95-
// aren't consistently available or correct.
96-
println!("cargo:rustc-check-cfg=cfg(reliable_f16_math)");
97-
println!("cargo:rustc-check-cfg=cfg(reliable_f128_math)");
98-
99-
let has_reliable_f16 = match (target_arch.as_str(), target_os.as_str()) {
100-
// We can always enable these in Miri as that is not affected by codegen bugs.
101-
_ if is_miri => true,
102-
// Selection failure <https://github.com/llvm/llvm-project/issues/50374>
103-
("s390x", _) => false,
104-
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
105-
("arm64ec", _) => false,
106-
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
107-
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
108-
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
109-
("csky", _) => false,
110-
("hexagon", _) => false,
111-
("powerpc" | "powerpc64", _) => false,
112-
("sparc" | "sparc64", _) => false,
113-
("wasm32" | "wasm64", _) => false,
114-
// `f16` support only requires that symbols converting to and from `f32` are available. We
115-
// provide these in `compiler-builtins`, so `f16` should be available on all platforms that
116-
// do not have other ABI issues or LLVM crashes.
117-
_ => true,
118-
};
119-
120-
let has_reliable_f128 = match (target_arch.as_str(), target_os.as_str()) {
121-
// We can always enable these in Miri as that is not affected by codegen bugs.
122-
_ if is_miri => true,
123-
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
124-
("arm64ec", _) => false,
125-
// Selection bug <https://github.com/llvm/llvm-project/issues/96432>
126-
("mips64" | "mips64r6", _) => false,
127-
// Selection bug <https://github.com/llvm/llvm-project/issues/95471>
128-
("nvptx64", _) => false,
129-
// ABI bugs <https://github.com/rust-lang/rust/issues/125109> et al. (full
130-
// list at <https://github.com/rust-lang/rust/issues/116909>)
131-
("powerpc" | "powerpc64", _) => false,
132-
// ABI unsupported <https://github.com/llvm/llvm-project/issues/41838>
133-
("sparc", _) => false,
134-
// Stack alignment bug <https://github.com/llvm/llvm-project/issues/77401>. NB: tests may
135-
// not fail if our compiler-builtins is linked.
136-
("x86", _) => false,
137-
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
138-
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
139-
// There are no known problems on other platforms, so the only requirement is that symbols
140-
// are available. `compiler-builtins` provides all symbols required for core `f128`
141-
// support, so this should work for everything else.
142-
_ => true,
143-
};
144-
145-
// Configure platforms that have reliable basics but may have unreliable math.
146-
147-
// LLVM is currently adding missing routines, <https://github.com/llvm/llvm-project/issues/93566>
148-
let has_reliable_f16_math = has_reliable_f16
149-
&& match (target_arch.as_str(), target_os.as_str()) {
150-
// FIXME: Disabled on Miri as the intrinsics are not implemented yet.
151-
_ if is_miri => false,
152-
// x86 has a crash for `powi`: <https://github.com/llvm/llvm-project/issues/105747>
153-
("x86" | "x86_64", _) => false,
154-
// Assume that working `f16` means working `f16` math for most platforms, since
155-
// operations just go through `f32`.
156-
_ => true,
157-
};
158-
159-
let has_reliable_f128_math = has_reliable_f128
160-
&& match (target_arch.as_str(), target_os.as_str()) {
161-
// FIXME: Disabled on Miri as the intrinsics are not implemented yet.
162-
_ if is_miri => false,
163-
// LLVM lowers `fp128` math to `long double` symbols even on platforms where
164-
// `long double` is not IEEE binary128. See
165-
// <https://github.com/llvm/llvm-project/issues/44744>.
166-
//
167-
// This rules out anything that doesn't have `long double` = `binary128`; <= 32 bits
168-
// (ld is `f64`), anything other than Linux (Windows and MacOS use `f64`), and `x86`
169-
// (ld is 80-bit extended precision).
170-
("x86_64", _) => false,
171-
(_, "linux") if target_pointer_width == 64 => true,
172-
_ => false,
173-
};
174-
175-
if has_reliable_f16 {
176-
println!("cargo:rustc-cfg=reliable_f16");
177-
}
178-
if has_reliable_f128 {
179-
println!("cargo:rustc-cfg=reliable_f128");
180-
}
181-
if has_reliable_f16_math {
182-
println!("cargo:rustc-cfg=reliable_f16_math");
183-
}
184-
if has_reliable_f128_math {
185-
println!("cargo:rustc-cfg=reliable_f128_math");
186-
}
18777
}

‎library/std/src/f128.rs

Lines changed: 180 additions & 45 deletions
Large diffs are not rendered by default.

‎library/std/src/f16.rs

Lines changed: 180 additions & 45 deletions
Large diffs are not rendered by default.

‎library/std/tests/floats/f128.rs

Lines changed: 98 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// FIXME(f16_f128): only tested on platforms that have symbols and aren't buggy
2-
#![cfg(reliable_f128)]
2+
#![cfg(not(bootstrap))]
3+
#![cfg(target_has_reliable_f128)]
34

45
use std::f128::consts;
56
use std::num::FpCategory as Fp;
6-
#[cfg(reliable_f128_math)]
7+
#[cfg(not(miri))]
8+
#[cfg(not(bootstrap))]
9+
#[cfg(target_has_reliable_f128_math)]
710
use std::ops::Rem;
811
use std::ops::{Add, Div, Mul, Sub};
912

@@ -19,7 +22,9 @@ const TOL: f128 = 1e-12;
1922

2023
/// Tolerances for math that is allowed to be imprecise, usually due to multiple chained
2124
/// operations.
22-
#[cfg(reliable_f128_math)]
25+
#[cfg(not(miri))]
26+
#[cfg(not(bootstrap))]
27+
#[cfg(target_has_reliable_f128_math)]
2328
const TOL_IMPR: f128 = 1e-10;
2429

2530
/// Smallest number
@@ -66,37 +71,50 @@ fn test_num_f128() {
6671
assert_eq!(ten.div(two), ten / two);
6772
}
6873

74+
// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
75+
// the intrinsics.
76+
6977
#[test]
70-
#[cfg(reliable_f128_math)]
78+
#[cfg(not(miri))]
79+
#[cfg(not(bootstrap))]
80+
#[cfg(target_has_reliable_f128_math)]
7181
fn test_num_f128_rem() {
7282
let ten = 10f128;
7383
let two = 2f128;
7484
assert_eq!(ten.rem(two), ten % two);
7585
}
7686

7787
#[test]
78-
#[cfg(reliable_f128_math)]
88+
#[cfg(not(miri))]
89+
#[cfg(not(bootstrap))]
90+
#[cfg(target_has_reliable_f128_math)]
7991
fn test_min_nan() {
8092
assert_eq!(f128::NAN.min(2.0), 2.0);
8193
assert_eq!(2.0f128.min(f128::NAN), 2.0);
8294
}
8395

8496
#[test]
85-
#[cfg(reliable_f128_math)]
97+
#[cfg(not(miri))]
98+
#[cfg(not(bootstrap))]
99+
#[cfg(target_has_reliable_f128_math)]
86100
fn test_max_nan() {
87101
assert_eq!(f128::NAN.max(2.0), 2.0);
88102
assert_eq!(2.0f128.max(f128::NAN), 2.0);
89103
}
90104

91105
#[test]
92-
#[cfg(reliable_f128_math)]
106+
#[cfg(not(miri))]
107+
#[cfg(not(bootstrap))]
108+
#[cfg(target_has_reliable_f128_math)]
93109
fn test_minimum() {
94110
assert!(f128::NAN.minimum(2.0).is_nan());
95111
assert!(2.0f128.minimum(f128::NAN).is_nan());
96112
}
97113

98114
#[test]
99-
#[cfg(reliable_f128_math)]
115+
#[cfg(not(miri))]
116+
#[cfg(not(bootstrap))]
117+
#[cfg(target_has_reliable_f128_math)]
100118
fn test_maximum() {
101119
assert!(f128::NAN.maximum(2.0).is_nan());
102120
assert!(2.0f128.maximum(f128::NAN).is_nan());
@@ -253,7 +271,9 @@ fn test_classify() {
253271
}
254272

255273
#[test]
256-
#[cfg(reliable_f128_math)]
274+
#[cfg(not(miri))]
275+
#[cfg(not(bootstrap))]
276+
#[cfg(target_has_reliable_f128_math)]
257277
fn test_floor() {
258278
assert_approx_eq!(1.0f128.floor(), 1.0f128, TOL_PRECISE);
259279
assert_approx_eq!(1.3f128.floor(), 1.0f128, TOL_PRECISE);
@@ -268,7 +288,9 @@ fn test_floor() {
268288
}
269289

270290
#[test]
271-
#[cfg(reliable_f128_math)]
291+
#[cfg(not(miri))]
292+
#[cfg(not(bootstrap))]
293+
#[cfg(target_has_reliable_f128_math)]
272294
fn test_ceil() {
273295
assert_approx_eq!(1.0f128.ceil(), 1.0f128, TOL_PRECISE);
274296
assert_approx_eq!(1.3f128.ceil(), 2.0f128, TOL_PRECISE);
@@ -283,7 +305,9 @@ fn test_ceil() {
283305
}
284306

285307
#[test]
286-
#[cfg(reliable_f128_math)]
308+
#[cfg(not(miri))]
309+
#[cfg(not(bootstrap))]
310+
#[cfg(target_has_reliable_f128_math)]
287311
fn test_round() {
288312
assert_approx_eq!(2.5f128.round(), 3.0f128, TOL_PRECISE);
289313
assert_approx_eq!(1.0f128.round(), 1.0f128, TOL_PRECISE);
@@ -299,7 +323,9 @@ fn test_round() {
299323
}
300324

301325
#[test]
302-
#[cfg(reliable_f128_math)]
326+
#[cfg(not(miri))]
327+
#[cfg(not(bootstrap))]
328+
#[cfg(target_has_reliable_f128_math)]
303329
fn test_round_ties_even() {
304330
assert_approx_eq!(2.5f128.round_ties_even(), 2.0f128, TOL_PRECISE);
305331
assert_approx_eq!(1.0f128.round_ties_even(), 1.0f128, TOL_PRECISE);
@@ -315,7 +341,9 @@ fn test_round_ties_even() {
315341
}
316342

317343
#[test]
318-
#[cfg(reliable_f128_math)]
344+
#[cfg(not(miri))]
345+
#[cfg(not(bootstrap))]
346+
#[cfg(target_has_reliable_f128_math)]
319347
fn test_trunc() {
320348
assert_approx_eq!(1.0f128.trunc(), 1.0f128, TOL_PRECISE);
321349
assert_approx_eq!(1.3f128.trunc(), 1.0f128, TOL_PRECISE);
@@ -330,7 +358,9 @@ fn test_trunc() {
330358
}
331359

332360
#[test]
333-
#[cfg(reliable_f128_math)]
361+
#[cfg(not(miri))]
362+
#[cfg(not(bootstrap))]
363+
#[cfg(target_has_reliable_f128_math)]
334364
fn test_fract() {
335365
assert_approx_eq!(1.0f128.fract(), 0.0f128, TOL_PRECISE);
336366
assert_approx_eq!(1.3f128.fract(), 0.3f128, TOL_PRECISE);
@@ -345,7 +375,9 @@ fn test_fract() {
345375
}
346376

347377
#[test]
348-
#[cfg(reliable_f128_math)]
378+
#[cfg(not(miri))]
379+
#[cfg(not(bootstrap))]
380+
#[cfg(target_has_reliable_f128_math)]
349381
fn test_abs() {
350382
assert_eq!(f128::INFINITY.abs(), f128::INFINITY);
351383
assert_eq!(1f128.abs(), 1f128);
@@ -445,7 +477,9 @@ fn test_next_down() {
445477
}
446478

447479
#[test]
448-
#[cfg(reliable_f128_math)]
480+
#[cfg(not(miri))]
481+
#[cfg(not(bootstrap))]
482+
#[cfg(target_has_reliable_f128_math)]
449483
fn test_mul_add() {
450484
let nan: f128 = f128::NAN;
451485
let inf: f128 = f128::INFINITY;
@@ -462,7 +496,9 @@ fn test_mul_add() {
462496
}
463497

464498
#[test]
465-
#[cfg(reliable_f16_math)]
499+
#[cfg(not(miri))]
500+
#[cfg(not(bootstrap))]
501+
#[cfg(target_has_reliable_f128_math)]
466502
fn test_recip() {
467503
let nan: f128 = f128::NAN;
468504
let inf: f128 = f128::INFINITY;
@@ -484,7 +520,9 @@ fn test_recip() {
484520
// Many math functions allow for less accurate results, so the next tolerance up is used
485521

486522
#[test]
487-
#[cfg(reliable_f128_math)]
523+
#[cfg(not(miri))]
524+
#[cfg(not(bootstrap))]
525+
#[cfg(target_has_reliable_f128_math)]
488526
fn test_powi() {
489527
let nan: f128 = f128::NAN;
490528
let inf: f128 = f128::INFINITY;
@@ -499,7 +537,9 @@ fn test_powi() {
499537
}
500538

501539
#[test]
502-
#[cfg(reliable_f128_math)]
540+
#[cfg(not(miri))]
541+
#[cfg(not(bootstrap))]
542+
#[cfg(target_has_reliable_f128_math)]
503543
fn test_powf() {
504544
let nan: f128 = f128::NAN;
505545
let inf: f128 = f128::INFINITY;
@@ -516,7 +556,9 @@ fn test_powf() {
516556
}
517557

518558
#[test]
519-
#[cfg(reliable_f128_math)]
559+
#[cfg(not(miri))]
560+
#[cfg(not(bootstrap))]
561+
#[cfg(target_has_reliable_f128_math)]
520562
fn test_sqrt_domain() {
521563
assert!(f128::NAN.sqrt().is_nan());
522564
assert!(f128::NEG_INFINITY.sqrt().is_nan());
@@ -528,7 +570,9 @@ fn test_sqrt_domain() {
528570
}
529571

530572
#[test]
531-
#[cfg(reliable_f128_math)]
573+
#[cfg(not(miri))]
574+
#[cfg(not(bootstrap))]
575+
#[cfg(target_has_reliable_f128_math)]
532576
fn test_exp() {
533577
assert_eq!(1.0, 0.0f128.exp());
534578
assert_approx_eq!(consts::E, 1.0f128.exp(), TOL);
@@ -543,7 +587,9 @@ fn test_exp() {
543587
}
544588

545589
#[test]
546-
#[cfg(reliable_f128_math)]
590+
#[cfg(not(miri))]
591+
#[cfg(not(bootstrap))]
592+
#[cfg(target_has_reliable_f128_math)]
547593
fn test_exp2() {
548594
assert_eq!(32.0, 5.0f128.exp2());
549595
assert_eq!(1.0, 0.0f128.exp2());
@@ -557,7 +603,9 @@ fn test_exp2() {
557603
}
558604

559605
#[test]
560-
#[cfg(reliable_f128_math)]
606+
#[cfg(not(miri))]
607+
#[cfg(not(bootstrap))]
608+
#[cfg(target_has_reliable_f128_math)]
561609
fn test_ln() {
562610
let nan: f128 = f128::NAN;
563611
let inf: f128 = f128::INFINITY;
@@ -573,7 +621,9 @@ fn test_ln() {
573621
}
574622

575623
#[test]
576-
#[cfg(reliable_f128_math)]
624+
#[cfg(not(miri))]
625+
#[cfg(not(bootstrap))]
626+
#[cfg(target_has_reliable_f128_math)]
577627
fn test_log() {
578628
let nan: f128 = f128::NAN;
579629
let inf: f128 = f128::INFINITY;
@@ -592,7 +642,9 @@ fn test_log() {
592642
}
593643

594644
#[test]
595-
#[cfg(reliable_f128_math)]
645+
#[cfg(not(miri))]
646+
#[cfg(not(bootstrap))]
647+
#[cfg(target_has_reliable_f128_math)]
596648
fn test_log2() {
597649
let nan: f128 = f128::NAN;
598650
let inf: f128 = f128::INFINITY;
@@ -609,7 +661,9 @@ fn test_log2() {
609661
}
610662

611663
#[test]
612-
#[cfg(reliable_f128_math)]
664+
#[cfg(not(miri))]
665+
#[cfg(not(bootstrap))]
666+
#[cfg(target_has_reliable_f128_math)]
613667
fn test_log10() {
614668
let nan: f128 = f128::NAN;
615669
let inf: f128 = f128::INFINITY;
@@ -659,7 +713,9 @@ fn test_to_radians() {
659713
}
660714

661715
#[test]
662-
#[cfg(reliable_f128_math)]
716+
#[cfg(not(miri))]
717+
#[cfg(not(bootstrap))]
718+
#[cfg(target_has_reliable_f128_math)]
663719
fn test_asinh() {
664720
// Lower accuracy results are allowed, use increased tolerances
665721
assert_eq!(0.0f128.asinh(), 0.0f128);
@@ -690,7 +746,9 @@ fn test_asinh() {
690746
}
691747

692748
#[test]
693-
#[cfg(reliable_f128_math)]
749+
#[cfg(not(miri))]
750+
#[cfg(not(bootstrap))]
751+
#[cfg(target_has_reliable_f128_math)]
694752
fn test_acosh() {
695753
assert_eq!(1.0f128.acosh(), 0.0f128);
696754
assert!(0.999f128.acosh().is_nan());
@@ -709,7 +767,9 @@ fn test_acosh() {
709767
}
710768

711769
#[test]
712-
#[cfg(reliable_f128_math)]
770+
#[cfg(not(miri))]
771+
#[cfg(not(bootstrap))]
772+
#[cfg(target_has_reliable_f128_math)]
713773
fn test_atanh() {
714774
assert_eq!(0.0f128.atanh(), 0.0f128);
715775
assert_eq!((-0.0f128).atanh(), -0.0f128);
@@ -729,7 +789,9 @@ fn test_atanh() {
729789
}
730790

731791
#[test]
732-
#[cfg(reliable_f128_math)]
792+
#[cfg(not(miri))]
793+
#[cfg(not(bootstrap))]
794+
#[cfg(target_has_reliable_f128_math)]
733795
fn test_gamma() {
734796
// precision can differ among platforms
735797
assert_approx_eq!(1.0f128.gamma(), 1.0f128, TOL_IMPR);
@@ -750,7 +812,9 @@ fn test_gamma() {
750812
}
751813

752814
#[test]
753-
#[cfg(reliable_f128_math)]
815+
#[cfg(not(miri))]
816+
#[cfg(not(bootstrap))]
817+
#[cfg(target_has_reliable_f128_math)]
754818
fn test_ln_gamma() {
755819
assert_approx_eq!(1.0f128.ln_gamma().0, 0.0f128, TOL_IMPR);
756820
assert_eq!(1.0f128.ln_gamma().1, 1);
@@ -781,7 +845,9 @@ fn test_real_consts() {
781845
assert_approx_eq!(frac_1_pi, 1f128 / pi, TOL_PRECISE);
782846
assert_approx_eq!(frac_2_pi, 2f128 / pi, TOL_PRECISE);
783847

784-
#[cfg(reliable_f128_math)]
848+
#[cfg(not(miri))]
849+
#[cfg(not(bootstrap))]
850+
#[cfg(target_has_reliable_f128_math)]
785851
{
786852
let frac_2_sqrtpi: f128 = consts::FRAC_2_SQRT_PI;
787853
let sqrt2: f128 = consts::SQRT_2;

‎library/std/tests/floats/f16.rs

Lines changed: 92 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// FIXME(f16_f128): only tested on platforms that have symbols and aren't buggy
2-
#![cfg(reliable_f16)]
2+
#![cfg(not(bootstrap))]
3+
#![cfg(target_has_reliable_f16)]
34

45
use std::f16::consts;
56
use std::num::FpCategory as Fp;
@@ -57,29 +58,40 @@ fn test_num_f16() {
5758
crate::test_num(10f16, 2f16);
5859
}
5960

61+
// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
62+
// the intrinsics.
63+
6064
#[test]
61-
#[cfg(reliable_f16_math)]
65+
#[cfg(not(miri))]
66+
#[cfg(not(bootstrap))]
67+
#[cfg(target_has_reliable_f16_math)]
6268
fn test_min_nan() {
6369
assert_eq!(f16::NAN.min(2.0), 2.0);
6470
assert_eq!(2.0f16.min(f16::NAN), 2.0);
6571
}
6672

6773
#[test]
68-
#[cfg(reliable_f16_math)]
74+
#[cfg(not(miri))]
75+
#[cfg(not(bootstrap))]
76+
#[cfg(target_has_reliable_f16_math)]
6977
fn test_max_nan() {
7078
assert_eq!(f16::NAN.max(2.0), 2.0);
7179
assert_eq!(2.0f16.max(f16::NAN), 2.0);
7280
}
7381

7482
#[test]
75-
#[cfg(reliable_f16_math)]
83+
#[cfg(not(miri))]
84+
#[cfg(not(bootstrap))]
85+
#[cfg(target_has_reliable_f16_math)]
7686
fn test_minimum() {
7787
assert!(f16::NAN.minimum(2.0).is_nan());
7888
assert!(2.0f16.minimum(f16::NAN).is_nan());
7989
}
8090

8191
#[test]
82-
#[cfg(reliable_f16_math)]
92+
#[cfg(not(miri))]
93+
#[cfg(not(bootstrap))]
94+
#[cfg(target_has_reliable_f16_math)]
8395
fn test_maximum() {
8496
assert!(f16::NAN.maximum(2.0).is_nan());
8597
assert!(2.0f16.maximum(f16::NAN).is_nan());
@@ -236,7 +248,9 @@ fn test_classify() {
236248
}
237249

238250
#[test]
239-
#[cfg(reliable_f16_math)]
251+
#[cfg(not(miri))]
252+
#[cfg(not(bootstrap))]
253+
#[cfg(target_has_reliable_f16_math)]
240254
fn test_floor() {
241255
assert_approx_eq!(1.0f16.floor(), 1.0f16, TOL_0);
242256
assert_approx_eq!(1.3f16.floor(), 1.0f16, TOL_0);
@@ -251,7 +265,9 @@ fn test_floor() {
251265
}
252266

253267
#[test]
254-
#[cfg(reliable_f16_math)]
268+
#[cfg(not(miri))]
269+
#[cfg(not(bootstrap))]
270+
#[cfg(target_has_reliable_f16_math)]
255271
fn test_ceil() {
256272
assert_approx_eq!(1.0f16.ceil(), 1.0f16, TOL_0);
257273
assert_approx_eq!(1.3f16.ceil(), 2.0f16, TOL_0);
@@ -266,7 +282,9 @@ fn test_ceil() {
266282
}
267283

268284
#[test]
269-
#[cfg(reliable_f16_math)]
285+
#[cfg(not(miri))]
286+
#[cfg(not(bootstrap))]
287+
#[cfg(target_has_reliable_f16_math)]
270288
fn test_round() {
271289
assert_approx_eq!(2.5f16.round(), 3.0f16, TOL_0);
272290
assert_approx_eq!(1.0f16.round(), 1.0f16, TOL_0);
@@ -282,7 +300,9 @@ fn test_round() {
282300
}
283301

284302
#[test]
285-
#[cfg(reliable_f16_math)]
303+
#[cfg(not(miri))]
304+
#[cfg(not(bootstrap))]
305+
#[cfg(target_has_reliable_f16_math)]
286306
fn test_round_ties_even() {
287307
assert_approx_eq!(2.5f16.round_ties_even(), 2.0f16, TOL_0);
288308
assert_approx_eq!(1.0f16.round_ties_even(), 1.0f16, TOL_0);
@@ -298,7 +318,9 @@ fn test_round_ties_even() {
298318
}
299319

300320
#[test]
301-
#[cfg(reliable_f16_math)]
321+
#[cfg(not(miri))]
322+
#[cfg(not(bootstrap))]
323+
#[cfg(target_has_reliable_f16_math)]
302324
fn test_trunc() {
303325
assert_approx_eq!(1.0f16.trunc(), 1.0f16, TOL_0);
304326
assert_approx_eq!(1.3f16.trunc(), 1.0f16, TOL_0);
@@ -313,7 +335,9 @@ fn test_trunc() {
313335
}
314336

315337
#[test]
316-
#[cfg(reliable_f16_math)]
338+
#[cfg(not(miri))]
339+
#[cfg(not(bootstrap))]
340+
#[cfg(target_has_reliable_f16_math)]
317341
fn test_fract() {
318342
assert_approx_eq!(1.0f16.fract(), 0.0f16, TOL_0);
319343
assert_approx_eq!(1.3f16.fract(), 0.3f16, TOL_0);
@@ -328,7 +352,9 @@ fn test_fract() {
328352
}
329353

330354
#[test]
331-
#[cfg(reliable_f16_math)]
355+
#[cfg(not(miri))]
356+
#[cfg(not(bootstrap))]
357+
#[cfg(target_has_reliable_f16_math)]
332358
fn test_abs() {
333359
assert_eq!(f16::INFINITY.abs(), f16::INFINITY);
334360
assert_eq!(1f16.abs(), 1f16);
@@ -428,7 +454,9 @@ fn test_next_down() {
428454
}
429455

430456
#[test]
431-
#[cfg(reliable_f16_math)]
457+
#[cfg(not(miri))]
458+
#[cfg(not(bootstrap))]
459+
#[cfg(target_has_reliable_f16_math)]
432460
fn test_mul_add() {
433461
let nan: f16 = f16::NAN;
434462
let inf: f16 = f16::INFINITY;
@@ -445,7 +473,9 @@ fn test_mul_add() {
445473
}
446474

447475
#[test]
448-
#[cfg(reliable_f16_math)]
476+
#[cfg(not(miri))]
477+
#[cfg(not(bootstrap))]
478+
#[cfg(target_has_reliable_f16_math)]
449479
fn test_recip() {
450480
let nan: f16 = f16::NAN;
451481
let inf: f16 = f16::INFINITY;
@@ -461,7 +491,9 @@ fn test_recip() {
461491
}
462492

463493
#[test]
464-
#[cfg(reliable_f16_math)]
494+
#[cfg(not(miri))]
495+
#[cfg(not(bootstrap))]
496+
#[cfg(target_has_reliable_f16_math)]
465497
fn test_powi() {
466498
let nan: f16 = f16::NAN;
467499
let inf: f16 = f16::INFINITY;
@@ -476,7 +508,9 @@ fn test_powi() {
476508
}
477509

478510
#[test]
479-
#[cfg(reliable_f16_math)]
511+
#[cfg(not(miri))]
512+
#[cfg(not(bootstrap))]
513+
#[cfg(target_has_reliable_f16_math)]
480514
fn test_powf() {
481515
let nan: f16 = f16::NAN;
482516
let inf: f16 = f16::INFINITY;
@@ -493,7 +527,9 @@ fn test_powf() {
493527
}
494528

495529
#[test]
496-
#[cfg(reliable_f16_math)]
530+
#[cfg(not(miri))]
531+
#[cfg(not(bootstrap))]
532+
#[cfg(target_has_reliable_f16_math)]
497533
fn test_sqrt_domain() {
498534
assert!(f16::NAN.sqrt().is_nan());
499535
assert!(f16::NEG_INFINITY.sqrt().is_nan());
@@ -505,7 +541,9 @@ fn test_sqrt_domain() {
505541
}
506542

507543
#[test]
508-
#[cfg(reliable_f16_math)]
544+
#[cfg(not(miri))]
545+
#[cfg(not(bootstrap))]
546+
#[cfg(target_has_reliable_f16_math)]
509547
fn test_exp() {
510548
assert_eq!(1.0, 0.0f16.exp());
511549
assert_approx_eq!(2.718282, 1.0f16.exp(), TOL_0);
@@ -520,7 +558,9 @@ fn test_exp() {
520558
}
521559

522560
#[test]
523-
#[cfg(reliable_f16_math)]
561+
#[cfg(not(miri))]
562+
#[cfg(not(bootstrap))]
563+
#[cfg(target_has_reliable_f16_math)]
524564
fn test_exp2() {
525565
assert_eq!(32.0, 5.0f16.exp2());
526566
assert_eq!(1.0, 0.0f16.exp2());
@@ -534,7 +574,9 @@ fn test_exp2() {
534574
}
535575

536576
#[test]
537-
#[cfg(reliable_f16_math)]
577+
#[cfg(not(miri))]
578+
#[cfg(not(bootstrap))]
579+
#[cfg(target_has_reliable_f16_math)]
538580
fn test_ln() {
539581
let nan: f16 = f16::NAN;
540582
let inf: f16 = f16::INFINITY;
@@ -550,7 +592,9 @@ fn test_ln() {
550592
}
551593

552594
#[test]
553-
#[cfg(reliable_f16_math)]
595+
#[cfg(not(miri))]
596+
#[cfg(not(bootstrap))]
597+
#[cfg(target_has_reliable_f16_math)]
554598
fn test_log() {
555599
let nan: f16 = f16::NAN;
556600
let inf: f16 = f16::INFINITY;
@@ -569,7 +613,9 @@ fn test_log() {
569613
}
570614

571615
#[test]
572-
#[cfg(reliable_f16_math)]
616+
#[cfg(not(miri))]
617+
#[cfg(not(bootstrap))]
618+
#[cfg(target_has_reliable_f16_math)]
573619
fn test_log2() {
574620
let nan: f16 = f16::NAN;
575621
let inf: f16 = f16::INFINITY;
@@ -586,7 +632,9 @@ fn test_log2() {
586632
}
587633

588634
#[test]
589-
#[cfg(reliable_f16_math)]
635+
#[cfg(not(miri))]
636+
#[cfg(not(bootstrap))]
637+
#[cfg(target_has_reliable_f16_math)]
590638
fn test_log10() {
591639
let nan: f16 = f16::NAN;
592640
let inf: f16 = f16::INFINITY;
@@ -634,7 +682,9 @@ fn test_to_radians() {
634682
}
635683

636684
#[test]
637-
#[cfg(reliable_f16_math)]
685+
#[cfg(not(miri))]
686+
#[cfg(not(bootstrap))]
687+
#[cfg(target_has_reliable_f16_math)]
638688
fn test_asinh() {
639689
assert_eq!(0.0f16.asinh(), 0.0f16);
640690
assert_eq!((-0.0f16).asinh(), -0.0f16);
@@ -659,7 +709,9 @@ fn test_asinh() {
659709
}
660710

661711
#[test]
662-
#[cfg(reliable_f16_math)]
712+
#[cfg(not(miri))]
713+
#[cfg(not(bootstrap))]
714+
#[cfg(target_has_reliable_f16_math)]
663715
fn test_acosh() {
664716
assert_eq!(1.0f16.acosh(), 0.0f16);
665717
assert!(0.999f16.acosh().is_nan());
@@ -678,7 +730,9 @@ fn test_acosh() {
678730
}
679731

680732
#[test]
681-
#[cfg(reliable_f16_math)]
733+
#[cfg(not(miri))]
734+
#[cfg(not(bootstrap))]
735+
#[cfg(target_has_reliable_f16_math)]
682736
fn test_atanh() {
683737
assert_eq!(0.0f16.atanh(), 0.0f16);
684738
assert_eq!((-0.0f16).atanh(), -0.0f16);
@@ -698,7 +752,9 @@ fn test_atanh() {
698752
}
699753

700754
#[test]
701-
#[cfg(reliable_f16_math)]
755+
#[cfg(not(miri))]
756+
#[cfg(not(bootstrap))]
757+
#[cfg(target_has_reliable_f16_math)]
702758
fn test_gamma() {
703759
// precision can differ among platforms
704760
assert_approx_eq!(1.0f16.gamma(), 1.0f16, TOL_0);
@@ -719,7 +775,9 @@ fn test_gamma() {
719775
}
720776

721777
#[test]
722-
#[cfg(reliable_f16_math)]
778+
#[cfg(not(miri))]
779+
#[cfg(not(bootstrap))]
780+
#[cfg(target_has_reliable_f16_math)]
723781
fn test_ln_gamma() {
724782
assert_approx_eq!(1.0f16.ln_gamma().0, 0.0f16, TOL_0);
725783
assert_eq!(1.0f16.ln_gamma().1, 1);
@@ -752,7 +810,9 @@ fn test_real_consts() {
752810
assert_approx_eq!(frac_1_pi, 1f16 / pi, TOL_0);
753811
assert_approx_eq!(frac_2_pi, 2f16 / pi, TOL_0);
754812

755-
#[cfg(reliable_f16_math)]
813+
#[cfg(not(miri))]
814+
#[cfg(not(bootstrap))]
815+
#[cfg(target_has_reliable_f16_math)]
756816
{
757817
let frac_2_sqrtpi: f16 = consts::FRAC_2_SQRT_PI;
758818
let sqrt2: f16 = consts::SQRT_2;
@@ -813,7 +873,9 @@ fn test_clamp_max_is_nan() {
813873
}
814874

815875
#[test]
816-
#[cfg(reliable_f16_math)]
876+
#[cfg(not(miri))]
877+
#[cfg(not(bootstrap))]
878+
#[cfg(target_has_reliable_f16_math)]
817879
fn test_total_cmp() {
818880
use core::cmp::Ordering;
819881

‎library/std/tests/floats/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#![feature(f16, f128, float_algebraic, float_gamma, float_minimum_maximum)]
2+
#![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
3+
#![cfg_attr(not(bootstrap), expect(internal_features))] // for reliable_f16_f128
24

35
use std::fmt;
46
use std::ops::{Add, Div, Mul, Rem, Sub};

0 commit comments

Comments
 (0)
Please sign in to comment.