Skip to content

Commit 9bc67dc

Browse files
ojedagregkh
authored andcommitted
kbuild: rust: add rustc-min-version support function
commit ac95414 upstream. Introduce `rustc-min-version` support function that mimics `{gcc,clang}-min-version` ones, following commit 88b61e3 ("Makefile.compiler: replace cc-ifversion with compiler-specific macros"). In addition, use it in the first use case we have in the kernel (which was done independently to minimize the changes needed for the fix). Signed-off-by: Miguel Ojeda <[email protected]> Reviewed-by: Fiona Behrens <[email protected]> Reviewed-by: Nicolas Schier <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7eb3800 commit 9bc67dc

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

Documentation/kbuild/makefiles.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,20 @@ cc-cross-prefix
656656
endif
657657
endif
658658

659+
$(RUSTC) support functions
660+
--------------------------
661+
662+
rustc-min-version
663+
rustc-min-version tests if the value of $(CONFIG_RUSTC_VERSION) is greater
664+
than or equal to the provided value and evaluates to y if so.
665+
666+
Example::
667+
668+
rustflags-$(call rustc-min-version, 108500) := -Cfoo
669+
670+
In this example, rustflags-y will be assigned the value -Cfoo if
671+
$(CONFIG_RUSTC_VERSION) is >= 1.85.0.
672+
659673
$(LD) support functions
660674
-----------------------
661675

arch/arm64/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \
4848
KBUILD_CFLAGS += $(call cc-disable-warning, psabi)
4949
KBUILD_AFLAGS += $(compat_vdso)
5050

51-
ifeq ($(call test-ge, $(CONFIG_RUSTC_VERSION), 108500),y)
51+
ifeq ($(call rustc-min-version, 108500),y)
5252
KBUILD_RUSTFLAGS += --target=aarch64-unknown-none-softfloat
5353
else
5454
KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon"

scripts/Makefile.compiler

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ gcc-min-version = $(call test-ge, $(CONFIG_GCC_VERSION), $1)
6767
# Usage: cflags-$(call clang-min-version, 110000) += -foo
6868
clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1)
6969

70+
# rustc-min-version
71+
# Usage: rustc-$(call rustc-min-version, 108500) += -Cfoo
72+
rustc-min-version = $(call test-ge, $(CONFIG_RUSTC_VERSION), $1)
73+
7074
# ld-option
7175
# Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
7276
ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))

0 commit comments

Comments
 (0)