All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kbuild: add test-{ge,gt,le,lt} macros
@ 2022-12-11  2:46 ` Masahiro Yamada
  0 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2022-12-11  2:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Palmer Dabbelt, Albert Ou,
	Borislav Petkov, Dave Hansen, H. Peter Anvin, Ingo Molnar,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier,
	Palmer Dabbelt, Paul Walmsley, Thomas Gleixner, Tom Rix,
	linux-riscv, llvm, x86

GNU Make 4.4 introduced $(intcmp ...), which is useful to compare two
integers without forking a new process.

Add test-{ge,gt,le,lt} macros, which work more efficiently with GNU
Make >= 4.4. For older Make versions, they fall back to the 'test'
shell command.

The first two parameters to $(intcmp ...) must not be empty. To avoid
the syntax error, I appended '0' to them. Fortunately, '00' is treated
as '0'. This is needed because CONFIG options may expand to an empty
string when the kernel configuration is not included.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
---

Changes in v3:
  - Use $(intcmp ...) instead of playing with $(sort ...)

 Makefile                  |  2 +-
 arch/riscv/Makefile       |  2 +-
 arch/x86/Makefile         |  2 +-
 scripts/Kbuild.include    | 16 ++++++++++++++++
 scripts/Makefile.compiler |  4 ++--
 5 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index fbd9ff4a61e7..8801cac4d3d5 100644
--- a/Makefile
+++ b/Makefile
@@ -993,7 +993,7 @@ KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
 # Check for frame size exceeding threshold during prolog/epilog insertion
 # when using lld < 13.0.0.
 ifneq ($(CONFIG_FRAME_WARN),0)
-ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
+ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
 KBUILD_LDFLAGS	+= -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN)
 endif
 endif
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 0d13b597cb55..faf2c2177094 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -37,7 +37,7 @@ else
 endif
 
 ifeq ($(CONFIG_LD_IS_LLD),y)
-ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
+ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y)
 	KBUILD_CFLAGS += -mno-relax
 	KBUILD_AFLAGS += -mno-relax
 ifndef CONFIG_AS_IS_LLVM
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 415a5d138de4..e72c7a49cd59 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -211,7 +211,7 @@ endif
 KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
 
 ifdef CONFIG_LTO_CLANG
-ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
+ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
 KBUILD_LDFLAGS	+= -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
 endif
 endif
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index cbe28744637b..5019bc1e38e4 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -11,6 +11,22 @@ space   := $(empty) $(empty)
 space_escape := _-_SPACE_-_
 pound := \#
 
+###
+# Comparison macros.
+# Usage: $(call test-lt, $(CONFIG_LLD_VERSION), 150000)
+#
+# Use $(intcmp ...) if supported. (Make >= 4.4)
+# Otherwise, fall back to the 'test' shell command.
+ifeq ($(intcmp 1,0,,,y),y)
+test-le = $(intcmp $(strip $1)0, $(strip $2)0,y,y,)
+test-lt = $(intcmp $(strip $1)0, $(strip $2)0,y,,)
+else
+test-le = $(shell test $(strip $1)0 -le $(strip $2)0 && echo y)
+test-lt = $(shell test $(strip $1)0 -lt $(strip $2)0 && echo y)
+endif
+test-ge = $(call test-le, $2, $1)
+test-gt = $(call test-lt, $2, $1)
+
 ###
 # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
 dot-target = $(dir $@).$(notdir $@)
diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler
index 20d353dcabfb..3d8adfd34af1 100644
--- a/scripts/Makefile.compiler
+++ b/scripts/Makefile.compiler
@@ -63,11 +63,11 @@ cc-disable-warning = $(call try-run,\
 
 # gcc-min-version
 # Usage: cflags-$(call gcc-min-version, 70100) += -foo
-gcc-min-version = $(shell [ $(CONFIG_GCC_VERSION)0 -ge $(1)0 ] && echo y)
+gcc-min-version = $(call test-ge, $(CONFIG_GCC_VERSION), $1)
 
 # clang-min-version
 # Usage: cflags-$(call clang-min-version, 110000) += -foo
-clang-min-version = $(shell [ $(CONFIG_CLANG_VERSION)0 -ge $(1)0 ] && echo y)
+clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1)
 
 # ld-option
 # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
-- 
2.34.1


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

* [PATCH] kbuild: add test-{ge,gt,le,lt} macros
@ 2022-12-11  2:46 ` Masahiro Yamada
  0 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2022-12-11  2:46 UTC (permalink / raw)
  To: linux-kbuild
  Cc: linux-kernel, Masahiro Yamada, Palmer Dabbelt, Albert Ou,
	Borislav Petkov, Dave Hansen, H. Peter Anvin, Ingo Molnar,
	Nathan Chancellor, Nick Desaulniers, Nicolas Schier,
	Palmer Dabbelt, Paul Walmsley, Thomas Gleixner, Tom Rix,
	linux-riscv, llvm, x86

