[PATCH] rust: Makefile: apply fixed-x18 workaround only on arm64

HeeSu Kim posted 1 patch 4 days, 15 hours ago
rust/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] rust: Makefile: apply fixed-x18 workaround only on arm64
Posted by HeeSu Kim 4 days, 15 hours ago
The `-Cunsafe-allow-abi-mismatch=fixed-x18` option is a workaround for
a rustdoc issue (rust-lang/rust#144521) where target modifiers were not
properly saved. This affects both rustdoc and doctests builds.

However, `fixed-x18` is an ARM64-specific ABI modifier related to the
x18 register reservation (used for Shadow Call Stack). Currently, this
workaround is applied unconditionally on all architectures, which is
incorrect and may cause issues on non-ARM64 builds.

Restrict the workaround to only apply when building for arm64
(SRCARCH=arm64).

Fixes: 68e8e79e1bdc ("rust: fix `rustdoc` target modifiers")
Signed-off-by: HeeSu Kim <mlksvender@gmail.com>
---
 rust/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rust/Makefile b/rust/Makefile
index 5c0155b83..2bd547611 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -136,7 +136,8 @@ pin_init-flags := \
 
 # `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)
+# The `fixed-x18` modifier is ARM64-specific, so only apply it there.
+rustdoc_modifiers_workaround := $(if $(filter arm64,$(SRCARCH)),$(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18))
 
 # Similarly, for doctests (https://github.com/rust-lang/rust/issues/146465).
 doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,109100),$(comma)sanitizer)
-- 
2.52.0
Re: [PATCH] rust: Makefile: apply fixed-x18 workaround only on arm64
Posted by Gary Guo 4 days, 23 hours ago
On Mon Feb 2, 2026 at 10:21 PM GMT, HeeSu Kim wrote:
> The `-Cunsafe-allow-abi-mismatch=fixed-x18` option is a workaround for
> a rustdoc issue (rust-lang/rust#144521) where target modifiers were not
> properly saved. This affects both rustdoc and doctests builds.
>
> However, `fixed-x18` is an ARM64-specific ABI modifier related to the
> x18 register reservation (used for Shadow Call Stack). Currently, this
> workaround is applied unconditionally on all architectures, which is
> incorrect and may cause issues on non-ARM64 builds.
>
> Restrict the workaround to only apply when building for arm64
> (SRCARCH=arm64).
>
> Fixes: 68e8e79e1bdc ("rust: fix `rustdoc` target modifiers")
> Signed-off-by: HeeSu Kim <mlksvender@gmail.com>
> ---
>  rust/Makefile | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/rust/Makefile b/rust/Makefile
> index 5c0155b83..2bd547611 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -136,7 +136,8 @@ pin_init-flags := \
>  
>  # `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)
> +# The `fixed-x18` modifier is ARM64-specific, so only apply it there.
> +rustdoc_modifiers_workaround := $(if $(filter arm64,$(SRCARCH)),$(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18))

It looks like this bug has been fixed upstream already. While you're at it,
would you mind also add code so that we stop applying the workaround for
versions with bug fixed already?

Thanks,
Gary

>  
>  # Similarly, for doctests (https://github.com/rust-lang/rust/issues/146465).
>  doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,109100),$(comma)sanitizer)
Re: [PATCH] rust: Makefile: apply fixed-x18 workaround only on arm64
Posted by HeeSu Kim 4 days, 14 hours ago
On Tue, Feb 03, 2026, Gary Guo wrote:
> It looks like this bug has been fixed upstream already. While you're at
> it, would you mind also add code so that we stop applying the workaround
> for versions with bug fixed already?

Sure, I'll check which Rust version includes the fix and send a patch
with the requested changes.

