Skip to content

Commit 8ef2288

Browse files
ojedajfvogel
authored andcommitted
rust: workaround rustdoc target modifiers bug
commit abbf9a44944171ca99c150adad9361a2f517d3b6 upstream. Starting with Rust 1.88.0 (released 2025-06-26), `rustdoc` complains about a target modifier mismatch in configurations where `-Zfixed-x18` is passed: error: mixing `-Zfixed-x18` will cause an ABI mismatch in crate `rust_out` | = help: the `-Zfixed-x18` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely = note: unset `-Zfixed-x18` in this crate is incompatible with `-Zfixed-x18=` in dependency `core` = help: set `-Zfixed-x18=` in this crate or unset `-Zfixed-x18` in `core` = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=fixed-x18` to silence this error The reason is that `rustdoc` was not passing the target modifiers when configuring the session options, and thus it would report a mismatch that did not exist as soon as a target modifier is used in a dependency. We did not notice it in the kernel until now because `-Zfixed-x18` has been a target modifier only since 1.88.0 (and it is the only one we use so far). The issue has been reported upstream [1] and a fix has been submitted [2], including a test similar to the kernel case. [ This is now fixed upstream (thanks Guillaume for the quick review), so it will be fixed in Rust 1.90.0 (expected 2025-09-18). - Miguel ] Meanwhile, conditionally pass `-Cunsafe-allow-abi-mismatch=fixed-x18` to workaround the issue on our side. Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs). Reported-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Closes: https://lore.kernel.org/rust-for-linux/36cdc798-524f-4910-8b77-d7b9fac08d77@oss.qualcomm.com/ Link: rust-lang/rust#144521 [1] Link: rust-lang/rust#144523 [2] Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20250727092317.2930617-1-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit f6367a4d03b92c40af4079dbbac28848f48e0538) Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
1 parent 8d28306 commit 8ef2288

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

rust/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ core-cfgs = \
5555

5656
core-edition := $(if $(call rustc-min-version,108700),2024,2021)
5757

58+
# `rustdoc` did not save the target modifiers, thus workaround for
59+
# the time being (https://github.com/rust-lang/rust/issues/144521).
60+
rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18)
61+
5862
quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
5963
cmd_rustdoc = \
6064
OBJTREE=$(abspath $(objtree)) \
@@ -63,6 +67,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
6367
-Zunstable-options --generate-link-to-definition \
6468
--output $(rustdoc_output) \
6569
--crate-name $(subst rustdoc-,,$@) \
70+
$(rustdoc_modifiers_workaround) \
6671
$(if $(rustdoc_host),,--sysroot=/dev/null) \
6772
@$(objtree)/include/generated/rustc_cfg $<
6873

@@ -178,6 +183,7 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
178183
--extern bindings --extern uapi \
179184
--no-run --crate-name kernel -Zunstable-options \
180185
--sysroot=/dev/null \
186+
$(rustdoc_modifiers_workaround) \
181187
--test-builder $(objtree)/scripts/rustdoc_test_builder \
182188
$< $(rustdoc_test_kernel_quiet); \
183189
$(objtree)/scripts/rustdoc_test_gen

0 commit comments

Comments
 (0)