Re: [PATCH v5 2/2] rust: Makefile: bound rustdoc workaround to affected versions
From: Miguel Ojeda
Date: Thu Mar 12 2026 - 10:14:04 EST
On Thu, Feb 5, 2026 at 5:18 AM HeeSu Kim <mlksvender@xxxxxxxxx> wrote:
>
> # 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)
So I was merrily going to apply this, but sadly, this is not so
simple: the patch doesn't work because the doctests (the variable
quoted above, no the one that the patch modifies) need to take into
account the other one, which appends the sanitizer case using a comma.
For instance, for Rust 1.94.0, this would expand to just `,sanitizer`.
And it is not as simple as adding the flag there -- please see what I
wrote in commit fad472efab0a ("rust: kbuild: workaround `rustdoc`
doctests modifier bug"):
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.
I would suggest we take the chance to introduce the range version
check, and also to gate the doctests check up to 1.92, since it should
be fixed in that version.
And perhaps it is simpler if we split (expand) the cases explicitly
version by version for each variable using conditionals with the
version check. That is way more verbose, but it is way easier to see
what is going on in each case and to later on remove the cases when we
upgrade etc.:
ifeq ($(call rustc-version-range,108800,109000),y)
rustdoc_modifiers_workaround := -Cunsafe-allow-abi-mismatch=fixed-x18
doctests_modifiers_workaround := -Cunsafe-allow-abi-mismatch=fixed-x18
else ifeq ($(call rustc-version-range,109000,109100),y)
doctests_modifiers_workaround := -Cunsafe-allow-abi-mismatch=fixed-x18
else ifeq ($(call rustc-version-range,109100,109200),y)
doctests_modifiers_workaround :=
-Cunsafe-allow-abi-mismatch=fixed-x18,sanitizer
endif
Cheers,
Miguel