From patchwork Wed Nov 23 15:18:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 25045 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2855225wrr; Wed, 23 Nov 2022 07:25:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf6MrzkKb+K6lVj8YpEi+ecfXES1AOxdzajo75f1ABh01jAPZtiU1MNtsrlL2X64l3pHYnAH X-Received: by 2002:a17:906:1c12:b0:7b5:f9dd:2f4 with SMTP id k18-20020a1709061c1200b007b5f9dd02f4mr12795189ejg.243.1669217103772; Wed, 23 Nov 2022 07:25:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669217103; cv=none; d=google.com; s=arc-20160816; b=0OAB5E13DzIiXnJEYzysnsaankFnBTZmFoxX86FcsqiOquc233q9l3p9BFWZ1hKLMP 4VHVAoO2t0J47661nZoYMi1qBeNexyQHU5oZHXXul3okpEzpPD389j+NpfeSV8lDx6hL 8hXQ3OWfGRhoEx4KzyeZd4Mjb3MJWUvz/f/OA7R5+tf+rZuWmz+6y5d4L00XhT24C0xs OP6ylaeIVkhWN34eQoY//Ha09SIx3buaUF+UDo116REivSN3rWgSM+5i+/cA41/IS89B 4lYhlOVT2yC1Ac6QOKSiIjuNAPqptIn+6FseRCo5j6dJB7wpCp7FcK8KUTY8fbhu38A6 QwSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Wo+bMXbf7hkiB8qBn12pzwK3FJXVxx5Fut1Q4Y8Wj+8=; b=MSMyRuDYmIo6Tx42L9qMuA0b6m7AUXnHfi0W9ZYBKFoyscNs2ktMqQtmT0qOivuLe9 NiDEH4jGVYxce+jB4TarWiM9laHo1jnG1W53rPyQhMF5LxJSULgSO5s4PTUCSu+BrZuo d4uXdIpF0k363zJ8adyHL92RYFQ3+m/EfKx0XRHnaU+BnX0hY+C06ppFP0mxvDYNrdzT WOdjCxBTEzHQbmNkW2K/YyC0FP8gW91PoJQa5moHm3eF44P9aALzCSVqiBLN+4CJdKGV fi0xcAgUlbh4CReiJPpZmbFozCtaxyMg70cSJ9wb9JH8eFyiuR3aHJKZwsVk8Us9HXIs XQYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mbr1ML+r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a15-20020aa7d90f000000b00447d6f244c6si9876181edr.248.2022.11.23.07.24.39; Wed, 23 Nov 2022 07:25:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mbr1ML+r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237920AbiKWPT1 (ORCPT + 99 others); Wed, 23 Nov 2022 10:19:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235632AbiKWPTZ (ORCPT ); Wed, 23 Nov 2022 10:19:25 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 308232AE08; Wed, 23 Nov 2022 07:19:24 -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 D7D1CB820DE; Wed, 23 Nov 2022 15:19:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63D24C433C1; Wed, 23 Nov 2022 15:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669216761; bh=3H3vMqUsQmNXXkdqKJfmgSW/egj9FDENfVTPaP6+qAM=; h=From:To:Cc:Subject:Date:From; b=mbr1ML+rZ3tuUOMFTKOQ2+nl9SQroYHL+XVO/LMgRLCB6TAIXFMQe/N7MyaetbGQb xb8vfny9wHaFPR5n0mHPInD7BleStI5tVIiPWx2yanhnepMZrzN/ilLOAElKsO7W5k +5JHMl5yV6ctya8eve2bERbyI6Q/yICSK5SA2mNVQVuEeDZ7OMWea22uwJLksdyH6q AtLXqW+EjzAr0RPmjJOXM/4rq/azUddFYDgdWj2mPbw8FKoG0p3LV+mSmd1WxTXwhu oCyfP4udqnktAdYvrurVK/FWzw1cAJCtwhUAWaPV9bxI1uWbufb/3mDc/1bTt/KK9W Y1IghW53EKlFA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , 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@lists.infradead.org, llvm@lists.linux.dev, x86@kernel.org Subject: [PATCH v2 1/5] kbuild: add test-{le,ge,lt,gt} macros Date: Thu, 24 Nov 2022 00:18:24 +0900 Message-Id: <20221123151828.509565-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750300993425976125?= X-GMAIL-MSGID: =?utf-8?q?1750300993425976125?= 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 Reviewed-by: Nicolas Schier Acked-by: Palmer Dabbelt # RISC-V --- (no changes since v1) 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 6f846b1f2618..eb80332f7b51 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 Wed Nov 23 15:18:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 25053 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2856296wrr; Wed, 23 Nov 2022 07:27:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Eh0FqJA5SzO4cOzMwDoMfnVD4Cm/FYS6pQ21v+EXQycUERZ8cxjq4xiU2M8Ky7AsWlGYF X-Received: by 2002:a17:90a:3d41:b0:213:d34:a80b with SMTP id o1-20020a17090a3d4100b002130d34a80bmr31406719pjf.74.1669217229765; Wed, 23 Nov 2022 07:27:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669217229; cv=none; d=google.com; s=arc-20160816; b=MdocVQX+nFCmcsQuoUP33mOpmnqVMv5nGGbDaE9zo4Vt2fyZD3y5vcuuQTQ90hBkfr NWB7CZ9ThWYCAGLk0nAaAcwudOznCti+41WAB1Te55WmtlqqzI/aMHAOmqCS8TFCSK1x gp/c+LDdNDM6Z4HFsBR4O0Io+Du2Aki+pGpWF0p83MNiCaUg6g8fgpM03dvVka9eylXX R4yM/MKewryzFtg+wKb/09loqRySXZiUwIC82Q1tfJk9wr9JXWJaMeuweH/ynXKM4SbS DKJItZXWg9gx3rRpQiROFnx4TyZSK4ZtM6Y8fmFrhoSov4do6HKuEQ25aTKCA/yzvvmI CE0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ztVMqwpl2gT9e14Dt5zPLHVaAGsq5p/P2n7WKdzzQ4c=; b=BCz1Bl5SDlkiUHEWRNS9YqnqoWjHjX2jopuvhEtTcAcjER70N/QzPQb0Y8zMfmxMgA m6jwJ1yEpp0yxhPp8L+m1241IYE1rwshJK96oWI+XmxnFiB5mIhnGMeOeRs8Q+MrW8jf S6Pnz+VD3MYz4QgfoyJXyC1/cST0cvZBE0HuhVGfcPgMQiyWfcVtqep7IrMxcNeLqVH7 huDnSvr/ts9Uo9YDvVATIlug6w0UPws/dv2Z9vQ0iwrnSjG+sfy5k/mtHh2nC+/yQhUG tpmWLZ4I9Ukc4aWcnTt6FrUVrqk/LyuM7m79F6yP0AcfncTLZptCbRcsC2yf41aCJTvQ dMmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u78ZRFdh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x14-20020aa79ace000000b0056ea2b142b6si16266641pfp.373.2022.11.23.07.26.55; Wed, 23 Nov 2022 07:27:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u78ZRFdh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238487AbiKWPTa (ORCPT + 99 others); Wed, 23 Nov 2022 10:19:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237256AbiKWPT1 (ORCPT ); Wed, 23 Nov 2022 10:19:27 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F2872AE08; Wed, 23 Nov 2022 07:19:26 -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 14AF0B8201C; Wed, 23 Nov 2022 15:19:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E926C433D6; Wed, 23 Nov 2022 15:19:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669216763; bh=zZ9vzObwysMPcl9yyFyu+hM9JhD2sJD/mwetUOgE8Dc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u78ZRFdhLLKDOiXCo43KHNi5x4eN+sGMnlkZhZxhh3Zo0KVTH0mpwpKJoTiizKtaw UMEtdoP5kGu2uwa92JY1T16CK+MW1zge+M3dhb1ztCGfyNyycOs/Ses6zKE2tpIwc2 /V1N2q5WazBhktgQHq26rhp21iNgXR5vg58MchCLIBNIdtW4VTQcn2MBX2QV0d2JP3 Kggcc4K2uibSlJkbFNo496Fzv4PM2P1a3WoFr32yWGh6fB84EkxOdqgfl57WUCpbMu guv5ppWMHxrcwqfxWb+2V9j1zhrskW9jryNi0H1Io6Uu+w9YTTHBg+L4oSqHB6OjE0 p+QAlYHf/p0Pw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Tom Rix , llvm@lists.linux.dev Subject: [PATCH v2 2/5] kbuild: implement {gcc,clang}-min-version only with built-in functions Date: Thu, 24 Nov 2022 00:18:25 +0900 Message-Id: <20221123151828.509565-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221123151828.509565-1-masahiroy@kernel.org> References: <20221123151828.509565-1-masahiroy@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750301125922908996?= X-GMAIL-MSGID: =?utf-8?q?1750301125922908996?= Converting clang-min-version is straightforward because the versions are always 6-digit. gcc-min-version is somewhat tricky because the minimal GCC version is GCC 5.2; prepend '0' to the version that is less than 10 so that test-ge is always passed with 6-digit versions. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- Changes in v2: - Covert gcc-min-version in a different way scripts/Makefile.compiler | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler index 20d353dcabfb..cd75f81e88ef 100644 --- a/scripts/Makefile.compiler +++ b/scripts/Makefile.compiler @@ -63,11 +63,15 @@ 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) + +# Preprend 0 to the version that is less than 10 so test-ge works. +gcc-min-version = $(call test-ge, \ + $(or $(filter 1%, $(CONFIG_GCC_VERSION)), 0$(CONFIG_GCC_VERSION)), \ + $(or $(filter 1%, $1), 0$(strip $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 Wed Nov 23 15:18:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 25048 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2855501wrr; Wed, 23 Nov 2022 07:25:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf4BPodQQVv+7dcavKccr4DcY1G0miHubv0yjLsRqswnkRM3vppERmyl872X0NuyXL6ngpsd X-Received: by 2002:aa7:d5c5:0:b0:46a:1d7:c94d with SMTP id d5-20020aa7d5c5000000b0046a01d7c94dmr5793422eds.327.1669217143098; Wed, 23 Nov 2022 07:25:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669217143; cv=none; d=google.com; s=arc-20160816; b=qy/gmtbrW+wwpZubdmySI2qtKH8P1rs+DNNbNu9M3T6irqJqayq/jG/zYLUrtQ4yyD jFyLNmQfnx5PdFYKZDoJe7nitztCIKzGXsiQTD3CuFIY8SgfTuC0/9JZfeX23SnTWpPc q6O6EQJR+pfe8rc64j7Uwe2QBXgehUy8+RFLF9RTIKV6OfCJmaWAEaqMW70rrYn68kvO sZ1R0DvlFtTWl+cGLJRJf3GgcwUzMe17HJDVdv6T/hmX5H+qlv0vRNA0rjkk8mMCuTHB YkQN5HSDQKIqHOVEmSuIoYe3mB4XFIdMMXdWcMjW/dejn5YKKJHYCMXbRO6QsVGK2wmy lZEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rs/32uapPu5livhOxx1Zm9JWbwSMSSx8f4Wwu2K94hY=; b=BPjp7hUuwfh4wz3efRirgLzOYTJRoIiBJxuMY4lCY9Rr0GUHZXccnVUaahh8sOHyEz YD1B2O6xWZSImBZZc8ViAB0GbQQ0miMF+bc6WXd75hKaEdFHX3almFlrOPtfxe5yqdMJ 8z3AQdqQxFmeBXMZx2ShW0xVti7pdySzA+jo+adDIMVnzUUH6NRjIr/R7TOUSSF7Fjai oFGqouRchah3csb903Fkrov6ccoNr4k+irzvCkfsY/t2of39fJybdDgrTWmGPtIiCzjE dTKkTV9G7GpkAy3jaTQjAY1Fsh34AOgKh5RjWcDryqZEtj1KU5H4V++NdsTE1IZOKUi7 aacg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZTakJUh4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f26-20020a50fc9a000000b004608b4f28b7si12788468edq.106.2022.11.23.07.25.18; Wed, 23 Nov 2022 07:25:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZTakJUh4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237256AbiKWPTk (ORCPT + 99 others); Wed, 23 Nov 2022 10:19:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238338AbiKWPT3 (ORCPT ); Wed, 23 Nov 2022 10:19:29 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 477502AE08; Wed, 23 Nov 2022 07:19:28 -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 E772DB820DD; Wed, 23 Nov 2022 15:19:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 469F7C43144; Wed, 23 Nov 2022 15:19:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669216765; bh=OBMm4QqhOlmUT3g2hDP5qvjLfDtxhBIfGMu2b58WDTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZTakJUh4PdtKZVMtfRk/8rZ7yYVopIAcF1MKUjNpx4uYLT/NqB3Mf1SsYWze85pWo x1E90tv3bomKgNa7eh63QrDSOGbRC7OxoFGAnQ94A76NYCcLAIOSRO1VyC4sVXHJ6m RouFILUtkRGvx58oSm4O3dnFCDSUgN7GQb77ShPvmMADImlEcl//liBhtPSso2Gzgk smA/5LKHQ0uAIWgB4OAKl3D3BNNzAaVt3giuxpqE+2sWxbSGYUUl/3Hy4Px+8zdT5i ZHXqqA2LvfZz+hcHjs+9dN+X/Lhr4jqkIhBersDC9u6NHW0UOD7DaYK0dAHa3zix/s NKvwf9hY/O5Uw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH v2 3/5] kbuild: add read-file macro Date: Thu, 24 Nov 2022 00:18:26 +0900 Message-Id: <20221123151828.509565-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221123151828.509565-1-masahiroy@kernel.org> References: <20221123151828.509565-1-masahiroy@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750301035227609156?= X-GMAIL-MSGID: =?utf-8?q?1750301035227609156?= 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 Reviewed-by: Nicolas Schier --- (no changes since v1) 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 eb80332f7b51..60ce9dcafc72 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 Wed Nov 23 15:18:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 25046 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2855329wrr; Wed, 23 Nov 2022 07:25:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf66L3SNoV/RgKE3HWirsg9oq67YzWckNtINXw7kIWWHuAHPBUipAH96aHd5+aQyCaKVykJY X-Received: by 2002:aa7:cb15:0:b0:458:e9c0:3e6f with SMTP id s21-20020aa7cb15000000b00458e9c03e6fmr26550778edt.61.1669217118692; Wed, 23 Nov 2022 07:25:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669217118; cv=none; d=google.com; s=arc-20160816; b=BqQzIm5bH56HmsieU+wVZap9Wd3RZzMi2ewVjt/4w5zZ9gl6HkM3w4xVUmLP0pW8HV WtpR75ISj1WNCDudNkVgxq59joWTlCUB1HE1F7fPnKBQajurKU9EL8Q16fGqY5WUr8Ig i6JdKr5ArSkZCvhDx/aXYARHzoFFsb+ZQ31XQLt414cMR/pFaOSqszGrP68+FdLB2IdZ mLwk4WCV0RFY4lbz4x/EW1uu1gAZkgJHpAbqvhYDIuidGD8AjgjH4VdC9HQQSjmGnk8r FDHqAmPGsNVYQPKc59UWXLkmyBQpChd+4KSSgBUk2tVjxYgiJnuOHuu7H7VtZmomvEzP zN2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KsbzuGioeGjBJXo0Wy5fyij2vNBC7xGIBsH5uJFt8G0=; b=BS9tcuta289Xbt4oB+l7uI2SCXeM73URGOl3mAtxSEPhJH8UlzgpubtSwyj+Fo78lq 3qmnufyOR5lpv11b0IMDZlR3t3JsFeULi2uzrP3WA6pVCeMrJazJXnYNm6Mxpz/npTHX vqW5YMFMITy5OqKVkF8TGHfUwr5pU35AnIc51rceHcHZ6jFE9uth0GNFGP0YQt7awfzU xB9qzuiZHPxCq/f4EkxTM5U3AWPDXGs86i22Dy+y+hZFnuUnXT3X+LfjFjVFLo+neNmX 8dytlXhqbZMuSlWfq+0DjSMKw0TmWlhA/+ui80DiLEqm6VkurrIYupu1vCoxkZ7bTjxu w8jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FFzNfwsc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s20-20020a056402521400b00468f23d264asi16131450edd.536.2022.11.23.07.24.53; Wed, 23 Nov 2022 07:25:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FFzNfwsc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238665AbiKWPTn (ORCPT + 99 others); Wed, 23 Nov 2022 10:19:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238639AbiKWPTi (ORCPT ); Wed, 23 Nov 2022 10:19:38 -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 7693660345; Wed, 23 Nov 2022 07:19:29 -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 00054B820D3; Wed, 23 Nov 2022 15:19:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22DEFC4347C; Wed, 23 Nov 2022 15:19:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669216766; bh=8SEmE6N+bA2OulqVdi1G0OFLobfhZaHBH+tpA5cpWDU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FFzNfwscRieaPq6gV8OHYFBn/q4GF0yLCzo+Ih194w/lP8UW5rnhZ1AGaI26p3UF4 Idxb8RKoRS6Hrkvt2kMWDi9PplpbfoM+3yeor0qoapjyLARLpKTaQoKwohRyYfi7eZ Wlh0PWxmFDhQ3EGK/LiTH91SIaOJpW0nxrcx3stMO3Vz/yNoDQHfY1aUlm8eZEcZmn QCUZVsmQCswc4bsCGMqYV/N71DaOQxxcOmbBdG0n1IAJTPnEO3ZhYNW9AG1CGMVhZj 6XuQx8aNxWAeHmj46Ah9SOnmxDJ1YfyenVLoBakB4u8/Ru+IqCzRCjdui1OC2Rn22a bOZHetA5yfhqg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH v2 4/5] kconfig: refactor Makefile to reduce process forks Date: Thu, 24 Nov 2022 00:18:27 +0900 Message-Id: <20221123151828.509565-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221123151828.509565-1-masahiroy@kernel.org> References: <20221123151828.509565-1-masahiroy@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750301009085108841?= X-GMAIL-MSGID: =?utf-8?q?1750301009085108841?= 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 Reviewed-by: Nicolas Schier --- (no changes since v1) 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 Wed Nov 23 15:18:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 25047 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2855404wrr; Wed, 23 Nov 2022 07:25:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf5lG5iT1vKHiC4OtEGuseCtyNfG5PdC/r4WjfcM5Q5Rhzj8mrvF+eWIw0mqnttT5CM2MD+3 X-Received: by 2002:a17:906:60d0:b0:78d:3f87:1725 with SMTP id f16-20020a17090660d000b0078d3f871725mr8198852ejk.492.1669217129556; Wed, 23 Nov 2022 07:25:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669217129; cv=none; d=google.com; s=arc-20160816; b=TBh89MNAIoh/PtnLHLma+UHF/j8H46VWw2F3KYI2LYMSOD424cxC7f7ZP/ickePTfQ M/Bx2W/krTEw/JAoiOLdGUoV1kO12l1D5ossLjpB6Ikkydt9a4MDwOFLLndPj3L5soE5 8N3I6aEzLaiMbAnTmszbElWYD6LFDxXw5HtOm523PruZzzbPqASO154yMwEkvcDtzfH8 WzzlWcHGx3AOnr1kc6FgrRUdJfmeOvVYqut0uRF2En+wButpZXfeVj6WmYwo2l4chjWO bC1EnzyxghzmZtmDjeYH0QSo1r4aNR4vhujrL5fmKGl4glpgZfn/7HxX9iFocav8qZUs PKKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YTXMBgOPNlgcqMhaYtEv4KQRqBIwK6lbzD8+tTGqLTI=; b=avBqG/LqdOIpQ+5aYLN8vONj6PWlDybQm1E/kKSWVOLKqVEImE87k9TJ9Vhd38ILdx lyxmiGi1U7uDnlDhg1H8EhbKw4/FV+TPFAit9H0R6k0WpozsgaLw73UmQp1BZDpn3dkt x4/R3KzDst0HD7lApmgveHxG9rvHbMWZg2H4vJBcNBNrF+Rf0rvwAaxSXG+xUmvHqpqn AsY6ZNcLfIJWYRaTz2f9u6Ge0i4yYI2SrKSW9/UKZETuOaY4j5DBsjm5Uu/InZk+ECuC 59p7xyXhXonoQLRhv978CGRSbuyyojGuvjjd9tXydczVb1S7+qdYJTAF8avuveH5Fc3D 39gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MaWBZskk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs13-20020a170906dc8d00b0078db3ae83d0si11679151ejc.3.2022.11.23.07.25.05; Wed, 23 Nov 2022 07:25:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MaWBZskk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238655AbiKWPTr (ORCPT + 99 others); Wed, 23 Nov 2022 10:19:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238645AbiKWPTj (ORCPT ); Wed, 23 Nov 2022 10:19:39 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF88549B64; Wed, 23 Nov 2022 07:19:30 -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 9A394B8201C; Wed, 23 Nov 2022 15:19:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37EFBC433D6; Wed, 23 Nov 2022 15:19:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669216768; bh=TYgZT0UGUrDb3jnlRqypuUU6uixbw+w0KmXfqkCj/Ww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MaWBZskklIpI/JB9pyv3uj9JVrxpNthVMW9OCVg7JdlrPm9I3l5wStLREBgY7yIDu KseZCUv4wY/W0yY1wOB1ULSvVHI6TANy2oA2l85bV/Oy8FeUMjJtt5Btq696yki63v PZ61+M+vkL35h2ZQURwb6osKWB49ru7xvolIUfH4RRcjnrFB4NGghDLAF901N6C5FI MvsOn7s8b9a6Ni0Uu8Fw1aOYQDcMajS4xVut8GplZhtEzyVvu0BLWTH9pshEQrLISF bZ+voy/9gzYZ+v0GWkUikRJTWKun5uY90RiJpEEh6th86OgHUzUXrtO7A1D+NHpiN7 cyaTUqXthK6Iw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH v2 5/5] kbuild: check Make version Date: Thu, 24 Nov 2022 00:18:28 +0900 Message-Id: <20221123151828.509565-5-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221123151828.509565-1-masahiroy@kernel.org> References: <20221123151828.509565-1-masahiroy@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750301021203227654?= X-GMAIL-MSGID: =?utf-8?q?1750301021203227654?= This is implemented based on test-le. It will work until GNU Make 10 is released. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- (no changes since v1) Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 60ce9dcafc72..797fafbc1b45 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)