Skip to content

Commit 595ab66

Browse files
committed
Merge tag 'rust-fixes-6.14' of https://github.com/Rust-for-Linux/linux
Pull rust fixes from Miguel Ojeda: - Do not export KASAN ODR symbols to avoid gendwarfksyms warnings - Fix future Rust 1.86.0 (to be released 2025-04-03) x86_64 builds - Clean future Rust 1.86.0 (to be released 2025-04-03) warning - Fix future GCC 15 (to be released in a few months) builds - Fix `rusttest` target in macOS * tag 'rust-fixes-6.14' of https://github.com/Rust-for-Linux/linux: x86: rust: set rustc-abi=x86-softfloat on rustc>=1.86.0 rust: kbuild: do not export generated KASAN ODR symbols rust: kbuild: add -fzero-init-padding-bits to bindgen_skip_cflags rust: init: use explicit ABI to clean warning in future compilers rust: kbuild: use host dylib naming in rusttestlib-kernel
2 parents a0df483 + 6273a05 commit 595ab66

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

rust/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ rusttestlib-kernel: private rustc_target_flags = --extern ffi \
144144
--extern bindings --extern uapi
145145
rusttestlib-kernel: $(src)/kernel/lib.rs \
146146
rusttestlib-bindings rusttestlib-uapi rusttestlib-build_error \
147-
$(obj)/libmacros.so $(obj)/bindings.o FORCE
147+
$(obj)/$(libmacros_name) $(obj)/bindings.o FORCE
148148
+$(call if_changed,rustc_test_library)
149149

150150
rusttestlib-bindings: private rustc_target_flags = --extern ffi
@@ -240,6 +240,7 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \
240240
-fzero-call-used-regs=% -fno-stack-clash-protection \
241241
-fno-inline-functions-called-once -fsanitize=bounds-strict \
242242
-fstrict-flex-arrays=% -fmin-function-alignment=% \
243+
-fzero-init-padding-bits=% \
243244
--param=% --param asan-%
244245

245246
# Derived from `scripts/Makefile.clang`.
@@ -331,7 +332,7 @@ $(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_extra = ;
331332
$(obj)/bindings/bindings_helpers_generated.rs: $(src)/helpers/helpers.c FORCE
332333
$(call if_changed_dep,bindgen)
333334

334-
rust_exports = $(NM) -p --defined-only $(1) | awk '$$2~/(T|R|D|B)/ && $$3!~/__cfi/ { printf $(2),$$3 }'
335+
rust_exports = $(NM) -p --defined-only $(1) | awk '$$2~/(T|R|D|B)/ && $$3!~/__cfi/ && $$3!~/__odr_asan/ { printf $(2),$$3 }'
335336

336337
quiet_cmd_exports = EXPORTS $@
337338
cmd_exports = \

rust/kernel/init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ pub unsafe trait PinInit<T: ?Sized, E = Infallible>: Sized {
870870
/// use kernel::{types::Opaque, init::pin_init_from_closure};
871871
/// #[repr(C)]
872872
/// struct RawFoo([u8; 16]);
873-
/// extern {
873+
/// extern "C" {
874874
/// fn init_foo(_: *mut RawFoo);
875875
/// }
876876
///

scripts/generate_rust_target.rs

Lines changed: 18 additions & 0 deletions
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)