linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: workaround `rustdoc` target modifiers bug
@ 2025-07-27  9:23 Miguel Ojeda
  2025-07-27  9:31 ` Miguel Ojeda
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Miguel Ojeda @ 2025-07-27  9:23 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Masahiro Yamada
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	rust-for-linux, Nathan Chancellor, Nicolas Schier, linux-kbuild,
	linux-kernel, patches, Konrad Dybcio

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.

Meanwhile, conditionally pass `-Cunsafe-allow-abi-mismatch=fixed-x18`
to workaround the issue on our side.

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: https://github.com/rust-lang/rust/issues/144521 [1]
Link: https://github.com/rust-lang/rust/pull/144523 [2]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
 rust/Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/rust/Makefile b/rust/Makefile
index 115b63b7d1e3..f5883152fd5d 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -62,6 +62,10 @@ core-cfgs = \
 
 core-edition := $(if $(call rustc-min-version,108700),2024,2021)
 
+# `rustdoc` did not save the target modifiers, thus workaround for
+# the time being (https://github.com/rust-lang/rust/issues/144521).
+rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18)
+
 # `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only
 # since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust
 # 1.82.0 (https://github.com/rust-lang/rust/issues/138520). Thus workaround both
@@ -74,6 +78,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
 		-Zunstable-options --generate-link-to-definition \
 		--output $(rustdoc_output) \
 		--crate-name $(subst rustdoc-,,$@) \
+		$(rustdoc_modifiers_workaround) \
 		$(if $(rustdoc_host),,--sysroot=/dev/null) \
 		@$(objtree)/include/generated/rustc_cfg $<
 
@@ -212,6 +217,7 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
 		--extern bindings --extern uapi \
 		--no-run --crate-name kernel -Zunstable-options \
 		--sysroot=/dev/null \
+		$(rustdoc_modifiers_workaround) \
 		--test-builder $(objtree)/scripts/rustdoc_test_builder \
 		$< $(rustdoc_test_kernel_quiet); \
 	$(objtree)/scripts/rustdoc_test_gen

base-commit: 89be9a83ccf1f88522317ce02f854f30d6115c41
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] rust: workaround `rustdoc` target modifiers bug
  2025-07-27  9:23 [PATCH] rust: workaround `rustdoc` target modifiers bug Miguel Ojeda
@ 2025-07-27  9:31 ` Miguel Ojeda
  2025-07-27 10:16   ` Alice Ryhl
  2025-07-28  6:06 ` Miguel Ojeda
  2025-08-12 19:53 ` Miguel Ojeda
  2 siblings, 1 reply; 5+ messages in thread
From: Miguel Ojeda @ 2025-07-27  9:31 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Alex Gaynor, Masahiro Yamada, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, rust-for-linux, Nathan Chancellor,
	Nicolas Schier, linux-kbuild, linux-kernel, patches,
	Konrad Dybcio

On Sun, Jul 27, 2025 at 11:23 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> 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: https://github.com/rust-lang/rust/issues/144521 [1]
> Link: https://github.com/rust-lang/rust/pull/144523 [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

And most likely:

Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is
pinned in older LTSs).

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rust: workaround `rustdoc` target modifiers bug
  2025-07-27  9:31 ` Miguel Ojeda
@ 2025-07-27 10:16   ` Alice Ryhl
  0 siblings, 0 replies; 5+ messages in thread
From: Alice Ryhl @ 2025-07-27 10:16 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Miguel Ojeda, Alex Gaynor, Masahiro Yamada, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Danilo Krummrich, rust-for-linux, Nathan Chancellor,
	Nicolas Schier, linux-kbuild, linux-kernel, patches,
	Konrad Dybcio

On Sun, Jul 27, 2025 at 11:31 AM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Sun, Jul 27, 2025 at 11:23 AM Miguel Ojeda <ojeda@kernel.org> wrote:
> >
> > 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: https://github.com/rust-lang/rust/issues/144521 [1]
> > Link: https://github.com/rust-lang/rust/pull/144523 [2]
> > Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

> And most likely:
>
> Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is
> pinned in older LTSs).

We also do not even set -Zfixed-x18 prior to v6.12, so there are other
reasons to not backport it further.

Alice

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rust: workaround `rustdoc` target modifiers bug
  2025-07-27  9:23 [PATCH] rust: workaround `rustdoc` target modifiers bug Miguel Ojeda
  2025-07-27  9:31 ` Miguel Ojeda
@ 2025-07-28  6:06 ` Miguel Ojeda
  2025-08-12 19:53 ` Miguel Ojeda
  2 siblings, 0 replies; 5+ messages in thread
From: Miguel Ojeda @ 2025-07-28  6:06 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Alex Gaynor, Masahiro Yamada, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, rust-for-linux, Nathan Chancellor,
	Nicolas Schier, linux-kbuild, linux-kernel, patches,
	Konrad Dybcio, Guillaume Gomez

On Sun, Jul 27, 2025 at 11:23 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> 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).

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rust: workaround `rustdoc` target modifiers bug
  2025-07-27  9:23 [PATCH] rust: workaround `rustdoc` target modifiers bug Miguel Ojeda
  2025-07-27  9:31 ` Miguel Ojeda
  2025-07-28  6:06 ` Miguel Ojeda
@ 2025-08-12 19:53 ` Miguel Ojeda
  2 siblings, 0 replies; 5+ messages in thread
From: Miguel Ojeda @ 2025-08-12 19:53 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Alex Gaynor, Masahiro Yamada, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, rust-for-linux, Nathan Chancellor,
	Nicolas Schier, linux-kbuild, linux-kernel, patches,
	Konrad Dybcio, Guillaume Gomez

On Sun, Jul 27, 2025 at 11:23 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> 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.
>
> Meanwhile, conditionally pass `-Cunsafe-allow-abi-mismatch=fixed-x18`
> to workaround the issue on our side.
>
> 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: https://github.com/rust-lang/rust/issues/144521 [1]
> Link: https://github.com/rust-lang/rust/pull/144523 [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Applied to `rust-fixes` -- thanks everyone!

  [ 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 ]

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-08-12 19:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-27  9:23 [PATCH] rust: workaround `rustdoc` target modifiers bug Miguel Ojeda
2025-07-27  9:31 ` Miguel Ojeda
2025-07-27 10:16   ` Alice Ryhl
2025-07-28  6:06 ` Miguel Ojeda
2025-08-12 19:53 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).