Skip to content

Commit aad8f84

Browse files
ojedaSasha Levin
authored andcommitted
rust: kbuild: treat build_error and rustdoc as kernel objects
commit 16c43a56b79e2c3220b043236369a129d508c65a upstream. Even if normally `build_error` isn't a kernel object, it should still be treated as such so that we pass the same flags. Similarly, `rustdoc` targets are never kernel objects, but we need to treat them as such. Otherwise, starting with Rust 1.91.0 (released 2025-10-30), `rustc` will complain about missing sanitizer flags since `-Zsanitizer` is a target modifier too [1]: error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `build_error` --> rust/build_error.rs:3:1 | 3 | //! Build-time error. | ^ | = help: the `-Zsanitizer` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely = note: unset `-Zsanitizer` in this crate is incompatible with `-Zsanitizer=kernel-address` in dependency `core` = help: set `-Zsanitizer=kernel-address` in this crate or unset `-Zsanitizer` in `core` = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=sanitizer` to silence this error Thus explicitly mark them as kernel objects. Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs). Link: rust-lang/rust#138736 [1] Reviewed-by: Alice Ryhl <aliceryhl@google.com> Tested-by: Justin M. Forbes <jforbes@fedoraproject.org> Link: https://patch.msgid.link/20251102212853.1505384-1-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e7a555c commit aad8f84

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

rust/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,14 @@ rustdoc-core: private rustc_target_flags = --edition=$(core-edition) $(core-cfgs
124124
rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs rustdoc-clean FORCE
125125
+$(call if_changed,rustdoc)
126126

127+
# Even if `rustdoc` targets are not kernel objects, they should still be
128+
# treated as such so that we pass the same flags. Otherwise, for instance,
129+
# `rustdoc` will complain about missing sanitizer flags causing an ABI mismatch.
130+
rustdoc-compiler_builtins: private is-kernel-object := y
127131
rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE
128132
+$(call if_changed,rustdoc)
129133

134+
rustdoc-ffi: private is-kernel-object := y
130135
rustdoc-ffi: $(src)/ffi.rs rustdoc-core FORCE
131136
+$(call if_changed,rustdoc)
132137

@@ -144,6 +149,7 @@ rustdoc-pin_init: $(src)/pin-init/src/lib.rs rustdoc-pin_init_internal \
144149
rustdoc-macros FORCE
145150
+$(call if_changed,rustdoc)
146151

152+
rustdoc-kernel: private is-kernel-object := y
147153
rustdoc-kernel: private rustc_target_flags = --extern ffi --extern pin_init \
148154
--extern build_error --extern macros \
149155
--extern bindings --extern uapi
@@ -526,6 +532,10 @@ $(obj)/pin_init.o: $(src)/pin-init/src/lib.rs $(obj)/compiler_builtins.o \
526532
$(obj)/$(libpin_init_internal_name) $(obj)/$(libmacros_name) FORCE
527533
+$(call if_changed_rule,rustc_library)
528534

535+
# Even if normally `build_error` is not a kernel object, it should still be
536+
# treated as such so that we pass the same flags. Otherwise, for instance,
537+
# `rustc` will complain about missing sanitizer flags causing an ABI mismatch.
538+
$(obj)/build_error.o: private is-kernel-object := y
529539
$(obj)/build_error.o: private skip_gendwarfksyms = 1
530540
$(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE
531541
+$(call if_changed_rule,rustc_library)

0 commit comments

Comments
 (0)