Best regards,
HeeSu Kim
Re: [PATCH] rust: Makefile: apply fixed-x18 workaround only on arm64
Posted by Miguel Ojeda 4 days, 23 hours ago
On Mon, Feb 2, 2026 at 2:21 PM HeeSu Kim <mlksvender@gmail.com> wrote:
>
> However, `fixed-x18` is an ARM64-specific ABI modifier related to the
> x18 register reservation (used for Shadow Call Stack). Currently, this
> workaround is applied unconditionally on all architectures, which is
> incorrect and may cause issues on non-ARM64 builds.

Could you please elaborate on the issues you are seeing, e.g. how to
reproduce them?

The flag is only used to silence errors from checks that were added to
`rustc` and it is ignored otherwise (that is why the workaround was
written like that).

Thank you!

Cheers,
Miguel
Re: [PATCH] rust: Makefile: apply fixed-x18 workaround only on arm64
Posted by Charalampos Mitrodimas 4 days, 23 hours ago
HeeSu Kim <mlksvender@gmail.com> writes:

> The `-Cunsafe-allow-abi-mismatch=fixed-x18` option is a workaround for
> a rustdoc issue (rust-lang/rust#144521) where target modifiers were not
> properly saved. This affects both rustdoc and doctests builds.
>
> However, `fixed-x18` is an ARM64-specific ABI modifier related to the
> x18 register reservation (used for Shadow Call Stack). Currently, this
> workaround is applied unconditionally on all architectures, which is
> incorrect and may cause issues on non-ARM64 builds.
>
> Restrict the workaround to only apply when building for arm64
> (SRCARCH=arm64).
>
> Fixes: 68e8e79e1bdc ("rust: fix `rustdoc` target modifiers")

Are we sure this is in the correct commit hash? It is not present on
mainline.

Maybe it should be this one?

      Fixes: abbf9a449441 ("rust: workaround `rustdoc` target modifiers bug")

Cheers,
C. Mitrodimas

> Signed-off-by: HeeSu Kim <mlksvender@gmail.com>
> ---
>  rust/Makefile | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/rust/Makefile b/rust/Makefile
> index 5c0155b83..2bd547611 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -136,7 +136,8 @@ pin_init-flags := \
>  
>  # `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)
> +# The `fixed-x18` modifier is ARM64-specific, so only apply it there.
> +rustdoc_modifiers_workaround := $(if $(filter arm64,$(SRCARCH)),$(if
> $(call
> rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18))
>  
>  # Similarly, for doctests (https://github.com/rust-lang/rust/issues/146465).
>  doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if
> $(call rustc-min-version,109100),$(comma)sanitizer)
Re: [PATCH] rust: Makefile: apply fixed-x18 workaround only on arm64
Posted by HeeSu Kim 4 days, 14 hours ago
On Tue, Feb 03, 2026, C. Mitrodimas wrote:
> > The `-Cunsafe-allow-abi-mismatch=fixed-x18` option is a workaround for
> > a rustdoc issue (rust-lang/rust#144521) where target modifiers were not
> > properly saved. This affects both rustdoc and doctests builds.
> >
> > However, `fixed-x18` is an ARM64-specific ABI modifier related to the
> > x18 register reservation (used for Shadow Call Stack). Currently, this
> > workaround is applied unconditionally on all architectures, which is
> > incorrect and may cause issues on non-ARM64 builds.
> >
> > Restrict the workaround to only apply when building for arm64
> > (SRCARCH=arm64).
> >
> > Fixes: 68e8e79e1bdc ("rust: fix `rustdoc` target modifiers")
>
> Are we sure this is in the correct commit hash? It is not present on
> mainline.
>
> Maybe it should be this one?
>
>       Fixes: abbf9a449441 ("rust: workaround `rustdoc` target modifiers bug")
>
> Cheers,
> C. Mitrodimas

You're right. I mistakenly used a commit hash from my local branch.
I'll send a v2 with the correct Fixes tag.
[PATCH v2] rust: Makefile: bound rustdoc workaround to affected versions
Posted by HeeSu Kim 4 days, 13 hours ago
The `-Cunsafe-allow-abi-mismatch=fixed-x18` workaround was added to
handle a rustdoc bug (rust-lang/rust#144521) where target modifiers
were not properly saved.

This bug was fixed in Rust 1.90.0 (rust-lang/rust#144523). Restrict
the workaround to only apply for Rust 1.88.x and 1.89.x versions that
are affected by the bug, avoiding unnecessary flags on newer compiler
versions.

Suggested-by: Gary Guo <gary@garyguo.net>
Fixes: abbf9a449441 ("rust: workaround `rustdoc` target modifiers bug")
Signed-off-by: HeeSu Kim <mlksvender@gmail.com>
---
 rust/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rust/Makefile b/rust/Makefile
index 5c0155b83454..55e2dc865207 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -136,7 +136,8 @@ pin_init-flags := \
 
 # `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)
+# The bug was fixed in Rust 1.90.0, so only apply for 1.88.x and 1.89.x.
+rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),$(if $(call test-lt,$(CONFIG_RUSTC_VERSION),109000),-Cunsafe-allow-abi-mismatch=fixed-x18))
 
 # Similarly, for doctests (https://github.com/rust-lang/rust/issues/146465).
 doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,109100),$(comma)sanitizer)
