Skip to content

Commit c018fe9

Browse files
ojedajannau
authored andcommitted
rust: kbuild: treat build_error and rustdoc as kernel objects
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: [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs). Link: rust-lang/rust#138736 [1] Reviewed-by: Alice Ryhl <[email protected]> Tested-by: Justin M. Forbes <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 8ce7726 commit c018fe9

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
@@ -121,9 +121,14 @@ rustdoc-core: private rustc_target_flags = --edition=$(core-edition) $(core-cfgs
121121
rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs rustdoc-clean FORCE
122122
+$(call if_changed,rustdoc)
123123

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

131+
rustdoc-ffi: private is-kernel-object := y
127132
rustdoc-ffi: $(src)/ffi.rs rustdoc-core FORCE
128133
+$(call if_changed,rustdoc)
129134

@@ -141,6 +146,7 @@ rustdoc-pin_init: $(src)/pin-init/src/lib.rs rustdoc-pin_init_internal \
141146
rustdoc-macros FORCE
142147
+$(call if_changed,rustdoc)
143148

149+
rustdoc-kernel: private is-kernel-object := y
144150
rustdoc-kernel: private rustc_target_flags = --extern ffi --extern pin_init \
145151
--extern build_error --extern macros \
146152
--extern bindings --extern uapi
@@ -523,6 +529,10 @@ $(obj)/pin_init.o: $(src)/pin-init/src/lib.rs $(obj)/compiler_builtins.o \
523529
$(obj)/$(libpin_init_internal_name) $(obj)/$(libmacros_name) FORCE
524530
+$(call if_changed_rule,rustc_library)
525531

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

0 commit comments

Comments
 (0)