Skip to content

Commit e0d6a41

Browse files
committed
rust185: fix cross-build of mipsel-unknown-netbsd target.
Following on from rust-lang/rust#137630 apply patch gracefully supplied in beetrees/rust@21f8bda .patch by @beetrees. Fixes cross-build for the mipsel-unknown-netbsd target on NetBSD which does not (yet?) support the f16 data type, at least not with the LLVM embedded in 1.85.0 (which is LLVM version 19.1.7).
1 parent 442b0fd commit e0d6a41

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

rust185/distinfo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ SHA1 (patch-src_llvm-project_llvm_include_llvm_Analysis_ConstantFolding.h) = 39d
133133
SHA1 (patch-src_llvm-project_llvm_utils_FileCheck_FileCheck.cpp) = 2587c2f4d11ad8f75bf8a16de625135b26bacc15
134134
SHA1 (patch-src_tools_cargo_src_cargo_core_profiles.rs) = e1af7fde97416e0a269ee34efd37f4f47fcf7a95
135135
SHA1 (patch-src_tools_cargo_tests_testsuite_build.rs) = 333ec513b9b94750b2424a7c1b21c809e6ea25b8
136+
SHA1 (patch-src_tools_clippy_clippy__utils_src_consts.rs) = bfebd1fa83be18626751d1059eaf32c275f43d28
137+
SHA1 (patch-src_tools_clippy_clippy__utils_src_lib.rs) = 68df85b3758a03860ec38b8d0b2cca30d4b02286
136138
SHA1 (patch-src_tools_rust-installer_install-template.sh) = 6984546c34a2e4d55a6dbe59baa0d4958184e0b7
137139
SHA1 (patch-tests_assembly_targets_targets-elf.rs) = ee7d036c055ed2a2b3b303f381ad4694327c739b
138140
SHA1 (patch-tools_rust-analyzer_lib_line-index-src_lib.rs) = 4ed527174447ee23fa81dd6840e18b9949d5a273
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
$NetBSD$
2+
3+
Following on from https://github.com/rust-lang/rust/issues/137630
4+
apply patch gracefully supplied in
5+
https://github.com/beetrees/rust/commit/21f8bda79b2904c827b9d8d769a1307acfd855a1.patch
6+
7+
Fixes cross-build for 32-bit mips on NetBSD which
8+
does not (yet?) support the f16 data type.
9+
10+
--- src/tools/clippy/clippy_utils/src/consts.rs.orig 2025-02-17 18:17:27.000000000 +0000
11+
+++ src/tools/clippy/clippy_utils/src/consts.rs
12+
@@ -41,14 +41,16 @@ pub enum Constant<'tcx> {
13+
Char(char),
14+
/// An integer's bit representation.
15+
Int(u128),
16+
- /// An `f16`.
17+
- F16(f16),
18+
+ /// An `f16` bitcast to a `u16`.
19+
+ // FIXME(f16_f128): use `f16` once builtins are available on all host tools platforms.
20+
+ F16(u16),
21+
/// An `f32`.
22+
F32(f32),
23+
/// An `f64`.
24+
F64(f64),
25+
- /// An `f128`.
26+
- F128(f128),
27+
+ /// An `f128` bitcast to a `u128`.
28+
+ // FIXME(f16_f128): use `f128` once builtins are available on all host tools platforms.
29+
+ F128(u128),
30+
/// `true` or `false`.
31+
Bool(bool),
32+
/// An array of constants.
33+
@@ -175,7 +177,7 @@ impl Hash for Constant<'_> {
34+
},
35+
Self::F16(f) => {
36+
// FIXME(f16_f128): once conversions to/from `f128` are available on all platforms,
37+
- f.to_bits().hash(state);
38+
+ f.hash(state);
39+
},
40+
Self::F32(f) => {
41+
f64::from(f).to_bits().hash(state);
42+
@@ -184,7 +186,7 @@ impl Hash for Constant<'_> {
43+
f.to_bits().hash(state);
44+
},
45+
Self::F128(f) => {
46+
- f.to_bits().hash(state);
47+
+ f.hash(state);
48+
},
49+
Self::Bool(b) => {
50+
b.hash(state);
51+
@@ -290,12 +292,12 @@ impl Constant<'_> {
52+
53+
fn parse_f16(s: &str) -> Self {
54+
let f: Half = s.parse().unwrap();
55+
- Self::F16(f16::from_bits(f.to_bits().try_into().unwrap()))
56+
+ Self::F16(f.to_bits().try_into().unwrap())
57+
}
58+
59+
fn parse_f128(s: &str) -> Self {
60+
let f: Quad = s.parse().unwrap();
61+
- Self::F128(f128::from_bits(f.to_bits()))
62+
+ Self::F128(f.to_bits())
63+
}
64+
}
65+
66+
@@ -851,10 +853,10 @@ pub fn mir_to_const<'tcx>(tcx: TyCtxt<'t
67+
ty::Adt(adt_def, _) if adt_def.is_struct() => Some(Constant::Adt(result)),
68+
ty::Bool => Some(Constant::Bool(int == ScalarInt::TRUE)),
69+
ty::Uint(_) | ty::Int(_) => Some(Constant::Int(int.to_bits(int.size()))),
70+
- ty::Float(FloatTy::F16) => Some(Constant::F16(f16::from_bits(int.into()))),
71+
+ ty::Float(FloatTy::F16) => Some(Constant::F16(int.into())),
72+
ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits(int.into()))),
73+
ty::Float(FloatTy::F64) => Some(Constant::F64(f64::from_bits(int.into()))),
74+
- ty::Float(FloatTy::F128) => Some(Constant::F128(f128::from_bits(int.into()))),
75+
+ ty::Float(FloatTy::F128) => Some(Constant::F128(int.into())),
76+
ty::RawPtr(_, _) => Some(Constant::RawPtr(int.to_bits(int.size()))),
77+
_ => None,
78+
},
79+
@@ -875,10 +877,10 @@ pub fn mir_to_const<'tcx>(tcx: TyCtxt<'t
80+
let range = alloc_range(offset + size * idx, size);
81+
let val = alloc.read_scalar(&tcx, range, /* read_provenance */ false).ok()?;
82+
res.push(match flt {
83+
- FloatTy::F16 => Constant::F16(f16::from_bits(val.to_u16().discard_err()?)),
84+
+ FloatTy::F16 => Constant::F16(val.to_u16().discard_err()?),
85+
FloatTy::F32 => Constant::F32(f32::from_bits(val.to_u32().discard_err()?)),
86+
FloatTy::F64 => Constant::F64(f64::from_bits(val.to_u64().discard_err()?)),
87+
- FloatTy::F128 => Constant::F128(f128::from_bits(val.to_u128().discard_err()?)),
88+
+ FloatTy::F128 => Constant::F128(val.to_u128().discard_err()?),
89+
});
90+
}
91+
Some(Constant::Vec(res))
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
$NetBSD$
2+
3+
Following on from https://github.com/rust-lang/rust/issues/137630
4+
apply patch gracefully supplied in
5+
https://github.com/beetrees/rust/commit/21f8bda79b2904c827b9d8d769a1307acfd855a1
6+
.patch
7+
8+
Fixes cross-build for 32-bit mips on NetBSD which
9+
does not (yet?) support the f16 data type.
10+
11+
--- src/tools/clippy/clippy_utils/src/lib.rs.orig 2025-02-17 18:17:27.000000000 +0000
12+
+++ src/tools/clippy/clippy_utils/src/lib.rs
13+
@@ -1,7 +1,5 @@
14+
#![feature(array_chunks)]
15+
#![feature(box_patterns)]
16+
-#![feature(f128)]
17+
-#![feature(f16)]
18+
#![feature(if_let_guard)]
19+
#![feature(macro_metavar_expr_concat)]
20+
#![feature(let_chains)]

0 commit comments

Comments
 (0)