-- 
2.52.0
Re: [PATCH v2] rust: Makefile: bound rustdoc workaround to affected versions
Posted by Miguel Ojeda 4 days, 21 hours ago
On Mon, Feb 2, 2026 at 4:21 PM HeeSu Kim <mlksvender@gmail.com> wrote:
>
> This bug was fixed in Rust 1.90.0 (rust-lang/rust#144523). Restrict

Normally these references should be full links (i.e. a tag), since we
do not have "autolinking" like GitHub e.g.

  Link: https://........ [1]

Then you can use [1] above instead of the parenthesis.

> are affected by the bug, avoiding unnecessary flags on newer compiler

To clarify a bit: avoiding the flags is good, but I think avoiding the
skipping of the checks that the flag does is what is more important
(i.e. if it were just the former advantage, I would say it is not
worth the complexity of the added tests).

> Suggested-by: Gary Guo <gary@garyguo.net>

This is very minor and it is fine without a change, but for
completeness: for Suggested-by we generally add a Link: after that
tag, i.e. to lore.kernel.org to the message where Gary suggested it in
this case.

> Fixes: abbf9a449441 ("rust: workaround `rustdoc` target modifiers bug")

I think this is not really a fix anymore, i.e. nothing is broken, and
instead it is more of a feature, as far as I understand: avoiding to
skip the silencing of the checks.

If you added the tag to suggest that the patch should be backported to
stable kernels, then in these cases an explicit Cc: stable@ may be
added, mentioning the versions where this should go, e.g. in this
case:

  Cc: stable@vger.kernel.org # Useful in 6.18.y and later.

(I used "Useful" instead of my usual "Needed" since it is not critical
to backport -- but please correct me if I am wrong).

By the way, I wonder if we would want at least a `rustc-max-version`
function or instead a range-based one for this sort of test. It is not
a blocker for this patch, but we may want to limit other workarounds
too (e.g. the one below this one).

Cc'ing Kbuild since I don't recall we have that for C compilers, so
there may be a reason for that.

Thanks for the patch!

Cheers,
Miguel
Re: [PATCH v2] rust: Makefile: bound rustdoc workaround to affected versions
Posted by Gary Guo 3 days, 23 hours ago
On Mon Feb 2, 2026 at 4:00 PM GMT, Miguel Ojeda wrote:
> On Mon, Feb 2, 2026 at 4:21 PM HeeSu Kim <mlksvender@gmail.com> wrote:
>>
>> This bug was fixed in Rust 1.90.0 (rust-lang/rust#144523). Restrict
>
> Normally these references should be full links (i.e. a tag), since we
> do not have "autolinking" like GitHub e.g.
>
>   Link: https://........ [1]
>
> Then you can use [1] above instead of the parenthesis.
>
>> are affected by the bug, avoiding unnecessary flags on newer compiler
>
> To clarify a bit: avoiding the flags is good, but I think avoiding the
> skipping of the checks that the flag does is what is more important
> (i.e. if it were just the former advantage, I would say it is not
> worth the complexity of the added tests).

I think skipping workarounds when possible is in general good, as it serves a
good reference that it can be removed whenever the toolchain minimum version is
bumped above that (and with the help with LKP, it means that it's also been
actually widely tested that the workaround is indeed not necessary).

Best,
Gary
Re: [PATCH v2] rust: Makefile: bound rustdoc workaround to affected versions
Posted by Nathan Chancellor 4 days, 13 hours ago
On Mon, Feb 02, 2026 at 05:00:59PM +0100, Miguel Ojeda wrote:
> By the way, I wonder if we would want at least a `rustc-max-version`
> function or instead a range-based one for this sort of test. It is not
> a blocker for this patch, but we may want to limit other workarounds
> too (e.g. the one below this one).
> 
> Cc'ing Kbuild since I don't recall we have that for C compilers, so
> there may be a reason for that.

I don't think there is any particular reason for this. It is probably
more that for C, we generally prefer feature or bug checks in Kconfig to
catch problems or enable features for both compilers when they are
detected or we do the version checks with the actual operators from
Kconfig rather than doing something in Kbuild.

Both a "max" version and a range-based macro make sense to me since the
range-based one could just use the min max macros under the hood.

In lieu of a separate macro, couldn't this still use 'rustc-min-version'
for both parts if it was willing to unwrap the nested ifs (which I find
kind of unreadable in their current form):

  # The bug was fixed in Rust 1.90.0, so only apply for 1.88.x and 1.89.x.
  ifeq ($(call rustc-min-version,108800)_$(call rustc-min-version,109000),y_)
  rustdoc_modifiers_workaround := -Cunsafe-allow-abi-mismatch=fixed-x18
  endif

Cheers,
Nathan
[PATCH v4] rust: Makefile: bound rustdoc workaround to affected versions
Posted by HeeSu Kim 3 days, 14 hours ago
The `-Cunsafe-allow-abi-mismatch=fixed-x18` workaround was added to
handle a rustdoc bug where target modifiers were not properly saved [1].

This bug was fixed in Rust 1.90.0 [2]. Restrict the workaround to only
apply for Rust 1.88.x and 1.89.x versions that are affected by the
bug, preserving ABI compatibility checks on newer compiler versions.

Add `rustc-max-version` macro to `scripts/Makefile.compiler` for
version upper bound checks, mirroring the existing `rustc-min-version`.

Link: https://github.com/rust-lang/rust/issues/144521 [1]
Link: https://github.com/rust-lang/rust/pull/144523 [2]
Suggested-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/rust-for-linux/DG4JM9PU51M0.1YRGM9HVTY24U@garyguo.net/
Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://lore.kernel.org/rust-for-linux/CANiq72n39eU9WE=Yh0_yJzmqMxo=QAaU2pN0UqP9jZ7bT7rhgA@mail.gmail.com/
Cc: stable@vger.kernel.org # Useful in 6.18.y and later.
Signed-off-by: HeeSu Kim <mlksvender@gmail.com>
---
Changes in v4:
- Add rustc-max-version macro for cleaner version bounds
- Use rustc-max-version instead of test-lt for readability

Changes in v3:
- Remove Fixes: tag (this is a feature, not a fix)
- Use full URLs with Link: tags instead of GitHub-style references
- Add Link: to lore.kernel.org for Suggested-by attribution
- Add Cc: stable for potential backporting to 6.18.y

Changes in v2:
- Change approach: bound to affected Rust versions instead of ARM64-only
  (the flag is simply ignored on non-ARM64 architectures)

 rust/Makefile             | 3 ++-
 scripts/Makefile.compiler | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/rust/Makefile b/rust/Makefile
index 5c0155b83454..1e8a75bc2878 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -136,7 +136,8 @@ pin_init-flags := \
 
 # `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)
+# The bug was fixed in Rust 1.90.0, so only apply for 1.88.x and 1.89.x.
+rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),$(if $(call rustc-max-version,108999),-Cunsafe-allow-abi-mismatch=fixed-x18))
 
 # Similarly, for doctests (https://github.com/rust-lang/rust/issues/146465).
 doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,109100),$(comma)sanitizer)
diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler
index ef91910de265..85268f6f1494 100644
--- a/scripts/Makefile.compiler
+++ b/scripts/Makefile.compiler
@@ -71,6 +71,10 @@ clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1)
 # Usage: rustc-$(call rustc-min-version, 108500) += -Cfoo
 rustc-min-version = $(call test-ge, $(CONFIG_RUSTC_VERSION), $1)
 
+# rustc-max-version
+# Usage: rustc-$(call rustc-max-version, 109000) += -Cfoo
+rustc-max-version = $(call test-le, $(CONFIG_RUSTC_VERSION), $1)
+
 # ld-option
 # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
 ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
-- 
2.52.0
Re: [PATCH v4] rust: Makefile: bound rustdoc workaround to affected versions
Posted by Nathan Chancellor 3 days, 15 hours ago
On Wed, Feb 04, 2026 at 08:48:43AM +0900, HeeSu Kim wrote:
> The `-Cunsafe-allow-abi-mismatch=fixed-x18` workaround was added to
> handle a rustdoc bug where target modifiers were not properly saved [1].
> 
> This bug was fixed in Rust 1.90.0 [2]. Restrict the workaround to only
> apply for Rust 1.88.x and 1.89.x versions that are affected by the
> bug, preserving ABI compatibility checks on newer compiler versions.
> 
> Add `rustc-max-version` macro to `scripts/Makefile.compiler` for
> version upper bound checks, mirroring the existing `rustc-min-version`.
> 
> Link: https://github.com/rust-lang/rust/issues/144521 [1]
> Link: https://github.com/rust-lang/rust/pull/144523 [2]
> Suggested-by: Gary Guo <gary@garyguo.net>
> Link: https://lore.kernel.org/rust-for-linux/DG4JM9PU51M0.1YRGM9HVTY24U@garyguo.net/
> Suggested-by: Miguel Ojeda <ojeda@kernel.org>
> Link: https://lore.kernel.org/rust-for-linux/CANiq72n39eU9WE=Yh0_yJzmqMxo=QAaU2pN0UqP9jZ7bT7rhgA@mail.gmail.com/
> Cc: stable@vger.kernel.org # Useful in 6.18.y and later.
> Signed-off-by: HeeSu Kim <mlksvender@gmail.com>

