Skip to content

Commit 97b78fc

Browse files
ojedaSasha Levin
authored andcommitted
rust: kbuild: workaround rustdoc doctests modifier bug
[ Upstream commit fad472e ] The `rustdoc` modifiers bug [1] was fixed in Rust 1.90.0 [2], for which we added a workaround in commit abbf9a4 ("rust: workaround `rustdoc` target modifiers bug"). However, `rustdoc`'s doctest generation still has a similar issue [3], being fixed at [4], which does not affect us because we apply the workaround to both, and now, starting with Rust 1.91.0 (released 2025-10-30), `-Zsanitizer` is a target modifier too [5], which means we fail with: RUSTDOC TK rust/kernel/lib.rs error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `kernel` --> rust/kernel/lib.rs:3:1 | 3 | //! The `kernel` crate. | ^ | = 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 A simple way around is to add the sanitizer to the list in the existing workaround (especially if we had not started to pass the sanitizer flags in the previous commit, since in that case that would not be necessary). However, that still applies the workaround in more cases than necessary. Instead, only modify the doctests flags to ignore the check for sanitizers, so that it is more local (and thus the compiler keeps checking it for us in the normal `rustdoc` calls). Since the previous commit already treated the `rustdoc` calls as kernel objects, this should allow us in the future to easily remove this workaround when the time comes. By the way, the `-Cunsafe-allow-abi-mismatch` flag overwrites previous ones rather than appending, so it needs to be all done in the same flag. Moreover, unknown modifiers are rejected, and thus we have to gate based on the version too. Finally, `-Zsanitizer-cfi-normalize-integers` is not affected (in Rust 1.91.0), so it is not needed in the workaround for the moment. Cc: [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs). Link: rust-lang/rust#144521 [1] Link: rust-lang/rust#144523 [2] Link: rust-lang/rust#146465 [3] Link: rust-lang/rust#148068 [4] Link: rust-lang/rust#138736 [5] 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]> [ added --remap-path-prefix comments missing in stable branch ] Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6b1cf76 commit 97b78fc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

rust/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ core-edition := $(if $(call rustc-min-version,108700),2024,2021)
5959
# the time being (https://github.com/rust-lang/rust/issues/144521).
6060
rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18)
6161

62+
# Similarly, for doctests (https://github.com/rust-lang/rust/issues/146465).
63+
doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,109100),$(comma)sanitizer)
6264
quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
6365
cmd_rustdoc = \
6466
OBJTREE=$(abspath $(objtree)) \
@@ -189,7 +191,7 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
189191
--extern bindings --extern uapi \
190192
--no-run --crate-name kernel -Zunstable-options \
191193
--sysroot=/dev/null \
192-
$(rustdoc_modifiers_workaround) \
194+
$(doctests_modifiers_workaround) \
193195
--test-builder $(objtree)/scripts/rustdoc_test_builder \
194196
$< $(rustdoc_test_kernel_quiet); \
195197
$(objtree)/scripts/rustdoc_test_gen

0 commit comments

Comments
 (0)