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

From: HeeSu Kim

Date: Wed Feb 04 2026 - 23:19:00 EST


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)
+
# 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