Acked-by: Nathan Chancellor <nathan@kernel.org>

I assume Miguel will pick this up.

> ---
> Changes in v4:
> - Add rustc-max-version macro for cleaner version bounds
> - Use rustc-max-version instead of test-lt for readability
> 
> Changes in v3:
> - Remove Fixes: tag (this is a feature, not a fix)
> - Use full URLs with Link: tags instead of GitHub-style references
> - Add Link: to lore.kernel.org for Suggested-by attribution
> - Add Cc: stable for potential backporting to 6.18.y
> 
> Changes in v2:
> - Change approach: bound to affected Rust versions instead of ARM64-only
>   (the flag is simply ignored on non-ARM64 architectures)
> 
>  rust/Makefile             | 3 ++-
>  scripts/Makefile.compiler | 4 ++++
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/rust/Makefile b/rust/Makefile
> index 5c0155b83454..1e8a75bc2878 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -136,7 +136,8 @@ pin_init-flags := \
>  
>  # `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)
> +# The bug was fixed in Rust 1.90.0, so only apply for 1.88.x and 1.89.x.
> +rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),$(if $(call rustc-max-version,108999),-Cunsafe-allow-abi-mismatch=fixed-x18))
>  
>  # Similarly, for doctests (https://github.com/rust-lang/rust/issues/146465).
>  doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,109100),$(comma)sanitizer)
> diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler
> index ef91910de265..85268f6f1494 100644
> --- a/scripts/Makefile.compiler
> +++ b/scripts/Makefile.compiler
> @@ -71,6 +71,10 @@ clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1)
>  # Usage: rustc-$(call rustc-min-version, 108500) += -Cfoo
>  rustc-min-version = $(call test-ge, $(CONFIG_RUSTC_VERSION), $1)
>  
> +# rustc-max-version
> +# Usage: rustc-$(call rustc-max-version, 109000) += -Cfoo
> +rustc-max-version = $(call test-le, $(CONFIG_RUSTC_VERSION), $1)

