Skip to content

Commit 3386719

Browse files
authored
Merge pull request #76 from RalfJung/rustup
rustup: lockfile fix, and a patch for f16/f128 float math
2 parents 389b54e + 29279bf commit 3386719

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

run-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ rm -f library
3333
ln -s "$MIRI_LIB_SRC" library
3434

3535
# use the rust-src lockfile
36-
cp "$MIRI_LIB_SRC/../Cargo.lock" Cargo.lock
36+
cp "$MIRI_LIB_SRC/Cargo.lock" Cargo.lock
3737

3838
# This ensures that the "core" crate being built as part of `cargo miri test`
3939
# is just a re-export of the sysroot crate, so we don't get duplicate lang items.

rust-src.diff

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
diff --git a/library/std/build.rs b/library/std/build.rs
2+
index 18ca7b512a9..35a5977b6eb 100644
3+
--- a/library/std/build.rs
4+
+++ b/library/std/build.rs
5+
@@ -11,6 +11,7 @@ fn main() {
6+
.expect("CARGO_CFG_TARGET_POINTER_WIDTH was not set")
7+
.parse()
8+
.unwrap();
9+
+ let is_miri = env::var_os("CARGO_CFG_MIRI").is_some();
10+
11+
println!("cargo:rustc-check-cfg=cfg(netbsd10)");
12+
if target_os == "netbsd" && env::var("RUSTC_STD_NETBSD10").is_ok() {
13+
@@ -91,6 +92,8 @@ fn main() {
14+
println!("cargo:rustc-check-cfg=cfg(reliable_f128_math)");
15+
16+
let has_reliable_f16 = match (target_arch.as_str(), target_os.as_str()) {
17+
+ // We can always enable these in Miri as that is not affected by codegen bugs.
18+
+ _ if is_miri => true,
19+
// Selection failure until recent LLVM <https://github.com/llvm/llvm-project/issues/93894>
20+
// FIXME(llvm19): can probably be removed at the version bump
21+
("loongarch64", _) => false,
22+
@@ -118,6 +121,8 @@ fn main() {
23+
};
24+
25+
let has_reliable_f128 = match (target_arch.as_str(), target_os.as_str()) {
26+
+ // We can always enable these in Miri as that is not affected by codegen bugs.
27+
+ _ if is_miri => true,
28+
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
29+
("arm64ec", _) => false,
30+
// ABI and precision bugs <https://github.com/rust-lang/rust/issues/125109>
31+
@@ -141,6 +146,8 @@ fn main() {
32+
// LLVM is currenlty adding missing routines, <https://github.com/llvm/llvm-project/issues/93566>
33+
let has_reliable_f16_math = has_reliable_f16
34+
&& match (target_arch.as_str(), target_os.as_str()) {
35+
+ // FIXME: Disabled on Miri as the intrinsics are not implemented yet.
36+
+ _ if is_miri => false,
37+
// Currently nothing special. Hooray!
38+
// This will change as platforms gain better better support for standard ops but math
39+
// lags behind.
40+
@@ -149,6 +156,8 @@ fn main() {
41+
42+
let has_reliable_f128_math = has_reliable_f128
43+
&& match (target_arch.as_str(), target_os.as_str()) {
44+
+ // FIXME: Disabled on Miri as the intrinsics are not implemented yet.
45+
+ _ if is_miri => false,
46+
// LLVM lowers `fp128` math to `long double` symbols even on platforms where
47+
// `long double` is not IEEE binary128. See
48+
// <https://github.com/llvm/llvm-project/issues/44744>.
49+
diff --git a/library/std/src/f16/tests.rs b/library/std/src/f16/tests.rs
50+
index 50504e7ffd9..684ee3f3855 100644
51+
--- a/library/std/src/f16/tests.rs
52+
+++ b/library/std/src/f16/tests.rs
53+
@@ -4,20 +4,20 @@
54+
use crate::f16::consts;
55+
use crate::num::{FpCategory as Fp, *};
56+
57+
-/// Tolerance for results on the order of 10.0e-2;
58+
-#[cfg(reliable_f16_math)]
59+
+/// Tolerance for results on the order of 10.0e-2
60+
+#[allow(unused)]
61+
const TOL_N2: f16 = 0.0001;
62+
63+
/// Tolerance for results on the order of 10.0e+0
64+
-#[cfg(reliable_f16_math)]
65+
+#[allow(unused)]
66+
const TOL_0: f16 = 0.01;
67+
68+
/// Tolerance for results on the order of 10.0e+2
69+
-#[cfg(reliable_f16_math)]
70+
+#[allow(unused)]
71+
const TOL_P2: f16 = 0.5;
72+
73+
/// Tolerance for results on the order of 10.0e+4
74+
-#[cfg(reliable_f16_math)]
75+
+#[allow(unused)]
76+
const TOL_P4: f16 = 10.0;
77+
78+
/// Smallest number

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2024-08-05
1+
nightly-2024-08-08

0 commit comments

Comments
 (0)