linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kbuild: rust: add rustc-min-version support function
@ 2025-02-10 16:42 Miguel Ojeda
  2025-02-10 17:04 ` Fiona Behrens
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Miguel Ojeda @ 2025-02-10 16:42 UTC (permalink / raw)
  To: Masahiro Yamada, Jonathan Corbet, Catalin Marinas, Will Deacon,
	Miguel Ojeda, Alex Gaynor
  Cc: Nathan Chancellor, Nicolas Schier, linux-kbuild, linux-doc,
	moderated for non-subscribers, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
	patches

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).

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
This is based on top of the fix so that the fix remains as simple as
possible:

    https://lore.kernel.org/rust-for-linux/20250210163732.281786-1-ojeda@kernel.org/

 Documentation/kbuild/makefiles.rst | 14 ++++++++++++++
 arch/arm64/Makefile                |  2 +-
 scripts/Makefile.compiler          |  4 ++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst
index d36519f194dc..2608aa32c762 100644
--- a/Documentation/kbuild/makefiles.rst
+++ b/Documentation/kbuild/makefiles.rst
@@ -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
 -----------------------

diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 2b25d671365f..1d5dfcd1c13e 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -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"
diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler
index 8c1029687e2e..8956587b8547 100644
--- a/scripts/Makefile.compiler
+++ b/scripts/Makefile.compiler
@@ -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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] kbuild: rust: add rustc-min-version support function
  2025-02-10 16:42 [PATCH] kbuild: rust: add rustc-min-version support function Miguel Ojeda
@ 2025-02-10 17:04 ` Fiona Behrens
  2025-02-13  7:19 ` Nicolas Schier
  2025-02-14  1:38 ` Masahiro Yamada
  2 siblings, 0 replies; 7+ messages in thread
From: Fiona Behrens @ 2025-02-10 17:04 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Masahiro Yamada, Jonathan Corbet, Catalin Marinas, Will Deacon,
	Alex Gaynor, Nathan Chancellor, Nicolas Schier, linux-kbuild,
	linux-doc, moderated for non-subscribers, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
	patches

Miguel Ojeda <ojeda@kernel.org> writes:

> 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).
>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Reviewed-by: Fiona Behrens <me@Kloenk.dev>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] kbuild: rust: add rustc-min-version support function
  2025-02-10 16:42 [PATCH] kbuild: rust: add rustc-min-version support function Miguel Ojeda
  2025-02-10 17:04 ` Fiona Behrens
@ 2025-02-13  7:19 ` Nicolas Schier
  2025-02-14  1:38 ` Masahiro Yamada
  2 siblings, 0 replies; 7+ messages in thread
From: Nicolas Schier @ 2025-02-13  7:19 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Masahiro Yamada, Jonathan Corbet, Catalin Marinas, Will Deacon,
	Alex Gaynor, Nathan Chancellor, linux-kbuild, linux-doc,
	moderated for non-subscribers, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
	patches

On Mon, Feb 10, 2025 at 05:42:45PM +0100, Miguel Ojeda wrote:
> 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).
> 
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> This is based on top of the fix so that the fix remains as simple as
> possible:
> 
>     https://lore.kernel.org/rust-for-linux/20250210163732.281786-1-ojeda@kernel.org/
> 
>  Documentation/kbuild/makefiles.rst | 14 ++++++++++++++
>  arch/arm64/Makefile                |  2 +-
>  scripts/Makefile.compiler          |  4 ++++
>  3 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst
> index d36519f194dc..2608aa32c762 100644
> --- a/Documentation/kbuild/makefiles.rst
> +++ b/Documentation/kbuild/makefiles.rst
> @@ -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
>  -----------------------
> 
> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index 2b25d671365f..1d5dfcd1c13e 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -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"
> diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler
> index 8c1029687e2e..8956587b8547 100644
> --- a/scripts/Makefile.compiler
> +++ b/scripts/Makefile.compiler
> @@ -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

Reviewed-by: Nicolas Schier <n.schier@avm.de>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] kbuild: rust: add rustc-min-version support function
  2025-02-10 16:42 [PATCH] kbuild: rust: add rustc-min-version support function Miguel Ojeda
  2025-02-10 17:04 ` Fiona Behrens
  2025-02-13  7:19 ` Nicolas Schier
@ 2025-02-14  1:38 ` Masahiro Yamada
  2025-02-14 18:47   ` Miguel Ojeda
  2 siblings, 1 reply; 7+ messages in thread
From: Masahiro Yamada @ 2025-02-14  1:38 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Jonathan Corbet, Catalin Marinas, Will Deacon, Alex Gaynor,
	Nathan Chancellor, Nicolas Schier, linux-kbuild, linux-doc,
	moderated for non-subscribers, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
	patches

On Tue, Feb 11, 2025 at 1:43 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> 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).
>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> This is based on top of the fix so that the fix remains as simple as
> possible:
>
>     https://lore.kernel.org/rust-for-linux/20250210163732.281786-1-ojeda@kernel.org/
>



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 <masahiroy@kernel.org>



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] kbuild: rust: add rustc-min-version support function
  2025-02-14  1:38 ` Masahiro Yamada
@ 2025-02-14 18:47   ` Miguel Ojeda
  2025-03-06 11:36     ` Masahiro Yamada
  0 siblings, 1 reply; 7+ messages in thread
From: Miguel Ojeda @ 2025-02-14 18:47 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Miguel Ojeda, Jonathan Corbet, Catalin Marinas, Will Deacon,
	Alex Gaynor, Nathan Chancellor, Nicolas Schier, linux-kbuild,
	linux-doc, moderated for non-subscribers, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
	patches

On Fri, Feb 14, 2025 at 2:39 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> 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 <masahiroy@kernel.org>

Thanks a lot Masahiro -- happy to take it on my side if that means
less work for you.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] kbuild: rust: add rustc-min-version support function
  2025-02-14 18:47   ` Miguel Ojeda
@ 2025-03-06 11:36     ` Masahiro Yamada
  2025-03-06 12:57       ` Miguel Ojeda
  0 siblings, 1 reply; 7+ messages in thread
From: Masahiro Yamada @ 2025-03-06 11:36 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Miguel Ojeda, Jonathan Corbet, Catalin Marinas, Will Deacon,
	Alex Gaynor, Nathan Chancellor, Nicolas Schier, linux-kbuild,
	linux-doc, moderated for non-subscribers, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
	patches

On Sat, Feb 15, 2025 at 3:48 AM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Fri, Feb 14, 2025 at 2:39 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > 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 <masahiroy@kernel.org>
>
> 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] kbuild: rust: add rustc-min-version support function
  2025-03-06 11:36     ` Masahiro Yamada
@ 2025-03-06 12:57       ` Miguel Ojeda
  0 siblings, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2025-03-06 12:57 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Miguel Ojeda, Jonathan Corbet, Catalin Marinas, Will Deacon,
	Alex Gaynor, Nathan Chancellor, Nicolas Schier, linux-kbuild,
	linux-doc, moderated for non-subscribers, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel,
	patches

On Thu, Mar 6, 2025 at 12:37 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> This has not been picked up by any one in linux-next.

Yeah, I didn't start yet, sorry.

> I applied this to linux-kbuild now. Thanks.

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-03-06 12:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-10 16:42 [PATCH] kbuild: rust: add rustc-min-version support function Miguel Ojeda
2025-02-10 17:04 ` Fiona Behrens
2025-02-13  7:19 ` Nicolas Schier
2025-02-14  1:38 ` Masahiro Yamada
2025-02-14 18:47   ` Miguel Ojeda
2025-03-06 11:36     ` Masahiro Yamada
2025-03-06 12:57       ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).