Minor meta comment: It is generally perferred to add a macro like this
in a separate change to make it easier to backport if it is needed in
the future.

>  # ld-option
>  # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
>  ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
> -- 
> 2.52.0
>
[PATCH v5 1/2] kbuild: add rustc-max-version macro
Posted by HeeSu Kim 2 days ago
Add `rustc-max-version` macro to `scripts/Makefile.compiler` for
version upper bound checks, mirroring the existing `rustc-min-version`.

This will be used to bound workarounds to specific compiler version
ranges.

Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://lore.kernel.org/rust-for-linux/CANiq72n39eU9WE=Yh0_yJzmqMxo=QAaU2pN0UqP9jZ7bT7rhgA@mail.gmail.com/
Acked-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: HeeSu Kim <mlksvender@gmail.com>
---
Changes in v5:
- Split rustc-max-version macro into separate patch for easier backporting
  (was part of the workaround patch in v4)

 scripts/Makefile.compiler | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler
index ef91910de265..85268f6f1494 100644
--- a/scripts/Makefile.compiler
+++ b/scripts/Makefile.compiler
@@ -71,6 +71,10 @@ clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1)
 # Usage: rustc-$(call rustc-min-version, 108500) += -Cfoo
 rustc-min-version = $(call test-ge, $(CONFIG_RUSTC_VERSION), $1)
 
+# rustc-max-version
+# Usage: rustc-$(call rustc-max-version, 109000) += -Cfoo
+rustc-max-version = $(call test-le, $(CONFIG_RUSTC_VERSION), $1)
+
 # ld-option
 # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
 ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
-- 
2.52.0
Re: [PATCH v5 1/2] kbuild: add rustc-max-version macro
Posted by Nicolas Schier 1 day, 22 hours ago
On Thu, Feb 05, 2026 at 10:18:14PM +0900, HeeSu Kim wrote:
> Add `rustc-max-version` macro to `scripts/Makefile.compiler` for
> version upper bound checks, mirroring the existing `rustc-min-version`.
> 
> This will be used to bound workarounds to specific compiler version
> ranges.
> 
> Suggested-by: Miguel Ojeda <ojeda@kernel.org>
> Link: https://lore.kernel.org/rust-for-linux/CANiq72n39eU9WE=Yh0_yJzmqMxo=QAaU2pN0UqP9jZ7bT7rhgA@mail.gmail.com/
> Acked-by: Nathan Chancellor <nathan@kernel.org>
> Signed-off-by: HeeSu Kim <mlksvender@gmail.com>
> ---
> Changes in v5:
> - Split rustc-max-version macro into separate patch for easier backporting
>   (was part of the workaround patch in v4)
> 
>  scripts/Makefile.compiler | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler
> index ef91910de265..85268f6f1494 100644
> --- a/scripts/Makefile.compiler
> +++ b/scripts/Makefile.compiler
> @@ -71,6 +71,10 @@ clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1)
>  # Usage: rustc-$(call rustc-min-version, 108500) += -Cfoo
>  rustc-min-version = $(call test-ge, $(CONFIG_RUSTC_VERSION), $1)
>  
> +# rustc-max-version
> +# Usage: rustc-$(call rustc-max-version, 109000) += -Cfoo
> +rustc-max-version = $(call test-le, $(CONFIG_RUSTC_VERSION), $1)
> +

Acked-by: Nicolas Schier <nsc@kernel.org>



(nit-picking; not crucial for this very patch set)

For readability, a less-than version check might be easier to read; and
that would probably better match the suggested version range check:

    rustc-lt-version = $(if $(call rustc-min-version, $(1)),,y)
    rustc-version-range = $(and $(call rustc-lt-version,$(2)), $(call rustc-min-version,$(1)))

so that the actual version check could become

    # The bug was fixed in Rust 1.90.0, so only apply for 1.88.x to < 1.90.0
    rustdoc_modifiers_workaround := $(if $(call rustc-version-range, 108800, 109000), \
    		-Cunsafe-allow-abi-mismatch=fixed-x18)

or:

    ifeq ($(call rustc-version-range, 108800, 109000),y)
    rustdoc_modifiers_workaround := -Cunsafe-allow-abi-mismatch=fixed-x18
    endif


-- 
Nicolas
[PATCH v5 2/2] rust: Makefile: bound rustdoc workaround to affected versions
Posted by HeeSu Kim 2 days ago
The `-Cunsafe-allow-abi-mismatch=fixed-x18` workaround was added to
handle a rustdoc bug where target modifiers were not properly saved [1].

This bug was fixed in Rust 1.90.0 [2]. Restrict the workaround to only
apply for Rust 1.88.x and 1.89.x versions that are affected by the
bug, preserving ABI compatibility checks on newer compiler versions.

Link: https://github.com/rust-lang/rust/issues/144521 [1]
Link: https://github.com/rust-lang/rust/pull/144523 [2]
Suggested-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/rust-for-linux/DG4JM9PU51M0.1YRGM9HVTY24U@garyguo.net/
Cc: stable@vger.kernel.org # Useful in 6.18.y and later.
Acked-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: HeeSu Kim <mlksvender@gmail.com>
---
Changes in v5:
- Split rustc-max-version macro into separate patch for easier backporting

Changes in v4:
- Add rustc-max-version macro for cleaner version bounds
- Use rustc-max-version instead of test-lt for readability

Changes in v3:
- Remove Fixes: tag (this is a feature, not a fix)
- Use full URLs with Link: tags instead of GitHub-style references
- Add Link: to lore.kernel.org for Suggested-by attribution
- Add Cc: stable for potential backporting to 6.18.y

Changes in v2:
- Change approach: bound to affected Rust versions instead of ARM64-only
  (the flag is simply ignored on non-ARM64 architectures)

 rust/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rust/Makefile b/rust/Makefile
index 5c0155b83454..1e8a75bc2878 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -136,7 +136,8 @@ pin_init-flags := \
 
 # `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)
+# The bug was fixed in Rust 1.90.0, so only apply for 1.88.x and 1.89.x.
+rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),$(if $(call rustc-max-version,108999),-Cunsafe-allow-abi-mismatch=fixed-x18))
 
 # Similarly, for doctests (https://github.com/rust-lang/rust/issues/146465).
 doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,109100),$(comma)sanitizer)