GNU Make 4.4 introduced $(intcmp ...), which is useful to compare two
integers without forking a new process.

Add test-{ge,gt,le,lt} macros, which work more efficiently with GNU
Make >= 4.4. For older Make versions, they fall back to the 'test'
shell command.

The first two parameters to $(intcmp ...) must not be empty. To avoid
the syntax error, I appended '0' to them. Fortunately, '00' is treated
as '0'. This is needed because CONFIG options may expand to an empty
string when the kernel configuration is not included.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
---

Changes in v3:
  - Use $(intcmp ...) instead of playing with $(sort ...)

 Makefile                  |  2 +-
 arch/riscv/Makefile       |  2 +-
 arch/x86/Makefile         |  2 +-
 scripts/Kbuild.include    | 16 ++++++++++++++++
 scripts/Makefile.compiler |  4 ++--
 5 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index fbd9ff4a61e7..8801cac4d3d5 100644
--- a/Makefile
+++ b/Makefile
@@ -993,7 +993,7 @@ KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
 # Check for frame size exceeding threshold during prolog/epilog insertion
 # when using lld < 13.0.0.
 ifneq ($(CONFIG_FRAME_WARN),0)
-ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
+ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
 KBUILD_LDFLAGS	+= -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN)
 endif
 endif
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 0d13b597cb55..faf2c2177094 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -37,7 +37,7 @@ else
 endif
 
 ifeq ($(CONFIG_LD_IS_LLD),y)
-ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
+ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y)
 	KBUILD_CFLAGS += -mno-relax
 	KBUILD_AFLAGS += -mno-relax
 ifndef CONFIG_AS_IS_LLVM
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 415a5d138de4..e72c7a49cd59 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -211,7 +211,7 @@ endif
 KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
 
 ifdef CONFIG_LTO_CLANG
-ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
+ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
 KBUILD_LDFLAGS	+= -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
 endif
 endif
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index cbe28744637b..5019bc1e38e4 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -11,6 +11,22 @@ space   := $(empty) $(empty)
 space_escape := _-_SPACE_-_
 pound := \#
 
+###
+# Comparison macros.
+# Usage: $(call test-lt, $(CONFIG_LLD_VERSION), 150000)
+#
+# Use $(intcmp ...) if supported. (Make >= 4.4)
+# Otherwise, fall back to the 'test' shell command.
+ifeq ($(intcmp 1,0,,,y),y)
+test-le = $(intcmp $(strip $1)0, $(strip $2)0,y,y,)
+test-lt = $(intcmp $(strip $1)0, $(strip $2)0,y,,)
+else
+test-le = $(shell test $(strip $1)0 -le $(strip $2)0 && echo y)
+test-lt = $(shell test $(strip $1)0 -lt $(strip $2)0 && echo y)
+endif
+test-ge = $(call test-le, $2, $1)
+test-gt = $(call test-lt, $2, $1)
+
 ###
 # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
 dot-target = $(dir $@).$(notdir $@)
diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler
index 20d353dcabfb..3d8adfd34af1 100644
--- a/scripts/Makefile.compiler
+++ b/scripts/Makefile.compiler
@@ -63,11 +63,11 @@ cc-disable-warning = $(call try-run,\
 
 # gcc-min-version
 # Usage: cflags-$(call gcc-min-version, 70100) += -foo
-gcc-min-version = $(shell [ $(CONFIG_GCC_VERSION)0 -ge $(1)0 ] && echo y)
+gcc-min-version = $(call test-ge, $(CONFIG_GCC_VERSION), $1)
 
 # clang-min-version
 # Usage: cflags-$(call clang-min-version, 110000) += -foo
-clang-min-version = $(shell [ $(CONFIG_CLANG_VERSION)0 -ge $(1)0 ] && echo y)
+clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1)
 
 # ld-option
 # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
