Re: [PATCH v5 1/2] kbuild: add rustc-max-version macro

From: Nicolas Schier

Date: Thu Feb 05 2026 - 10:59:15 EST


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@xxxxxxxxxx>
> Link: https://lore.kernel.org/rust-for-linux/CANiq72n39eU9WE=Yh0_yJzmqMxo=QAaU2pN0UqP9jZ7bT7rhgA@xxxxxxxxxxxxxx/
> Acked-by: Nathan Chancellor <nathan@xxxxxxxxxx>
> Signed-off-by: HeeSu Kim <mlksvender@xxxxxxxxx>
> ---
> 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@xxxxxxxxxx>



(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