kbuild: rust: add rustc-min-version support function
Subsystems (4)
Miguel Ojeda
maintainerPATCH 1/1 kbuild: rust: add rustc-min-version support function
Introduce rustc-min-version support function that mimics {gcc,clang}-min-version ones, following commit 88b61e3bff93 ("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).
---
This is based on top of the fix so that the fix remains as simple as possible:
https://lore.kernel.org/rust-for-linux/[email protected]/
Documentation/kbuild/makefiles.rst | 14 ++++++++++++++ arch/arm64/Makefile | 2 +- scripts/Makefile.compiler | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-)
Documentation/kbuild/makefiles.rst +14 -0
@@ -670,6 +670,20 @@ cc-cross-prefix endif endif +$(RUSTC) support functions +-------------------------- + +rustc-min-version + rustc-min-version tests if the value of $(CONFIG_RUSTC_VERSION) is greater + than or equal to the provided value and evaluates to y if so. + + Example:: + + rustflags-$(call rustc-min-version, 108500) := -Cfoo + + In this example, rustflags-y will be assigned the value -Cfoo if + $(CONFIG_RUSTC_VERSION) is >= 1.85.0. + $(LD) support functions -----------------------
arch/arm64/Makefile +1 -1
@@ -48,7 +48,7 @@ KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \ KBUILD_CFLAGS += $(call cc-disable-warning, psabi) KBUILD_AFLAGS += $(compat_vdso) -ifeq ($(call test-ge, $(CONFIG_RUSTC_VERSION), 108500),y) +ifeq ($(call rustc-min-version, 108500),y) KBUILD_RUSTFLAGS += --target=aarch64-unknown-none-softfloat else KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon"
scripts/Makefile.compiler +4 -0
@@ -67,6 +67,10 @@ gcc-min-version = $(call test-ge, $(CONFIG_GCC_VERSION), $1) # Usage: cflags-$(call clang-min-version, 110000) += -foo clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1) +# rustc-min-version +# Usage: rustc-$(call rustc-min-version, 108500) += -Cfoo +rustc-min-version = $(call test-ge, $(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.48.1
Quoted 8 lines · Miguel Ojeda
Introduce
rustc-min-versionsupport function that mimics{gcc,clang}-min-versionones, following commit88b61e3bff93("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]>
Quoted 73 lines · Miguel Ojeda
Introduce
rustc-min-versionsupport function that mimics{gcc,clang}-min-versionones, following commit88b61e3bff93("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]>---
This is based on top of the fix so that the fix remains as simple as possible:https://lore.kernel.org/rust-for-linux/[email protected]/Documentation/kbuild/makefiles.rst | 14 ++++++++++++++ arch/arm64/Makefile | 2 +- scripts/Makefile.compiler | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-)Documentation/kbuild/makefiles.rst +14
-0@@ -670,6 +670,20 @@ cc-cross-prefix endif endif +$(RUSTC) support functions +-------------------------- + +rustc-min-version + rustc-min-version tests if the value of $(CONFIG_RUSTC_VERSION) is greater + than or equal to the provided value and evaluates to y if so. + + Example:: + + rustflags-$(call rustc-min-version, 108500) := -Cfoo + + In this example, rustflags-y will be assigned the value -Cfoo if + $(CONFIG_RUSTC_VERSION) is >= 1.85.0. + $(LD) support functions -----------------------arch/arm64/Makefile +1
-1@@ -48,7 +48,7 @@ KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \ KBUILD_CFLAGS += $(call cc-disable-warning, psabi) KBUILD_AFLAGS += $(compat_vdso) -ifeq ($(call test-ge, $(CONFIG_RUSTC_VERSION), 108500),y) +ifeq ($(call rustc-min-version, 108500),y) KBUILD_RUSTFLAGS += --target=aarch64-unknown-none-softfloat else KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon"scripts/Makefile.compiler +4
-1@@ -67,6 +67,10 @@ gcc-min-version = $(call test-ge, $(CONFIG_GCC_VERSION), $1) # Usage: cflags-$(call clang-min-version, 110000) += -foo clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1) +# rustc-min-version +# Usage: rustc-$(call rustc-min-version, 108500) += -Cfoo +rustc-min-version = $(call test-ge, $(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)) --
Quoted 1 line
2.48.1
Quoted 8 lines · Miguel Ojeda
Introduce
rustc-min-versionsupport function that mimics{gcc,clang}-min-versionones, following commit88b61e3bff93("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).
Quoted 7 lines
Signed-off-by Miguel Ojeda <[email protected]>---
This is based on top of the fix so that the fix remains as simple as possible:https://lore.kernel.org/rust-for-linux/[email protected]/
Do you want me to pick it up to kbuild tree,
or will you take it with my Ack?
If you go with the latter,
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 6 lines · Masahiro Yamada
Do you want me to pick it up to kbuild tree,
or will you take it with my Ack?If you go with the latter,
Acked-by Masahiro Yamada <[email protected]>
Thanks a lot Masahiro -- happy to take it on my side if that means less work for you.
Cheers,
Miguel
Quoted 6 lines · Miguel Ojeda
Quoted 4 lines · Masahiro Yamada
Do you want me to pick it up to kbuild tree,
or will you take it with my Ack?
Quoted 9 lines
Quoted 2 lines
If you go with the latter,
Acked-by Masahiro Yamada <[email protected]>Thanks a lot Masahiro -- happy to take it on my side if that means less work for you.
Cheers,
Miguel
This has not been picked up by any one in linux-next.
I applied this to linux-kbuild now. Thanks.
--
Best Regards
Masahiro Yamada
Quoted 2 lines · Masahiro Yamada
This has not been picked up by any one in linux-next.
Yeah, I didn't start yet, sorry.
Quoted 1 line
I applied this to linux-kbuild now. Thanks.
Thanks!
Cheers,
Miguel