-- 
2.34.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] kbuild: add test-{ge,gt,le,lt} macros
  2022-12-11  2:46 ` Masahiro Yamada
@ 2022-12-12 17:08   ` Nathan Chancellor
  -1 siblings, 0 replies; 6+ messages in thread
From: Nathan Chancellor @ 2022-12-12 17:08 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Palmer Dabbelt, Albert Ou,
	Borislav Petkov, Dave Hansen, H. Peter Anvin, Ingo Molnar,
	Nick Desaulniers, Nicolas Schier, Palmer Dabbelt, Paul Walmsley,
	Thomas Gleixner, Tom Rix, linux-riscv, llvm, x86

On Sun, Dec 11, 2022 at 11:46:47AM +0900, Masahiro Yamada wrote:
> GNU Make 4.4 introduced $(intcmp ...), which is useful to compare two
> integers without forking a new process.
> 
> Add test-{ge,gt,le,lt} macros, which work more efficiently with GNU
> Make >= 4.4. For older Make versions, they fall back to the 'test'
> shell command.
> 
> The first two parameters to $(intcmp ...) must not be empty. To avoid
> the syntax error, I appended '0' to them. Fortunately, '00' is treated
> as '0'. This is needed because CONFIG options may expand to an empty
> string when the kernel configuration is not included.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> 
> Changes in v3:
>   - Use $(intcmp ...) instead of playing with $(sort ...)
> 
>  Makefile                  |  2 +-
>  arch/riscv/Makefile       |  2 +-
>  arch/x86/Makefile         |  2 +-
>  scripts/Kbuild.include    | 16 ++++++++++++++++
>  scripts/Makefile.compiler |  4 ++--
>  5 files changed, 21 insertions(+), 5 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index fbd9ff4a61e7..8801cac4d3d5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -993,7 +993,7 @@ KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
>  # Check for frame size exceeding threshold during prolog/epilog insertion
>  # when using lld < 13.0.0.
>  ifneq ($(CONFIG_FRAME_WARN),0)
> -ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
> +ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
>  KBUILD_LDFLAGS	+= -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN)
>  endif
>  endif
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index 0d13b597cb55..faf2c2177094 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -37,7 +37,7 @@ else
>  endif
>  
>  ifeq ($(CONFIG_LD_IS_LLD),y)
> -ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
> +ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y)
>  	KBUILD_CFLAGS += -mno-relax
>  	KBUILD_AFLAGS += -mno-relax
>  ifndef CONFIG_AS_IS_LLVM
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index 415a5d138de4..e72c7a49cd59 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -211,7 +211,7 @@ endif
>  KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
>  
>  ifdef CONFIG_LTO_CLANG
> -ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
> +ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
>  KBUILD_LDFLAGS	+= -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
>  endif
>  endif
> diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
> index cbe28744637b..5019bc1e38e4 100644
> --- a/scripts/Kbuild.include
> +++ b/scripts/Kbuild.include
> @@ -11,6 +11,22 @@ space   := $(empty) $(empty)
>  space_escape := _-_SPACE_-_
>  pound := \#
>  
> +###
> +# Comparison macros.
> +# Usage: $(call test-lt, $(CONFIG_LLD_VERSION), 150000)
> +#
> +# Use $(intcmp ...) if supported. (Make >= 4.4)
> +# Otherwise, fall back to the 'test' shell command.
> +ifeq ($(intcmp 1,0,,,y),y)
> +test-le = $(intcmp $(strip $1)0, $(strip $2)0,y,y,)
> +test-lt = $(intcmp $(strip $1)0, $(strip $2)0,y,,)
> +else
> +test-le = $(shell test $(strip $1)0 -le $(strip $2)0 && echo y)
> +test-lt = $(shell test $(strip $1)0 -lt $(strip $2)0 && echo y)
> +endif
> +test-ge = $(call test-le, $2, $1)
> +test-gt = $(call test-lt, $2, $1)
> +
>  ###
>  # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
>  dot-target = $(dir $@).$(notdir $@)
> diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler
> index 20d353dcabfb..3d8adfd34af1 100644
> --- a/scripts/Makefile.compiler
> +++ b/scripts/Makefile.compiler
> @@ -63,11 +63,11 @@ cc-disable-warning = $(call try-run,\
>  
>  # gcc-min-version
>  # Usage: cflags-$(call gcc-min-version, 70100) += -foo
> -gcc-min-version = $(shell [ $(CONFIG_GCC_VERSION)0 -ge $(1)0 ] && echo y)
> +gcc-min-version = $(call test-ge, $(CONFIG_GCC_VERSION), $1)
>  
>  # clang-min-version
>  # Usage: cflags-$(call clang-min-version, 110000) += -foo
> -clang-min-version = $(shell [ $(CONFIG_CLANG_VERSION)0 -ge $(1)0 ] && echo y)
> +clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1)
>  
>  # ld-option
>  # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
> -- 
> 2.34.1
> 

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

