[PATCH v2] rust: Makefile: bound rustdoc workaround to affected versions

From: HeeSu Kim

Date: Mon Feb 02 2026 - 10:31:26 EST


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@xxxxxxxxxxx>
Fixes: abbf9a449441 ("rust: workaround `rustdoc` target modifiers bug")
Signed-off-by: HeeSu Kim <mlksvender@xxxxxxxxx>
---
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