Skip to content

Commit d0c82a3

Browse files
Darksonngregkh
authored andcommitted
x86: rust: set rustc-abi=x86-softfloat on rustc>=1.86.0
commit 6273a05 upstream. When using Rust on the x86 architecture, we are currently using the unstable target.json feature to specify the compilation target. Rustc is going to change how softfloat is specified in the target.json file on x86, thus update generate_rust_target.rs to specify softfloat using the new option. Note that if you enable this parameter with a compiler that does not recognize it, then that triggers a warning but it does not break the build. [ For future reference, this solves the following error: RUSTC L rust/core.o error: Error loading target specification: target feature `soft-float` is incompatible with the ABI but gets enabled in target spec. Run `rustc --print target-list` for a list of built-in targets - Miguel ] Cc: <[email protected]> # Needed in 6.12.y and 6.13.y only (Rust is pinned in older LTSs). Link: rust-lang/rust#136146 Signed-off-by: Alice Ryhl <[email protected]> Acked-by: Dave Hansen <[email protected]> # for x86 Link: https://lore.kernel.org/r/[email protected] [ Added 6.13.y too to Cc: stable tag and added reasoning to avoid over-backporting. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5ba1e19 commit d0c82a3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

scripts/generate_rust_target.rs

+18
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,18 @@ impl KernelConfig {
165165
let option = "CONFIG_".to_owned() + option;
166166
self.0.contains_key(&option)
167167
}
168+
169+
/// Is the rustc version at least `major.minor.patch`?
170+
fn rustc_version_atleast(&self, major: u32, minor: u32, patch: u32) -> bool {
171+
let check_version = 100000 * major + 100 * minor + patch;
172+
let actual_version = self
173+
.0
174+
.get("CONFIG_RUSTC_VERSION")
175+
.unwrap()
176+
.parse::<u32>()
177+
.unwrap();
178+
check_version <= actual_version
179+
}
168180
}
169181

170182
fn main() {
@@ -182,6 +194,9 @@ fn main() {
182194
}
183195
} else if cfg.has("X86_64") {
184196
ts.push("arch", "x86_64");
197+
if cfg.rustc_version_atleast(1, 86, 0) {
198+
ts.push("rustc-abi", "x86-softfloat");
199+
}
185200
ts.push(
186201
"data-layout",
187202
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
@@ -215,6 +230,9 @@ fn main() {
215230
panic!("32-bit x86 only works under UML");
216231
}
217232
ts.push("arch", "x86");
233+
if cfg.rustc_version_atleast(1, 86, 0) {
234+
ts.push("rustc-abi", "x86-softfloat");
235+
}
218236
ts.push(
219237
"data-layout",
220238
"e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128",

0 commit comments

Comments
 (0)