* Re: [PATCH] kbuild: add test-{ge,gt,le,lt} macros
@ 2022-12-12 17:08   ` Nathan Chancellor
  0 siblings, 0 replies; 6+ messages in thread
From: Nathan Chancellor @ 2022-12-12 17:08 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Palmer Dabbelt, Albert Ou,
	Borislav Petkov, Dave Hansen, H. Peter Anvin, Ingo Molnar,
	Nick Desaulniers, Nicolas Schier, Palmer Dabbelt, Paul Walmsley,
	Thomas Gleixner, Tom Rix, linux-riscv, llvm, x86

On Sun, Dec 11, 2022 at 11:46:47AM +0900, Masahiro Yamada wrote:
> GNU Make 4.4 introduced $(intcmp ...), which is useful to compare two
> integers without forking a new process.
> 
> Add test-{ge,gt,le,lt} macros, which work more efficiently with GNU
> Make >= 4.4. For older Make versions, they fall back to the 'test'
> shell command.
> 
> The first two parameters to $(intcmp ...) must not be empty. To avoid
> the syntax error, I appended '0' to them. Fortunately, '00' is treated
> as '0'. This is needed because CONFIG options may expand to an empty
> string when the kernel configuration is not included.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> 
> Changes in v3:
>   - Use $(intcmp ...) instead of playing with $(sort ...)
> 
>  Makefile                  |  2 +-
>  arch/riscv/Makefile       |  2 +-
>  arch/x86/Makefile         |  2 +-
>  scripts/Kbuild.include    | 16 ++++++++++++++++
>  scripts/Makefile.compiler |  4 ++--
>  5 files changed, 21 insertions(+), 5 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index fbd9ff4a61e7..8801cac4d3d5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -993,7 +993,7 @@ KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
>  # Check for frame size exceeding threshold during prolog/epilog insertion
>  # when using lld < 13.0.0.
>  ifneq ($(CONFIG_FRAME_WARN),0)
> -ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
> +ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
>  KBUILD_LDFLAGS	+= -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN)
>  endif
>  endif
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index 0d13b597cb55..faf2c2177094 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -37,7 +37,7 @@ else
>  endif
>  
>  ifeq ($(CONFIG_LD_IS_LLD),y)
> -ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0)
> +ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y)
>  	KBUILD_CFLAGS += -mno-relax
>  	KBUILD_AFLAGS += -mno-relax
>  ifndef CONFIG_AS_IS_LLVM
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index 415a5d138de4..e72c7a49cd59 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -211,7 +211,7 @@ endif
>  KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
>  
>  ifdef CONFIG_LTO_CLANG
> -ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
> +ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
>  KBUILD_LDFLAGS	+= -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
>  endif
>  endif
> diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
> index cbe28744637b..5019bc1e38e4 100644
> --- a/scripts/Kbuild.include
> +++ b/scripts/Kbuild.include
> @@ -11,6 +11,22 @@ space   := $(empty) $(empty)
>  space_escape := _-_SPACE_-_
>  pound := \#
>  
> +###
> +# Comparison macros.
> +# Usage: $(call test-lt, $(CONFIG_LLD_VERSION), 150000)
> +#
> +# Use $(intcmp ...) if supported. (Make >= 4.4)
> +# Otherwise, fall back to the 'test' shell command.
> +ifeq ($(intcmp 1,0,,,y),y)
> +test-le = $(intcmp $(strip $1)0, $(strip $2)0,y,y,)
> +test-lt = $(intcmp $(strip $1)0, $(strip $2)0,y,,)
> +else
> +test-le = $(shell test $(strip $1)0 -le $(strip $2)0 && echo y)
> +test-lt = $(shell test $(strip $1)0 -lt $(strip $2)0 && echo y)
> +endif
> +test-ge = $(call test-le, $2, $1)
> +test-gt = $(call test-lt, $2, $1)
> +
>  ###
>  # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
>  dot-target = $(dir $@).$(notdir $@)
> diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler
> index 20d353dcabfb..3d8adfd34af1 100644
> --- a/scripts/Makefile.compiler
> +++ b/scripts/Makefile.compiler
> @@ -63,11 +63,11 @@ cc-disable-warning = $(call try-run,\
>  
>  # gcc-min-version
>  # Usage: cflags-$(call gcc-min-version, 70100) += -foo
> -gcc-min-version = $(shell [ $(CONFIG_GCC_VERSION)0 -ge $(1)0 ] && echo y)
> +gcc-min-version = $(call test-ge, $(CONFIG_GCC_VERSION), $1)
>  
>  # clang-min-version
>  # Usage: cflags-$(call clang-min-version, 110000) += -foo
> -clang-min-version = $(shell [ $(CONFIG_CLANG_VERSION)0 -ge $(1)0 ] && echo y)
> +clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1)
>  
>  # ld-option
>  # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)
> -- 
> 2.34.1
> 

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] kbuild: add test-{ge,gt,le,lt} macros
  2022-12-11  2:46 ` Masahiro Yamada
@ 2022-12-13  4:02   ` Nicolas Schier
  -1 siblings, 0 replies; 6+ messages in thread
From: Nicolas Schier @ 2022-12-13  4:02 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Palmer Dabbelt, Albert Ou,
	Borislav Petkov, Dave Hansen, H. Peter Anvin, Ingo Molnar,
	Nathan Chancellor, Nick Desaulniers, Palmer Dabbelt,
	Paul Walmsley, Thomas Gleixner, Tom Rix, linux-riscv, llvm, x86

[-- Attachment #1: Type: text/plain, Size: 877 bytes --]

On Sun 11 Dec 2022 11:46:47 GMT, Masahiro Yamada wrote:
> GNU Make 4.4 introduced $(intcmp ...), which is useful to compare two
> integers without forking a new process.
> 
> Add test-{ge,gt,le,lt} macros, which work more efficiently with GNU
> Make >= 4.4. For older Make versions, they fall back to the 'test'
> shell command.
> 
> The first two parameters to $(intcmp ...) must not be empty. To avoid
> the syntax error, I appended '0' to them. Fortunately, '00' is treated
> as '0'. This is needed because CONFIG options may expand to an empty
> string when the kernel configuration is not included.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
> ---
> 
> Changes in v3:
>   - Use $(intcmp ...) instead of playing with $(sort ...)

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] kbuild: add test-{ge,gt,le,lt} macros
@ 2022-12-13  4:02   ` Nicolas Schier
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Schier @ 2022-12-13  4:02 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, linux-kernel, Palmer Dabbelt, Albert Ou,
	Borislav Petkov, Dave Hansen, H. Peter Anvin, Ingo Molnar,
	Nathan Chancellor, Nick Desaulniers, Palmer Dabbelt,
	Paul Walmsley, Thomas Gleixner, Tom Rix, linux-riscv, llvm, x86


[-- Attachment #1.1: Type: text/plain, Size: 877 bytes --]

On Sun 11 Dec 2022 11:46:47 GMT, Masahiro Yamada wrote:
> GNU Make 4.4 introduced $(intcmp ...), which is useful to compare two
> integers without forking a new process.
> 
> Add test-{ge,gt,le,lt} macros, which work more efficiently with GNU
> Make >= 4.4. For older Make versions, they fall back to the 'test'
> shell command.
> 
> The first two parameters to $(intcmp ...) must not be empty. To avoid
> the syntax error, I appended '0' to them. Fortunately, '00' is treated
> as '0'. This is needed because CONFIG options may expand to an empty
> string when the kernel configuration is not included.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
> ---
> 
> Changes in v3:
>   - Use $(intcmp ...) instead of playing with $(sort ...)

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2022-12-13  4:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-11  2:46 [PATCH] kbuild: add test-{ge,gt,le,lt} macros Masahiro Yamada
2022-12-11  2:46 ` Masahiro Yamada
2022-12-12 17:08 ` Nathan Chancellor
2022-12-12 17:08   ` Nathan Chancellor
2022-12-13  4:02 ` Nicolas Schier
2022-12-13  4:02   ` Nicolas Schier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.