From patchwork Fri Nov 18 19:53:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13048747 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3FBAC433FE for ; Fri, 18 Nov 2022 19:53:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231171AbiKRTxU (ORCPT ); Fri, 18 Nov 2022 14:53:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231393AbiKRTxQ (ORCPT ); Fri, 18 Nov 2022 14:53:16 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53B61B7E93; Fri, 18 Nov 2022 11:53:16 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D59B46269B; Fri, 18 Nov 2022 19:53:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62005C433B5; Fri, 18 Nov 2022 19:53:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668801195; bh=wUrXcoJycZccOLz2aaej5UsJmc9Iwi2+dKKmMfDV/h0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RGlUo4bz3GmYt03qSb/ffXbUyEfN55vN6z4W8851GmJwNQyrsLId8hwfNopcQXRVz SvtPfgdADwvMZBSWXT+GhRpZZq0Hl6AURqOZoR7KMX3JdLkd416INftQaVRJQ2wtR+ o94oSPE5mQIyHFPaVn9hmrLsO3zWuiqGF3Tf9d4rXOU+cFNOG5qbr70pSMefCDRYhZ HEOaaWDXeKf28Pd5SHpB5PMds+ZGRrCkYJlxrshyCLCqVkDALBivieo8KNndzmV+eZ 39ZVJGGKEwPJXOw2lQBMlMG3NrbeIsyxxd/vcf/DyjSeLh2rFb7NOFIl5K+n04FIV8 XMMA13BKlVNjg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 1/6] kbuild: add test-{le,ge,lt,gt} macros Date: Sat, 19 Nov 2022 04:53:02 +0900 Message-Id: <20221118195307.86049-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118195307.86049-1-masahiroy@kernel.org> References: <20221118195307.86049-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Because GNU Make is only able to handle strings, it is very hard to perform arighmetic in Makefiles. When we compare two integers, we invokes shell. One example is in the top Makefile: ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0) This is more expensive than using built-in functions since it forks a process. If we know the two have the same number of digits, we can do better. This commit adds four macros, test-le, test-ge, test-lt, test-gt. $(call test-lt, A, B) is evaluated to 'y' if A is less than B, or empty otherwise. This will replace $(call shell test A -lt B). Again, the limitation is that A and B must have the same number of digits because these macros are based on $(sort ) function. $(call test-lt, 1, 9) --> y (Works!) $(call test-lt, 10, 9) --> y (Not work...) To make the latter work, you need to add '0' prefix to align the number of digits: $(call test-lt, 10, 09) --> empty (Works!) Actually, we can live with this limitation in many places. As for the example above, we know $(CONFIG_LLD_VERSION) is 6-digits because the minimal supported version of LLVM is 11.0.0. So, the shell invocation can be replaced with more efficient code: ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y) Of course, this assumption will break when LLVM 100 is released, but it will be far in the future. Signed-off-by: Masahiro Yamada --- Makefile | 2 +- arch/riscv/Makefile | 2 +- arch/x86/Makefile | 2 +- scripts/Kbuild.include | 10 ++++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 58cd4f5e1c3a..303516c035f6 100644 --- a/Makefile +++ b/Makefile @@ -986,7 +986,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..9996f34327cb 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -11,6 +11,16 @@ space := $(empty) $(empty) space_escape := _-_SPACE_-_ pound := \# +### +# Comparison macros. +# Usage: $(call test-le, A, B) +# works like shell's "test A -le B", but A and B must have the same number of +# digits since it is just ASCII sort. +test-le = $(if $(filter $1, $(firstword $(sort $1 $2))),y) +test-ge = $(call test-le, $2, $1) +test-lt = $(if $(filter-out $2, $(firstword $(sort $1 $2))),y) +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 $@) From patchwork Fri Nov 18 19:53:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13048746 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74358C4332F for ; Fri, 18 Nov 2022 19:53:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229670AbiKRTxU (ORCPT ); Fri, 18 Nov 2022 14:53:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231388AbiKRTxS (ORCPT ); Fri, 18 Nov 2022 14:53:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD200B7EB6; Fri, 18 Nov 2022 11:53:17 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4845A6251B; Fri, 18 Nov 2022 19:53:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA489C433C1; Fri, 18 Nov 2022 19:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668801196; bh=wXJGBT1A52XfTBUcUmXtciPhChh/z7Sw4+vgV7bpK4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bFMMrT1GNVXJMOj/phzLELBESFBKwf25ezq14ItF4APdTJ90/ysm6FlUA6hOJzHrW iAad0HoYM0ruHOpEH/I5RvG6KjUOEHDGTxH9fY43tYmE9oadwLErYOTfGY1JTluqV0 ZRmdvvdu2o/PSD3lhAa89yRvUoj9UPvrZvgzX9bpTIcnovx0HLjFiiYFVv0DdBIMBv Et5d31i0aZdRR6XcCFsP2HgIQk+KKfQ4LPDDABaEOmhHj7ErcI118T0K39+13al7sB cQ0y3+bmvmhdOEgIhfYsX5CwUnfjy1FJNnoA7WpWQA+hZzBK0sRaVI54zUMDhhJZDO 0h4L8p+2wL1ww== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 2/6] kbuild: make CONFIG_*_VERSION always 6-digit Date: Sat, 19 Nov 2022 04:53:03 +0900 Message-Id: <20221118195307.86049-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118195307.86049-1-masahiroy@kernel.org> References: <20221118195307.86049-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org CONFIG_*_VERSION is the version number of a tool in a 5 or 6-digit form. This is fine in the Kconfig perspective because Kconfig supports numeric comparison (<, <=, >, >=). It is harder in Makefiles due to make's limited numerical capabilities. So, we ask for shell's "test" command when we compare versions, but it needs some process forks. test-{le,ge,lt,gt} macros can compare versions by using only built-in functions, but the number of digits must be aligned for those macros to work correctly. This commit (ab)uses Kconfig's hex type, which allows '0' prefixes, in order to make CONFIG_*_VERSION always 6-digit. For example with GCC 9.5, CONFIG_GCC_VERSION=90500 will be turned into CONFIG_GCC_VERSION=090500. I touched several Kconfig files so that versions are consistently compared against 6-digit numbers although this is not mandated. Signed-off-by: Masahiro Yamada --- arch/arm/mach-rpc/Kconfig | 2 +- arch/arm64/Kconfig | 4 ++-- arch/mips/vdso/Kconfig | 2 +- arch/powerpc/Kconfig | 2 +- arch/riscv/Kconfig | 4 ++-- init/Kconfig | 18 +++++++++--------- lib/Kconfig.debug | 6 +++--- lib/Kconfig.kasan | 2 +- scripts/as-version.sh | 6 +++--- scripts/cc-version.sh | 6 +++--- scripts/ld-version.sh | 6 +++--- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/arch/arm/mach-rpc/Kconfig b/arch/arm/mach-rpc/Kconfig index 55f6d829b677..106716042308 100644 --- a/arch/arm/mach-rpc/Kconfig +++ b/arch/arm/mach-rpc/Kconfig @@ -2,7 +2,7 @@ config ARCH_RPC bool "RiscPC" depends on ARCH_MULTI_V4 && !(ARCH_MULTI_V4T || ARCH_MULTI_V5) depends on !(ARCH_FOOTBRIDGE || ARCH_SA1100 || ARCH_MOXART || ARCH_GEMINI) - depends on !CC_IS_CLANG && GCC_VERSION < 90100 && GCC_VERSION >= 60000 + depends on !CC_IS_CLANG && GCC_VERSION < 090100 && GCC_VERSION >= 060000 depends on CPU_LITTLE_ENDIAN depends on ATAGS depends on MMU diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 505c8a1ccbe0..b318f7ad050b 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -236,7 +236,7 @@ config ARM64 config CLANG_SUPPORTS_DYNAMIC_FTRACE_WITH_REGS def_bool CC_IS_CLANG # https://github.com/ClangBuiltLinux/linux/issues/1507 - depends on AS_IS_GNU || (AS_IS_LLVM && (LD_IS_LLD || LD_VERSION >= 23600)) + depends on AS_IS_GNU || (AS_IS_LLVM && (LD_IS_LLD || LD_VERSION >= 023600)) select HAVE_DYNAMIC_FTRACE_WITH_REGS config GCC_SUPPORTS_DYNAMIC_FTRACE_WITH_REGS @@ -1814,7 +1814,7 @@ config ARM64_PTR_AUTH_KERNEL depends on (CC_HAS_SIGN_RETURN_ADDRESS || CC_HAS_BRANCH_PROT_PAC_RET) && AS_HAS_PAC # Modern compilers insert a .note.gnu.property section note for PAC # which is only understood by binutils starting with version 2.33.1. - depends on LD_IS_LLD || LD_VERSION >= 23301 || (CC_IS_GCC && GCC_VERSION < 90100) + depends on LD_IS_LLD || LD_VERSION >= 23301 || (CC_IS_GCC && GCC_VERSION < 090100) depends on !CC_IS_CLANG || AS_HAS_CFI_NEGATE_RA_STATE depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_REGS) help diff --git a/arch/mips/vdso/Kconfig b/arch/mips/vdso/Kconfig index a665f6108cb5..a8316108b756 100644 --- a/arch/mips/vdso/Kconfig +++ b/arch/mips/vdso/Kconfig @@ -12,7 +12,7 @@ # the lack of relocations. As such, we disable the VDSO for microMIPS builds. config MIPS_LD_CAN_LINK_VDSO - def_bool LD_VERSION >= 22500 || LD_IS_LLD + def_bool LD_VERSION >= 022500 || LD_IS_LLD config MIPS_DISABLE_VDSO def_bool CPU_MICROMIPS || (!CPU_MIPSR6 && !MIPS_LD_CAN_LINK_VDSO) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 2ca5418457ed..e7ba3a145595 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -220,7 +220,7 @@ config PPC select HAVE_FUNCTION_ERROR_INJECTION select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACER - select HAVE_GCC_PLUGINS if GCC_VERSION >= 50200 # plugin support on gcc <= 5.1 is buggy on PPC + select HAVE_GCC_PLUGINS if GCC_VERSION >= 050200 # plugin support on gcc <= 5.1 is buggy on PPC select HAVE_GENERIC_VDSO select HAVE_HARDLOCKUP_DETECTOR_ARCH if PPC_BOOK3S_64 && SMP select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index fa78595a6089..292f134f4493 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -416,7 +416,7 @@ config TOOLCHAIN_HAS_ZICBOM default y depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zicbom) depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zicbom) - depends on LLD_VERSION >= 150000 || LD_VERSION >= 23800 + depends on LLD_VERSION >= 150000 || LD_VERSION >= 023800 config RISCV_ISA_ZICBOM bool "Zicbom extension support for non-coherent DMA operation" @@ -440,7 +440,7 @@ config TOOLCHAIN_HAS_ZIHINTPAUSE default y depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zihintpause) depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zihintpause) - depends on LLD_VERSION >= 150000 || LD_VERSION >= 23600 + depends on LLD_VERSION >= 150000 || LD_VERSION >= 023600 config FPU bool "FPU support" diff --git a/init/Kconfig b/init/Kconfig index abf65098f1b6..402ce28c8eff 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -20,17 +20,17 @@ config CC_IS_GCC def_bool $(success,test "$(cc-name)" = GCC) config GCC_VERSION - int + hex default $(cc-version) if CC_IS_GCC - default 0 + default 000000 config CC_IS_CLANG def_bool $(success,test "$(cc-name)" = Clang) config CLANG_VERSION - int + hex default $(cc-version) if CC_IS_CLANG - default 0 + default 000000 config AS_IS_GNU def_bool $(success,test "$(as-name)" = GNU) @@ -39,7 +39,7 @@ config AS_IS_LLVM def_bool $(success,test "$(as-name)" = LLVM) config AS_VERSION - int + hex # Use clang version if this is the integrated assembler default CLANG_VERSION if AS_IS_LLVM default $(as-version) @@ -48,17 +48,17 @@ config LD_IS_BFD def_bool $(success,test "$(ld-name)" = BFD) config LD_VERSION - int + hex default $(ld-version) if LD_IS_BFD - default 0 + default 000000 config LD_IS_LLD def_bool $(success,test "$(ld-name)" = LLD) config LLD_VERSION - int + hex default $(ld-version) if LD_IS_LLD - default 0 + default 000000 config RUST_IS_AVAILABLE def_bool $(success,$(srctree)/scripts/rust_is_available.sh) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index d93dbe5a1d14..9d5f061fc4cf 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -258,7 +258,7 @@ config DEBUG_INFO_NONE config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT bool "Rely on the toolchain's implicit default DWARF version" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) + depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 023502 && AS_HAS_NON_CONST_LEB128) help The implicit default version of DWARF debug info produced by a toolchain changes over time. @@ -270,7 +270,7 @@ config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT config DEBUG_INFO_DWARF4 bool "Generate DWARF Version 4 debuginfo" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502) + depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 023502) help Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2 if using clang without clang's integrated assembler, and gdb 7.0+. @@ -282,7 +282,7 @@ config DEBUG_INFO_DWARF4 config DEBUG_INFO_DWARF5 bool "Generate DWARF Version 5 debuginfo" select DEBUG_INFO - depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128) + depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 023502 && AS_HAS_NON_CONST_LEB128) help Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc 5.0+ accepts the -gdwarf-5 flag but only had partial support for some diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan index ca09b1cf8ee9..2ad969c6eb29 100644 --- a/lib/Kconfig.kasan +++ b/lib/Kconfig.kasan @@ -29,7 +29,7 @@ config CC_HAS_KASAN_SW_TAGS # Old GCC versions do not have proper support for no_sanitize_address. # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89124 for details. config CC_HAS_WORKING_NOSANITIZE_ADDRESS - def_bool !CC_IS_GCC || GCC_VERSION >= 80300 + def_bool !CC_IS_GCC || GCC_VERSION >= 080300 menuconfig KASAN bool "KASAN: dynamic memory safety error detector" diff --git a/scripts/as-version.sh b/scripts/as-version.sh index 1a21495e9ff0..778ccbc82ca8 100755 --- a/scripts/as-version.sh +++ b/scripts/as-version.sh @@ -1,14 +1,14 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-only # -# Print the assembler name and its version in a 5 or 6-digit form. +# Print the assembler name and its version in a 6-digit form. # Also, perform the minimum version check. # (If it is the integrated assembler, return 0 as the version, and # skip the version check.) set -e -# Convert the version string x.y.z to a canonical 5 or 6-digit form. +# Convert the version string x.y.z to a canonical 6-digit form. get_canonical_version() { IFS=. @@ -18,7 +18,7 @@ get_canonical_version() # # The 4th field, if present, is ignored. # This occurs in development snapshots as in 2.35.1.20201116 - echo $((10000 * $1 + 100 * ${2:-0} + ${3:-0})) + printf "%06d\n" $((10000 * $1 + 100 * ${2:-0} + ${3:-0})) } # Clang fails to handle -Wa,--version unless -fno-integrated-as is given. diff --git a/scripts/cc-version.sh b/scripts/cc-version.sh index 2401c86fcf53..fe9f446a40b4 100755 --- a/scripts/cc-version.sh +++ b/scripts/cc-version.sh @@ -1,7 +1,7 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 # -# Print the C compiler name and its version in a 5 or 6-digit form. +# Print the C compiler name and its version in a 6-digit form. # Also, perform the minimum version check. set -e @@ -22,12 +22,12 @@ get_c_compiler_info() EOF } -# Convert the version string x.y.z to a canonical 5 or 6-digit form. +# Convert the version string x.y.z to a canonical 6-digit form. get_canonical_version() { IFS=. set -- $1 - echo $((10000 * $1 + 100 * $2 + $3)) + printf "%06d\n" $((10000 * $1 + 100 * $2 + $3)) } # $@ instead of $1 because multiple words might be given, e.g. CC="ccache gcc". diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh index a78b804b680c..a00693198a53 100755 --- a/scripts/ld-version.sh +++ b/scripts/ld-version.sh @@ -1,12 +1,12 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 # -# Print the linker name and its version in a 5 or 6-digit form. +# Print the linker name and its version in a 6-digit form. # Also, perform the minimum version check. set -e -# Convert the version string x.y.z to a canonical 5 or 6-digit form. +# Convert the version string x.y.z to a canonical 6-digit form. get_canonical_version() { IFS=. @@ -16,7 +16,7 @@ get_canonical_version() # # The 4th field, if present, is ignored. # This occurs in development snapshots as in 2.35.1.20201116 - echo $((10000 * $1 + 100 * ${2:-0} + ${3:-0})) + printf "%06d\n" $((10000 * $1 + 100 * ${2:-0} + ${3:-0})) } orig_args="$@" From patchwork Fri Nov 18 19:53:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13048749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5C37C4321E for ; Fri, 18 Nov 2022 19:53:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231388AbiKRTxX (ORCPT ); Fri, 18 Nov 2022 14:53:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbiKRTxU (ORCPT ); Fri, 18 Nov 2022 14:53:20 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ADA5B855C; Fri, 18 Nov 2022 11:53:19 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CBEAA62739; Fri, 18 Nov 2022 19:53:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40283C433B5; Fri, 18 Nov 2022 19:53:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668801198; bh=jkwieIU3zqT3Yga+W23Ydeot77NTQwoHFuXOZC5ErRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OmJDJst66s2v8a78YN50j8I5Rvjz5x7Ho/PMNoazQk7DzEsi41V9cX1SW75iuf82y XX4EqgRBE2nQpjjOCaNuXsaxuu+dSKz8b88mlWbLTO+FqmTYhN9z1FMEsf5axB/55Z t8TH7w40XCtlGRQG4ojD7ORPgwVCUVnfpG5uHTMplLZti4/g9FVIrxdmBPl+Elm8dv +z2XhZ/EnWl2KWCkADI015z94ufqK5Z8RfniuXynzGeRMYEkojTb4P5xdNfw523X7N 23nkPUmy4fBCC67m8+jFYqrND7/YTTvM/PvjIzDtqJKILNDYlsQ7CR+evEvKb6V6vz 6LzibfRfR/EGA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 3/6] kbuild: implement {gcc,clang}-min-version only with built-in functions Date: Sat, 19 Nov 2022 04:53:04 +0900 Message-Id: <20221118195307.86049-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118195307.86049-1-masahiroy@kernel.org> References: <20221118195307.86049-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Now CONFIG_{GCC,CLANG}_VERSION are always 6-digit, replace the shell invocations with the test-ge macro. Please note gcc-min-version must be used against a 6-digit number. Add '0' prefix. Signed-off-by: Masahiro Yamada --- Documentation/kbuild/makefiles.rst | 6 +++--- Makefile | 2 +- drivers/gpu/drm/amd/display/dc/dml/Makefile | 2 +- scripts/Makefile.compiler | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst index 6b7368d1f516..4144f1ce1ab5 100644 --- a/Documentation/kbuild/makefiles.rst +++ b/Documentation/kbuild/makefiles.rst @@ -669,18 +669,18 @@ more details, with real examples. gcc-min-version gcc-min-version tests if the value of $(CONFIG_GCC_VERSION) is greater than - or equal to the provided value and evaluates to y if so. + or equal to the provided value (in 6-digit form) and evaluates to y if so. Example:: - cflags-$(call gcc-min-version, 70100) := -foo + cflags-$(call gcc-min-version, 070100) := -foo In this example, cflags-y will be assigned the value -foo if $(CC) is gcc and $(CONFIG_GCC_VERSION) is >= 7.1. clang-min-version clang-min-version tests if the value of $(CONFIG_CLANG_VERSION) is greater - than or equal to the provided value and evaluates to y if so. + than or equal to the provided value (in 6-digit form) and evaluates to y if so. Example:: diff --git a/Makefile b/Makefile index 303516c035f6..03e6ae36c815 100644 --- a/Makefile +++ b/Makefile @@ -1050,7 +1050,7 @@ endif # ignored, continuing to default to PTRDIFF_MAX. So, left with no other # choice, we must perform a versioned check to disable this warning. # https://lore.kernel.org/lkml/20210824115859.187f272f@canb.auug.org.au -KBUILD_CFLAGS-$(call gcc-min-version, 90100) += -Wno-alloc-size-larger-than +KBUILD_CFLAGS-$(call gcc-min-version, 090100) += -Wno-alloc-size-larger-than KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH) # disable invalid "can't wrap" optimizations for signed / pointers diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile index ca7d24000621..8006801d1b56 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile @@ -34,7 +34,7 @@ dml_ccflags := -mhard-float -maltivec endif ifdef CONFIG_CC_IS_GCC -ifneq ($(call gcc-min-version, 70100),y) +ifneq ($(call gcc-min-version, 070100),y) IS_OLD_GCC = 1 endif endif diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler index 20d353dcabfb..db6f0546b0fc 100644 --- a/scripts/Makefile.compiler +++ b/scripts/Makefile.compiler @@ -62,12 +62,12 @@ cc-disable-warning = $(call try-run,\ $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) # gcc-min-version -# Usage: cflags-$(call gcc-min-version, 70100) += -foo -gcc-min-version = $(shell [ $(CONFIG_GCC_VERSION)0 -ge $(1)0 ] && echo y) +# Usage: cflags-$(call gcc-min-version, 070100) += -foo +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) From patchwork Fri Nov 18 19:53:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13048750 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB211C4332F for ; Fri, 18 Nov 2022 19:53:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231640AbiKRTxX (ORCPT ); Fri, 18 Nov 2022 14:53:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbiKRTxW (ORCPT ); Fri, 18 Nov 2022 14:53:22 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 219C7B5C67; Fri, 18 Nov 2022 11:53:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C9F10B82515; Fri, 18 Nov 2022 19:53:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2FC5C433C1; Fri, 18 Nov 2022 19:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668801199; bh=uuzKJuSL9U4I6WHbVaSjSwOBgCBIs163TnW2EI3m5+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E0JeKu6Z8lXqKFDfyG317cfY5aNZTtC7IcIZEEhM/mwnAXvQgpyLFvLiUDIKqsKdg lTg1pkn8jYZKB3/nCAJ9Qj5/6C9IJqydO8wC81xtg3vZSHkIojeW8v3PZqKo+HbiiA B4CkFfQ9dBsQAlcXYtfZ4NgTttG8SQL0sDSMaIBNn5WZVah2NTlmByKnEVZ1C66H6c iBArhSYEFYOWhYWk3wlJ1sJAZ1aJ9PFT7R782cD6oA6Yb0ScaMCvR5isTB5JhvmLVR dYMIBuy53qscKzFOiqsiFCghbwoQ6ICV7yZD6ehyJxzizAqb2xsPPJUC3S05rfmqqm GYrtgWH4hI4hg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 4/6] kbuild: add read-file macro Date: Sat, 19 Nov 2022 04:53:05 +0900 Message-Id: <20221118195307.86049-5-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118195307.86049-1-masahiroy@kernel.org> References: <20221118195307.86049-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Since GMU Make 4.2, $(file ...) supports the read operater '<', which is useful to read a file without forking any process. No warning is shown even if the input file is missing. For older Make versions, it falls back to the cat command. Signed-off-by: Masahiro Yamada --- Makefile | 2 +- scripts/Kbuild.include | 12 ++++++++++++ scripts/Makefile.modfinal | 2 +- scripts/Makefile.modinst | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 03e6ae36c815..93e5749ace55 100644 --- a/Makefile +++ b/Makefile @@ -369,7 +369,7 @@ else # !mixed-build include $(srctree)/scripts/Kbuild.include # Read KERNELRELEASE from include/config/kernel.release (if it exists) -KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) +KERNELRELEASE = $(call read-file, include/config/kernel.release) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 9996f34327cb..722846c23264 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -10,6 +10,10 @@ empty := space := $(empty) $(empty) space_escape := _-_SPACE_-_ pound := \# +define newline + + +endef ### # Comparison macros. @@ -55,6 +59,14 @@ stringify = $(squote)$(quote)$1$(quote)$(squote) kbuild-dir = $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) kbuild-file = $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile) +### +# Read a file, replacing newlines with spaces +ifeq ($(call test-ge, $(MAKE_VERSION), 4.2),y) +read-file = $(subst $(newline),$(space),$(file < $1)) +else +read-file = $(shell cat $1 2>/dev/null) +endif + ### # Easy method for doing a status message kecho := : diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal index 25bedd83644b..7252f6cf7837 100644 --- a/scripts/Makefile.modfinal +++ b/scripts/Makefile.modfinal @@ -13,7 +13,7 @@ include $(srctree)/scripts/Kbuild.include include $(srctree)/scripts/Makefile.lib # find all modules listed in modules.order -modules := $(sort $(shell cat $(MODORDER))) +modules := $(sort $(call read-file, $(MODORDER))) __modfinal: $(modules) @: diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index a4c987c23750..509d424dbbd2 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -9,7 +9,7 @@ __modinst: include include/config/auto.conf include $(srctree)/scripts/Kbuild.include -modules := $(sort $(shell cat $(MODORDER))) +modules := $(sort $(call read-file, $(MODORDER))) ifeq ($(KBUILD_EXTMOD),) dst := $(MODLIB)/kernel From patchwork Fri Nov 18 19:53:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13048752 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C26B3C433FE for ; Fri, 18 Nov 2022 19:53:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231693AbiKRTxi (ORCPT ); Fri, 18 Nov 2022 14:53:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231564AbiKRTxZ (ORCPT ); Fri, 18 Nov 2022 14:53:25 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CA38B8F95; Fri, 18 Nov 2022 11:53:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2B4DFB82518; Fri, 18 Nov 2022 19:53:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20962C43470; Fri, 18 Nov 2022 19:53:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668801200; bh=ryDjU692vvbieFeB+fZCtkAEExyqfoXOnX/ZyV+MCfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aOzo8E6tVsqTqKKXgn5QZwVrUYgifP7Er/UHBJ7xylrt0lF5xxwOmD4WEgoRLKn9W pppyrG6XQ+IjT/vYD5L5UimhGwKdz8ioh51dOX+4jEACgYjomdAma1Z6NQiibPwO/p aSc+G9luF4+8WK4H+N8FJwDN81+PaL93925MI3AyvnirfuqIKTtcd6Y1q5FSyf2r3p YnSmzjMi0P8ESTNPeOyyDvV4icZ/++VQQLITELzpSqDZ9C5byzpED3H5mU5peybUC6 hJmXTSo8MNqNF6zTDIY3V0GzoJ+kFRmgE5Cux6NzthNQuHJXiV7h6FaSgaGv1h4WCZ e9OOULpyvrG/Q== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 5/6] kconfig: refactor Makefile to reduce process forks Date: Sat, 19 Nov 2022 04:53:06 +0900 Message-Id: <20221118195307.86049-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118195307.86049-1-masahiroy@kernel.org> References: <20221118195307.86049-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Refactor Makefile and use read-file macro. For Make >= 4.2, it can read out a file by using the built-in function. Signed-off-by: Masahiro Yamada --- scripts/kconfig/.gitignore | 4 +++- scripts/kconfig/Makefile | 43 +++++++++++++++++++----------------- scripts/kconfig/gconf-cfg.sh | 7 ++++-- scripts/kconfig/mconf-cfg.sh | 25 ++++++++++++--------- scripts/kconfig/nconf-cfg.sh | 23 ++++++++++--------- scripts/kconfig/qconf-cfg.sh | 10 ++++++--- scripts/remove-stale-files | 2 ++ 7 files changed, 67 insertions(+), 47 deletions(-) diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore index 500e7424b3ef..c8a3f9cd52f0 100644 --- a/scripts/kconfig/.gitignore +++ b/scripts/kconfig/.gitignore @@ -1,5 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only /conf /[gmnq]conf -/[gmnq]conf-cfg +/[gmnq]conf-cflags +/[gmnq]conf-libs +/qconf-bin /qconf-moc.cc diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index b8ef0fb4bbef..da7da9775a4b 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -159,11 +159,12 @@ conf-objs := conf.o $(common-objs) hostprogs += nconf nconf-objs := nconf.o nconf.gui.o $(common-objs) -HOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs) -HOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) -HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) +HOSTLDLIBS_nconf = $(call read-file, $(obj)/nconf-libs) +HOSTCFLAGS_nconf.o = $(call read-file, $(obj)/nconf-cflags) +HOSTCFLAGS_nconf.gui.o = $(call read-file, $(obj)/nconf-cflags) -$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg +$(obj)/nconf: | $(obj)/nconf-libs +$(obj)/nconf.o $(obj)/nconf.gui.o: | $(obj)/nconf-cflags # mconf: Used for the menuconfig target based on lxdialog hostprogs += mconf @@ -171,27 +172,28 @@ lxdialog := $(addprefix lxdialog/, \ checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) mconf-objs := mconf.o $(lxdialog) $(common-objs) -HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs) +HOSTLDLIBS_mconf = $(call read-file, $(obj)/mconf-libs) $(foreach f, mconf.o $(lxdialog), \ - $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags))) + $(eval HOSTCFLAGS_$f = $$(call read-file, $(obj)/mconf-cflags))) -$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg +$(obj)/mconf: | $(obj)/mconf-libs +$(addprefix $(obj)/, mconf.o $(lxdialog)): | $(obj)/mconf-cflags # qconf: Used for the xconfig target based on Qt hostprogs += qconf qconf-cxxobjs := qconf.o qconf-moc.o qconf-objs := images.o $(common-objs) -HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs) -HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) -HOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) - -$(obj)/qconf.o: $(obj)/qconf-cfg +HOSTLDLIBS_qconf = $(call read-file, $(obj)/qconf-libs) +HOSTCXXFLAGS_qconf.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags) +HOSTCXXFLAGS_qconf-moc.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags) +$(obj)/qconf: | $(obj)/qconf-libs +$(obj)/qconf.o $(obj)/qconf-moc.o: | $(obj)/qconf-cflags quiet_cmd_moc = MOC $@ - cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@ + cmd_moc = $(call read-file, $(obj)/qconf-bin)/moc $< -o $@ -$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE +$(obj)/qconf-moc.cc: $(src)/qconf.h FORCE | $(obj)/qconf-bin $(call if_changed,moc) targets += qconf-moc.cc @@ -200,15 +202,16 @@ targets += qconf-moc.cc hostprogs += gconf gconf-objs := gconf.o images.o $(common-objs) -HOSTLDLIBS_gconf = $(shell . $(obj)/gconf-cfg && echo $$libs) -HOSTCFLAGS_gconf.o = $(shell . $(obj)/gconf-cfg && echo $$cflags) +HOSTLDLIBS_gconf = $(call read-file, $(obj)/gconf-libs) +HOSTCFLAGS_gconf.o = $(call read-file, $(obj)/gconf-cflags) -$(obj)/gconf.o: $(obj)/gconf-cfg +$(obj)/gconf: | $(obj)/gconf-libs +$(obj)/gconf.o: | $(obj)/gconf-cflags # check if necessary packages are available, and configure build flags -filechk_conf_cfg = $(CONFIG_SHELL) $< +cmd_conf_cfg = $< $(addprefix $(obj)/$*conf-, cflags libs bin) -$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE - $(call filechk,conf_cfg) +$(obj)/%conf-cflags $(obj)/%conf-libs $(obj)/%conf-bin: $(src)/%conf-cfg.sh + $(call cmd,conf_cfg) clean-files += *conf-cfg diff --git a/scripts/kconfig/gconf-cfg.sh b/scripts/kconfig/gconf-cfg.sh index cbd90c28c05f..040d8f338820 100755 --- a/scripts/kconfig/gconf-cfg.sh +++ b/scripts/kconfig/gconf-cfg.sh @@ -1,6 +1,9 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 +cflags=$1 +libs=$2 + PKG="gtk+-2.0 gmodule-2.0 libglade-2.0" if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then @@ -26,5 +29,5 @@ if ! ${HOSTPKG_CONFIG} --atleast-version=2.0.0 gtk+-2.0; then exit 1 fi -echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG)\" -echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG)\" +${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags} +${HOSTPKG_CONFIG} --libs ${PKG} > ${libs} diff --git a/scripts/kconfig/mconf-cfg.sh b/scripts/kconfig/mconf-cfg.sh index 025b565e0b7c..1e61f50a5905 100755 --- a/scripts/kconfig/mconf-cfg.sh +++ b/scripts/kconfig/mconf-cfg.sh @@ -1,19 +1,22 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 +cflags=$1 +libs=$2 + PKG="ncursesw" PKG2="ncurses" if [ -n "$(command -v ${HOSTPKG_CONFIG})" ]; then if ${HOSTPKG_CONFIG} --exists $PKG; then - echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG)\" - echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG)\" + ${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags} + ${HOSTPKG_CONFIG} --libs ${PKG} > ${libs} exit 0 fi - if ${HOSTPKG_CONFIG} --exists $PKG2; then - echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG2)\" - echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG2)\" + if ${HOSTPKG_CONFIG} --exists ${PKG2}; then + ${HOSTPKG_CONFIG} --cflags ${PKG2} > ${cflags} + ${HOSTPKG_CONFIG} --libs ${PKG2} > ${libs} exit 0 fi fi @@ -22,22 +25,22 @@ fi # (Even if it is installed, some distributions such as openSUSE cannot # find ncurses by pkg-config.) if [ -f /usr/include/ncursesw/ncurses.h ]; then - echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\" - echo libs=\"-lncursesw\" + echo -D_GNU_SOURCE -I/usr/include/ncursesw > ${cflags} + echo -lncursesw > ${libs} exit 0 fi if [ -f /usr/include/ncurses/ncurses.h ]; then - echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncurses\" - echo libs=\"-lncurses\" + echo -D_GNU_SOURCE -I/usr/include/ncurses > ${cflags} + echo -lncurses > ${libs} exit 0 fi # As a final fallback before giving up, check if $HOSTCC knows of a default # ncurses installation (e.g. from a vendor-specific sysroot). if echo '#include ' | ${HOSTCC} -E - >/dev/null 2>&1; then - echo cflags=\"-D_GNU_SOURCE\" - echo libs=\"-lncurses\" + echo -D_GNU_SOURCE > ${cflags} + echo -lncurses > ${libs} exit 0 fi diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh index 3a10bac2adb3..f871a2160e36 100755 --- a/scripts/kconfig/nconf-cfg.sh +++ b/scripts/kconfig/nconf-cfg.sh @@ -1,19 +1,22 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 +cflags=$1 +libs=$2 + PKG="ncursesw menuw panelw" PKG2="ncurses menu panel" if [ -n "$(command -v ${HOSTPKG_CONFIG})" ]; then if ${HOSTPKG_CONFIG} --exists $PKG; then - echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG)\" - echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG)\" + ${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags} + ${HOSTPKG_CONFIG} --libs ${PKG} > ${libs} exit 0 fi if ${HOSTPKG_CONFIG} --exists $PKG2; then - echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG2)\" - echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG2)\" + ${HOSTPKG_CONFIG} --cflags ${PKG2} > ${cflags} + ${HOSTPKG_CONFIG} --libs ${PKG2} > ${libs} exit 0 fi fi @@ -22,20 +25,20 @@ fi # (Even if it is installed, some distributions such as openSUSE cannot # find ncurses by pkg-config.) if [ -f /usr/include/ncursesw/ncurses.h ]; then - echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\" - echo libs=\"-lncursesw -lmenuw -lpanelw\" + echo -D_GNU_SOURCE -I/usr/include/ncursesw > ${cflags} + echo -lncursesw -lmenuw -lpanelw > ${libs} exit 0 fi if [ -f /usr/include/ncurses/ncurses.h ]; then - echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncurses\" - echo libs=\"-lncurses -lmenu -lpanel\" + echo -D_GNU_SOURCE -I/usr/include/ncurses > ${cflags} + echo -lncurses -lmenu -lpanel > ${libs} exit 0 fi if [ -f /usr/include/ncurses.h ]; then - echo cflags=\"-D_GNU_SOURCE\" - echo libs=\"-lncurses -lmenu -lpanel\" + echo -D_GNU_SOURCE > ${cflags} + echo -lncurses -lmenu -lpanel > ${libs} exit 0 fi diff --git a/scripts/kconfig/qconf-cfg.sh b/scripts/kconfig/qconf-cfg.sh index ad652cb53947..117f36e568fc 100755 --- a/scripts/kconfig/qconf-cfg.sh +++ b/scripts/kconfig/qconf-cfg.sh @@ -1,6 +1,10 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 +cflags=$1 +libs=$2 +bin=$3 + PKG="Qt5Core Qt5Gui Qt5Widgets" if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then @@ -11,9 +15,9 @@ if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then fi if ${HOSTPKG_CONFIG} --exists $PKG; then - echo cflags=\"-std=c++11 -fPIC $(${HOSTPKG_CONFIG} --cflags $PKG)\" - echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG)\" - echo moc=\"$(${HOSTPKG_CONFIG} --variable=host_bins Qt5Core)/moc\" + ${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags} + ${HOSTPKG_CONFIG} --libs ${PKG} > ${libs} + ${HOSTPKG_CONFIG} --variable=host_bins Qt5Core > ${bin} exit 0 fi diff --git a/scripts/remove-stale-files b/scripts/remove-stale-files index ccadfa3afb2b..64b14aa5aebf 100755 --- a/scripts/remove-stale-files +++ b/scripts/remove-stale-files @@ -47,3 +47,5 @@ rm -f arch/riscv/purgatory/kexec-purgatory.c rm -f scripts/extract-cert rm -f arch/x86/purgatory/kexec-purgatory.c + +rm -f scripts/kconfig/[gmnq]conf-cfg From patchwork Fri Nov 18 19:53:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13048751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D71E0C4332F for ; Fri, 18 Nov 2022 19:53:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229451AbiKRTxY (ORCPT ); Fri, 18 Nov 2022 14:53:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231814AbiKRTxX (ORCPT ); Fri, 18 Nov 2022 14:53:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFFBDB8F85; Fri, 18 Nov 2022 11:53:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 888BB6251B; Fri, 18 Nov 2022 19:53:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51275C4347C; Fri, 18 Nov 2022 19:53:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668801202; bh=jCvzmbRIXG2v1BOityBLpJImGOs/YCfsYemgrFfs7aA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sbJP75T3jcPRTR/gj908EXIbYcArqm1r3Zd30/w7+muYa8r8fBi5VKZuknJ6+i2WN Ay3MhiWJDrXTOfqhLn8J4MRNxcmNxUEN9YufITNGnMEoUOuDVNpp3RUO2/Zftr76Yf sNmxcR86NTp2JROrtlHM/eBUsNoMiXJ2qnUgdN2tL+euM2CJY5D1QZdWpNfsYHAAoj VXZ1wCLoT85T9wEPrrebSD0zojMLfXkHnnQ3uIw1pyDzxyHFMGgG9ftEr6lIXdqbIM NgQkmhx/37scwbSgv63LST3wr9m39jvqG/unz7OY6vmbTi3qMy4aUwmmNw9DEF1sbC 5y81cPtJISopQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 6/6] kbuild: check Make version Date: Sat, 19 Nov 2022 04:53:07 +0900 Message-Id: <20221118195307.86049-7-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118195307.86049-1-masahiroy@kernel.org> References: <20221118195307.86049-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org This is implemented based on test-le. It will work until GNU Make 10 is released. Signed-off-by: Masahiro Yamada --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 93e5749ace55..979363590bd7 100644 --- a/Makefile +++ b/Makefile @@ -368,6 +368,9 @@ else # !mixed-build include $(srctree)/scripts/Kbuild.include +# Check for the minimal Make version +$(if $(call test-lt, $(MAKE_VERSION), 3.82), $(error Make $(MAKE_VERSION) is too old)) + # Read KERNELRELEASE from include/config/kernel.release (if it exists) KERNELRELEASE = $(call read-file, include/config/kernel.release) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)