From patchwork Fri Feb 22 07:40:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10825365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39B0317E9 for ; Fri, 22 Feb 2019 07:40:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 297D730F09 for ; Fri, 22 Feb 2019 07:40:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D9FD31094; Fri, 22 Feb 2019 07:40:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87ACB30F09 for ; Fri, 22 Feb 2019 07:40:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726362AbfBVHkW (ORCPT ); Fri, 22 Feb 2019 02:40:22 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:53328 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726298AbfBVHkW (ORCPT ); Fri, 22 Feb 2019 02:40:22 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1M7eEN0013122; Fri, 22 Feb 2019 16:40:14 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1M7eEN0013122 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550821214; bh=DQ+BN3fwZB03g2y4k35iROrRq0d7oQO8BBS0JgSdlB0=; h=From:To:Cc:Subject:Date:From; b=oDBbG5lrr/abbSDWjIP9610qGqd5cIRV7P8tuLxOrYoqsXVBmgGqJLO293TFf8uWr OTlkUAW2LXdMy5iqu7Fsd2tBfGB8s0kNYZ2IE78y1HrtteOLLE9H7gypV/3jduILhN 1DVpkBa3+eU4pM+oLBx7M3WvnjdFWdsKQxrhywOut8I5//SUzKbjCJOkwflAuCDQm3 u/JUAAW6xywYA50BXNolHXbCNqH6Erkpf7GJninlo1jUqlPnzMuhRLK8HQuSsX05BQ OCYyB6Qjp6k+5gRCcLd/yOpmID38SeJ7yp6klTbt9Q1iF4k3Pe+GLuoW9ChbiRBOdH /VKS1mIQsIJIw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] kbuild: move tools_silent to a more relevant place Date: Fri, 22 Feb 2019 16:40:06 +0900 Message-Id: <1550821211-30324-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This would disturb the change the sub-make part. Move it near the tools/ target. Signed-off-by: Masahiro Yamada --- Changes in v2: None Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bf4e77b..82091b8 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,6 @@ endif ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) quiet=silent_ - tools_silent=s endif export quiet Q KBUILD_VERBOSE @@ -1678,6 +1677,11 @@ image_name: @echo $(KBUILD_IMAGE) # Clear a bunch of variables before executing the submake + +ifeq ($(quiet),silent_) +tools_silent=s +endif + tools/: FORCE $(Q)mkdir -p $(objtree)/tools $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/ From patchwork Fri Feb 22 07:40:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10825369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E1D717E9 for ; Fri, 22 Feb 2019 07:40:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C90C3108B for ; Fri, 22 Feb 2019 07:40:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 114C131096; Fri, 22 Feb 2019 07:40:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AE313108B for ; Fri, 22 Feb 2019 07:40:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726527AbfBVHkX (ORCPT ); Fri, 22 Feb 2019 02:40:23 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:53325 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725821AbfBVHkW (ORCPT ); Fri, 22 Feb 2019 02:40:22 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1M7eEN1013122; Fri, 22 Feb 2019 16:40:15 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1M7eEN1013122 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550821215; bh=ShLhb3WIzeeB+W+Duw3DHWEdsX60HCOwaHOO2R3ie0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qJcl0Md10oQcoXayGlWXNY+W8O17qfDDowqRNY21BFSSaJW1JNH/kZ4PnY+mjDwMy 6ho86dwoE6PzWBTMmChQaNCGhTuKzMOqYk0MjoOBtOTJKCkp+jsy7JzQJXSSIrZV3X p+RJj/+mqn7jnCdLUKsiTbCSxIajc/hggYCWsJltvw+NvBZxtO9buY5Q3U47RmLs9E KUtXSAm3Bmb3UVFmDn6LVtw9jtamhd0DrV/TewFR4e4jFF8TpVOCqa8zz06CpUqxSo oZt2vv+CirwZl50AIpUup0UWy+lAkkmsf/qOA8cTg1wJYJwsd/KIa4NrZOgAforUD7 qHVoAmczjamNw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] kbuild: make -r/-R effective in top Makefile for old Make versions Date: Fri, 22 Feb 2019 16:40:07 +0900 Message-Id: <1550821211-30324-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550821211-30324-1-git-send-email-yamada.masahiro@socionext.com> References: <1550821211-30324-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adding -rR to MAKEFLAGS is important because we do not want to be bothered by built-in implicit rules or variables. One problem that used to exist in older GNU Make versions is MAKEFLAGS += -rR ... does not become effective in the current Makefile. When you are building with O= option, it becomes effective in the top Makefile since it recurses via 'sub-make' target. Otherwise, the top Makefile tries implicit rules. That is why we explicitly add empty rules for Makefiles, but we often miss to do that. In fact, adding -d option to older GNU Make versions shows it is trying a bunch of implicit pattern rules. Considering target file `scripts/Makefile.kcov'. Looking for an implicit rule for `scripts/Makefile.kcov'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.o'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.c'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.cc'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.C'. ... This issue was fixed by GNU Make commit 58dae243526b ("[Savannah #20501] Handle adding -r/-R to MAKEFLAGS in the makefile"). So, it is no longer a problem if you use GNU Make 4.0 or later. However, older versions are still widely used. So, I decided to patch the kernel Makefile to invoke sub-make regardless of O= option. This will allow further cleanups. Signed-off-by: Masahiro Yamada --- Changes in v2: - Rename KBUILD_SUBMAKE to sub-make-done Makefile | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 82091b8..f0bc078 100644 --- a/Makefile +++ b/Makefile @@ -15,19 +15,6 @@ NAME = Shy Crocodile PHONY := _all _all: -# Do not use make's built-in rules and variables -# (this increases performance and avoids hard-to-debug behaviour) -MAKEFLAGS += -rR - -# Avoid funny character set dependencies -unexport LC_ALL -LC_COLLATE=C -LC_NUMERIC=C -export LC_COLLATE LC_NUMERIC - -# Avoid interference with shell env settings -unexport GREP_OPTIONS - # We are using a recursive build, so we need to do a little thinking # to get the ordering right. # @@ -44,6 +31,21 @@ unexport GREP_OPTIONS # descending is started. They are now explicitly listed as the # prepare rule. +ifneq ($(sub-make-done),1) + +# Do not use make's built-in rules and variables +# (this increases performance and avoids hard-to-debug behaviour) +MAKEFLAGS += -rR + +# Avoid funny character set dependencies +unexport LC_ALL +LC_COLLATE=C +LC_NUMERIC=C +export LC_COLLATE LC_NUMERIC + +# Avoid interference with shell env settings +unexport GREP_OPTIONS + # Beautify output # --------------------------------------------------------------------------- # @@ -111,7 +113,6 @@ export quiet Q KBUILD_VERBOSE # KBUILD_SRC is not intended to be used by the regular user (for now), # it is set on invocation of make with KBUILD_OUTPUT or O= specified. -ifeq ($(KBUILD_SRC),) # OK, Make called in directory where kernel src resides # Do we want to locate output files in a separate directory? @@ -141,6 +142,13 @@ $(if $(KBUILD_OUTPUT),, \ # 'sub-make' below. MAKEFLAGS += --include-dir=$(CURDIR) +else + +# Do not print "Entering directory ..." at all for in-tree build. +MAKEFLAGS += --no-print-directory + +endif # ifneq ($(KBUILD_OUTPUT),) + PHONY += $(MAKECMDGOALS) sub-make $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make @@ -148,16 +156,12 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make # Invoke a second make in the output directory, passing relevant variables sub-make: - $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ + $(Q)$(MAKE) sub-make-done=1 \ + $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \ -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) -# Leave processing to above invocation of make -skip-makefile := 1 -endif # ifneq ($(KBUILD_OUTPUT),) -endif # ifeq ($(KBUILD_SRC),) - +else # sub-make-done # We process the rest of the Makefile if this is the final invocation of make -ifeq ($(skip-makefile),) # Do not print "Entering directory ...", # but we want to display it when entering to the output directory @@ -1766,7 +1770,7 @@ $(cmd_files): ; # Do not try to update included dependency files endif # ifeq ($(config-targets),1) endif # ifeq ($(mixed-targets),1) -endif # skip-makefile +endif # sub-make-done PHONY += FORCE FORCE: From patchwork Fri Feb 22 07:40:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10825367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFC591823 for ; Fri, 22 Feb 2019 07:40:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0F4231094 for ; Fri, 22 Feb 2019 07:40:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B556831095; Fri, 22 Feb 2019 07:40:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B93F30F09 for ; Fri, 22 Feb 2019 07:40:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726298AbfBVHkX (ORCPT ); Fri, 22 Feb 2019 02:40:23 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:53327 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726303AbfBVHkW (ORCPT ); Fri, 22 Feb 2019 02:40:22 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1M7eEN2013122; Fri, 22 Feb 2019 16:40:15 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1M7eEN2013122 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550821215; bh=gzAGp20lwx555N74OLIUjuRuDhy6lpNK2qNzq0MFvi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mLdftSA6BczwG736OYyqiMv635Fnywbaz4TPoqU8CLsCGYGv+ghTJqnGKkXjkJU7L FCVVeWFuqSNWcnb5JKx0q//jwGesIQql1OnQuoHTovEh1hQow2WqaQOpxojidwpb2R mPWjpkidmDRZNVLEtlcnEQHoLl2YdnclkAdRh6/eJkbU/D/GRuRoGagmHyDAH4p8Xg v8G58xYD1jhvdQyqjP+6FaWzmxEwk9ro+FkMT+PDQcRfrlTiMOB08Jiktk7M42H12+ bJnOOCERgCzAW3P9C7Yy/Y5bHMjqgkd/VR1UD+mwQaQmEO/DLEvUFguyirnferBg4e mk7eyvEWrVUeg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/6] kbuild: remove empty rules for makefiles Date: Fri, 22 Feb 2019 16:40:08 +0900 Message-Id: <1550821211-30324-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550821211-30324-1-git-send-email-yamada.masahiro@socionext.com> References: <1550821211-30324-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The previous commit made 'MAKEFLAGS += -rR' effective in the top Makefile regardless of O= option, GNU Make versions. The top Makefile does not need to cancel implicit rules for makefiles. There is still one place where an empty rule is useful. Since -rR is effective only after sub-make, GNU Make would try implicit rules to update the top Makefile. Although it is not a big overhead, cancel it just in case. Signed-off-by: Masahiro Yamada --- Changes in v2: - Revive empty rule for $(KCONFIG_CONFIG) include/config/auto.conf.cmd Makefile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index f0bc078..538a4f1 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,10 @@ ifneq ($(sub-make-done),1) # (this increases performance and avoids hard-to-debug behaviour) MAKEFLAGS += -rR +# 'MAKEFLAGS += -rR' does not become immediately effective for old +# GNU Make versions. Cancel implicit rules for this Makefile. +$(lastword $(MAKEFILE_LIST)): ; + # Avoid funny character set dependencies unexport LC_ALL LC_COLLATE=C @@ -120,9 +124,6 @@ ifeq ("$(origin O)", "command line") KBUILD_OUTPUT := $(O) endif -# Cancel implicit rules on top Makefile -$(CURDIR)/Makefile Makefile: ; - ifneq ($(words $(subst :, ,$(CURDIR))), 1) $(error main directory cannot contain spaces nor colons) endif @@ -303,8 +304,6 @@ __build_one_by_one: else -# We need some generic definitions (do not try to remake the file). -scripts/Kbuild.include: ; include scripts/Kbuild.include # Read KERNELRELEASE from include/config/kernel.release (if it exists) @@ -1764,9 +1763,7 @@ cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ # read saved command lines for existing targets existing-targets := $(wildcard $(sort $(targets))) -cmd_files := $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) -$(cmd_files): ; # Do not try to update included dependency files --include $(cmd_files) +-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) endif # ifeq ($(config-targets),1) endif # ifeq ($(mixed-targets),1) From patchwork Fri Feb 22 07:40:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10825375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 065A81805 for ; Fri, 22 Feb 2019 07:40:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E63BF311B1 for ; Fri, 22 Feb 2019 07:40:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9616311CD; Fri, 22 Feb 2019 07:40:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CE46311B1 for ; Fri, 22 Feb 2019 07:40:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725889AbfBVHkm (ORCPT ); Fri, 22 Feb 2019 02:40:42 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:53323 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725894AbfBVHkW (ORCPT ); Fri, 22 Feb 2019 02:40:22 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1M7eEN3013122; Fri, 22 Feb 2019 16:40:16 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1M7eEN3013122 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550821216; bh=UcWNwsux7b1JpeJdXT16j2ZgXx6alk2fUysrOhB9agQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d1VCRaOUNPYV1EmPwqZ2gKCkt7j4bSA6poEYuGWUcvxPOg9a+Igydih6CmYtl/T12 /tAUcE1p6hv3o6AZBCecFoy2oG/HRE2uIt1QIXrXYZVHBw3vNs+zAxhgArylt4GJFd wp92HZ9Ju5ph5ZYc/FIRKzcnnF3EzJT3RZm1hAAEM6krFIyUb0Soqv1iDk5cU6TeU2 Ny8X4wV3Jo9zIQ+nIiPRosnZQtFZOBLUj2R46SEl8eRM8qcylSG9XiJ+8d3NOft8X5 167HDIJLYNsmVJrMN8A27kLRQvdNHZLuaawYY2+3DepfmBCFx7vD4Ks3dUvCAQAXyN rqLZ1JLb8/mSA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] kbuild: simplify single target rules Date: Fri, 22 Feb 2019 16:40:09 +0900 Message-Id: <1550821211-30324-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550821211-30324-1-git-send-email-yamada.masahiro@socionext.com> References: <1550821211-30324-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The dependency will be checked anyway after Kbuild descends into a sub-directory. Skip object/source dependency checks in top Makefile. VPATH can be simpler since the top Makefile no longer checks the presence of the source file, which is located in in the external module directory. One good thing is, it can compile an object from a generated source file. $ make crypto/rsapubkey.asn1.o ... ASN.1 crypto/rsapubkey.asn1.c CC crypto/rsapubkey.asn1.o Signed-off-by: Masahiro Yamada --- Changes in v2: - Do not merge pattern rules Makefile | 47 ++++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 538a4f1..4d8516e 100644 --- a/Makefile +++ b/Makefile @@ -219,7 +219,7 @@ objtree := . src := $(srctree) obj := $(objtree) -VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) +VPATH := $(srctree) export srctree objtree VPATH @@ -1703,31 +1703,23 @@ tools/%: FORCE # target-dir => where to store outputfile # build-dir => directory in kernel source tree to use -ifeq ($(KBUILD_EXTMOD),) - build-dir = $(patsubst %/,%,$(dir $@)) - target-dir = $(dir $@) -else - zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) - build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) - target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) -endif - -%.s: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.i: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.o: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.lst: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.s: %.S prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.o: %.S prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.symtypes: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.ll: %.c prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +build-target = $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD)/)$@ +build-dir = $(patsubst %/,%,$(dir $(build-target))) + +%.i: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.ll: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.lst: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.o: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.s: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.symtypes: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.ko: %.o + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost # Modules PHONY += / @@ -1737,9 +1729,6 @@ PHONY += / Documentation/ samples/: headers_install %/: prepare FORCE $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) -%.ko: prepare FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(@:.ko=.o) - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost # FIXME Should go into a make.lib or something # =========================================================================== From patchwork Fri Feb 22 07:40:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10825371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 555951805 for ; Fri, 22 Feb 2019 07:40:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4559A30F09 for ; Fri, 22 Feb 2019 07:40:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39F3931095; Fri, 22 Feb 2019 07:40:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAC0330F09 for ; Fri, 22 Feb 2019 07:40:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726360AbfBVHkX (ORCPT ); Fri, 22 Feb 2019 02:40:23 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:53324 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726313AbfBVHkW (ORCPT ); Fri, 22 Feb 2019 02:40:22 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1M7eEN4013122; Fri, 22 Feb 2019 16:40:16 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1M7eEN4013122 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550821216; bh=EjgNKSfh8xtmbNhOrnDsrTe+nk2utBj1sqPU76jQ+JE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W8QRvm5GYUfOTZqBxI0sxCTeKRFOZD7FIl/LKktPFs0LMO6yAuN2DDcfOnWbiO8gc 1n61jmAREu/7s5KsjKMyHrflanVNicsNDYf4nd3ejg+TmccySK3AmGKqxZPXPwevpo 9SUNvxg1ZnMfBe/KI2annVsQNThjCqSIC21+jKLMcnqgzKxmgmWpy2kPjQFPEcEjTu UC9+g1230GZpqzKVqWLqv5yKBNmT8/+8hwsFANpkSR3lT2z9NtJueDWCiys+Kh0z1Y XqjZRBuVWzY0SMQ/JnrSKNgVcJEva/JUHxHrz6nY5nf53yxFw3fBdQi8SM51W8t//G MPWXuduUhqSng== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v2 5/6] kbuild: invoke syncconfig if include/config/auto.conf.cmd is missing Date: Fri, 22 Feb 2019 16:40:10 +0900 Message-Id: <1550821211-30324-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550821211-30324-1-git-send-email-yamada.masahiro@socionext.com> References: <1550821211-30324-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If include/config/auto.conf.cmd is lost for some reasons, it is not self-healing, so the top Makefile misses to run syncconfig. Move include/config/auto.conf.cmd to the target side. I used a pattern rule instead of a normal rule here although it is a bit gross. If the rule were written with a normal rule like this, include/config/auto.conf \ include/config/auto.conf.cmd \ include/config/tristate.conf: $(KCONFIG_CONFIG) $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig ... syncconfig would be executed per target. Using a pattern rule makes sure that syncconfig is executed just once because Make assumes the recipe will create all of the targets. Here is a quote from the GNU Make manual [1]: "Pattern rules may have more than one target. Unlike normal rules, this does not act as many different rules with the same prerequisites and recipe. If a pattern rule has multiple targets, make knows that the rule's recipe is responsible for making all of the targets. The recipe is executed only once to make all the targets. When searching for a pattern rule to match a target, the target patterns of a rule other than the one that matches the target in need of a rule are incidental: make worries only about giving a recipe and prerequisites to the file presently in question. However, when this file's recipe is run, the other targets are marked as having been updated themselves." [1]: https://www.gnu.org/software/make/manual/html_node/Pattern-Intro.html Signed-off-by: Masahiro Yamada --- Changes in v2: - New patch Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4d8516e..aa9ff68 100644 --- a/Makefile +++ b/Makefile @@ -629,12 +629,17 @@ ifeq ($(may-sync-config),1) -include include/config/auto.conf.cmd # To avoid any implicit rule to kick in, define an empty command -$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; +$(KCONFIG_CONFIG): ; # The actual configuration files used during the build are stored in # include/generated/ and include/config/. Update them if .config is newer than # include/config/auto.conf (which mirrors .config). -include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd +# +# This exploits the 'multi-target pattern rule' trick. +# The syncconfig should be executed only once to make all the targets. +include/config/auto.% \ +include/config/auto.%.cmd \ +include/config/tristate.%: $(KCONFIG_CONFIG) $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig else # External modules and some install targets need include/generated/autoconf.h From patchwork Fri Feb 22 07:40:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10825373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7AF47184E for ; Fri, 22 Feb 2019 07:40:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AF2E30F09 for ; Fri, 22 Feb 2019 07:40:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F9B33108B; Fri, 22 Feb 2019 07:40:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6C9F31094 for ; Fri, 22 Feb 2019 07:40:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726555AbfBVHkX (ORCPT ); Fri, 22 Feb 2019 02:40:23 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:53326 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725944AbfBVHkW (ORCPT ); Fri, 22 Feb 2019 02:40:22 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x1M7eEN5013122; Fri, 22 Feb 2019 16:40:17 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x1M7eEN5013122 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550821217; bh=bMNe7A0okspALkFQtHY95z2jxYuEKE/+Qu2TtqR/cjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bZ45tHyAiCDn0ZbSCd2ozaFFwvONyLP/yPcxp8Ift+vGhhLkCmnbZTsCaMR4E/m1e Au6K4v4peI6k1ylEtMhZF5DX8L8aRfvuoTulxSDv+IR1ZEI9fri9l7/UB9XsdYNbht eiOq6fs/q7woZuKI1hcnQE9DUN8qJ71SARehfFV+YvCXf2PJDaKw8IZ+NW1N7hw9Wt KKi7RAgi8hTiTPrmINfLaASAC4Jr7aobJ8kcoHYXEMy167/kZngPT6sUytmJN+Bk66 dRof6yoTQC7MWH4WtuDMvFQThYVgEgJTJ74s3vFttUZckyBZQotL7rroQHJMTe/8zi c5Hn3zBODqdsA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v2 6/6] kbuild: move ".config not found!" message from Kconfig to Makefile Date: Fri, 22 Feb 2019 16:40:11 +0900 Message-Id: <1550821211-30324-6-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550821211-30324-1-git-send-email-yamada.masahiro@socionext.com> References: <1550821211-30324-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If you run "make" in a pristine source tree, currently Kbuild will start to build Kconfig to let it show the error message. It would be more straightforward to check it in Makefile and let it fail immediately. Signed-off-by: Masahiro Yamada --- Changes in v2: - New patch Makefile | 10 ++++++++-- scripts/kconfig/conf.c | 13 ------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index aa9ff68..84034c5 100644 --- a/Makefile +++ b/Makefile @@ -628,8 +628,14 @@ ifeq ($(may-sync-config),1) # because some architectures define CROSS_COMPILE there. -include include/config/auto.conf.cmd -# To avoid any implicit rule to kick in, define an empty command -$(KCONFIG_CONFIG): ; +$(KCONFIG_CONFIG): + @echo >&2 '***' + @echo >&2 '*** Configuration file "$@" not found!' + @echo >&2 '***' + @echo >&2 '*** Please run some configurator (e.g. "make oldconfig" or' + @echo >&2 '*** "make menuconfig" or "make xconfig").' + @echo >&2 '***' + @/bin/false # The actual configuration files used during the build are stored in # include/generated/ and include/config/. Update them if .config is newer than diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index da89ef7..ef3678c 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -488,7 +488,6 @@ int main(int ac, char **av) const char *progname = av[0]; int opt; const char *name, *defconfig_file = NULL /* gcc uninit */; - struct stat tmpstat; int no_conf_write = 0; tty_stdio = isatty(0) && isatty(1); @@ -560,18 +559,6 @@ int main(int ac, char **av) name = av[optind]; conf_parse(name); //zconfdump(stdout); - if (sync_kconfig) { - name = conf_get_configname(); - if (stat(name, &tmpstat)) { - fprintf(stderr, "***\n" - "*** Configuration file \"%s\" not found!\n" - "***\n" - "*** Please run some configurator (e.g. \"make oldconfig\" or\n" - "*** \"make menuconfig\" or \"make xconfig\").\n" - "***\n", name); - exit(1); - } - } switch (input_mode) { case defconfig: