Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kbuild: add test-{ge,gt,le,lt} macros

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>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

+21 -5
+1 -1
Makefile
··· 994 994 # Check for frame size exceeding threshold during prolog/epilog insertion 995 995 # when using lld < 13.0.0. 996 996 ifneq ($(CONFIG_FRAME_WARN),0) 997 - ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0) 997 + ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y) 998 998 KBUILD_LDFLAGS += -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN) 999 999 endif 1000 1000 endif
+1 -1
arch/riscv/Makefile
··· 37 37 endif 38 38 39 39 ifeq ($(CONFIG_LD_IS_LLD),y) 40 - ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0) 40 + ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y) 41 41 KBUILD_CFLAGS += -mno-relax 42 42 KBUILD_AFLAGS += -mno-relax 43 43 ifndef CONFIG_AS_IS_LLVM
+1 -1
arch/x86/Makefile
··· 211 211 KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE) 212 212 213 213 ifdef CONFIG_LTO_CLANG 214 - ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0) 214 + ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y) 215 215 KBUILD_LDFLAGS += -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8) 216 216 endif 217 217 endif
+16
scripts/Kbuild.include
··· 12 12 pound := \# 13 13 14 14 ### 15 + # Comparison macros. 16 + # Usage: $(call test-lt, $(CONFIG_LLD_VERSION), 150000) 17 + # 18 + # Use $(intcmp ...) if supported. (Make >= 4.4) 19 + # Otherwise, fall back to the 'test' shell command. 20 + ifeq ($(intcmp 1,0,,,y),y) 21 + test-ge = $(intcmp $(strip $1)0, $(strip $2)0,,y,y) 22 + test-gt = $(intcmp $(strip $1)0, $(strip $2)0,,,y) 23 + else 24 + test-ge = $(shell test $(strip $1)0 -ge $(strip $2)0 && echo y) 25 + test-gt = $(shell test $(strip $1)0 -gt $(strip $2)0 && echo y) 26 + endif 27 + test-le = $(call test-ge, $2, $1) 28 + test-lt = $(call test-gt, $2, $1) 29 + 30 + ### 15 31 # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o 16 32 dot-target = $(dir $@).$(notdir $@) 17 33
+2 -2
scripts/Makefile.compiler
··· 63 63 64 64 # gcc-min-version 65 65 # Usage: cflags-$(call gcc-min-version, 70100) += -foo 66 - gcc-min-version = $(shell [ $(CONFIG_GCC_VERSION)0 -ge $(1)0 ] && echo y) 66 + gcc-min-version = $(call test-ge, $(CONFIG_GCC_VERSION), $1) 67 67 68 68 # clang-min-version 69 69 # Usage: cflags-$(call clang-min-version, 110000) += -foo 70 - clang-min-version = $(shell [ $(CONFIG_CLANG_VERSION)0 -ge $(1)0 ] && echo y) 70 + clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1) 71 71 72 72 # ld-option 73 73 # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)