-- 
2.52.0
Re: [PATCH v2] rust: Makefile: bound rustdoc workaround to affected versions
Posted by HeeSu Kim 4 days, 12 hours ago
On Mon, 3 Feb 2026, Miguel Ojeda wrote:
> On Mon, Feb 3, 2025 at 1:09 AM HeeSu Kim <mlksvender@gmail.com> wrote:
> >
> > The `-Cunsafe-allow-abi-mismatch=fixed-x18` workaround was added to
> > handle a rustdoc bug (rust-lang/rust#144521) where target modifiers
> > were not properly saved.
> >
> > This bug was fixed in Rust 1.90.0 (rust-lang/rust#144523). Restrict
>
> We tend to use `Link:` tags for these. Typically we write a line like:
>
>     Link: https://github.com/rust-lang/rust/issues/144521
>
> If you want to reference it inline, you can also just put the full URL.
>
> > Suggested-by: Gary Guo <gary@garyguo.net>
>
> Please add a `Link:` tag after this one pointing to his message.
>
> > Fixes: abbf9a449441 ("rust: workaround `rustdoc` target modifiers bug")
>
> I am not so sure this is a fix -- after all, when you use `1.88` or
> `1.89`, nothing would change. So it is more of a feature? i.e. the
> ability to use `1.90`.
>
> But I guess it could also be understood as "we should have applied
> this only for affected versions to begin with", but then it would be
> from a "code documentation" perspective, which is fine, but it is not
> something that e.g. we would need to backport. So I am leaning towards
> not having a `Fixes:` here.
>
> And this has another issue (though a different patch): the `sanitizer`
> modifier.
>
> By the way, I wonder if we would want at least a `rustc-max-version`
> (or an `-until` variant, or whatever) so that we can easily express
> that range in a single call, and document the bounds together (I could
> imagine that we could end up with a few of these over time, and then
> they start to shift versions, they get spread across lines, etc.).
>
> Perhaps the Kbuild maintainers can comment on whether that would be a
> good idea or whether they already have something.
>
> Cheers,
> Miguel

Thanks for the detailed feedback.

For v3, I will:
- Use full Link: tags for GitHub references instead of shorthand
- Add Link: tag after Suggested-by pointing to Gary's lore message
- Remove the Fixes: tag
- Add Cc: stable@vger.kernel.org # Useful in 6.18.y and later.

Regarding rustc-max-version, it would be useful for reading the code.
I'll wait for Kbuild maintainers' reply.

Best regards,
HeeSu Kim
[PATCH v3] rust: Makefile: bound rustdoc workaround to affected versions
Posted by HeeSu Kim 4 days, 4 hours ago
The `-Cunsafe-allow-abi-mismatch=fixed-x18` workaround was added to
handle a rustdoc bug where target modifiers were not properly saved [1].

This bug was fixed in Rust 1.90.0 [2]. Restrict the workaround to only
apply for Rust 1.88.x and 1.89.x versions that are affected by the
bug, preserving ABI compatibility checks on newer compiler versions.

Link: https://github.com/rust-lang/rust/issues/144521 [1]
Link: https://github.com/rust-lang/rust/pull/144523 [2]
Suggested-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/rust-for-linux/DG4JM9PU51M0.1YRGM9HVTY24U@garyguo.net/
Cc: stable@vger.kernel.org # Useful in 6.18.y and later.
Signed-off-by: HeeSu Kim <mlksvender@gmail.com>
---
Changes in v3:
- Remove Fixes: tag (this is a feature, not a fix)
- Use full URLs with Link: tags instead of GitHub-style references
- Add Link: to lore.kernel.org for Suggested-by attribution
- Add Cc: stable for potential backporting to 6.18.y

Changes in v2:
- Change approach: bound to affected Rust versions instead of ARM64-only
  (the flag is simply ignored on non-ARM64 architectures)

 rust/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rust/Makefile b/rust/Makefile
index 5c0155b83454..55e2dc865207 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -136,7 +136,8 @@ pin_init-flags := \

 # `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)
+# The bug was fixed in Rust 1.90.0, so only apply for 1.88.x and 1.89.x.
+rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),$(if $(call test-lt,$(CONFIG_RUSTC_VERSION),109000),-Cunsafe-allow-abi-mismatch=fixed-x18))

 # Similarly, for doctests (https://github.com/rust-lang/rust/issues/146465).
 doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,109100),$(comma)sanitizer)
--
2.52.0