From patchwork Tue Mar 26 04:02:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 161146 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp4739149jan; Mon, 25 Mar 2019 21:03:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCWqciBgUFfK80KtZGKbU3DeswX07ZcNubMfZCvrAAA7gWc7jnUgJntdM4zdKtmgwDKUEF X-Received: by 2002:a17:902:e684:: with SMTP id cn4mr6090427plb.71.1553572999891; Mon, 25 Mar 2019 21:03:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553572999; cv=none; d=google.com; s=arc-20160816; b=Yh9nRnGg6W4jV2yQ4C5iWvA9JVeXPExdUwypCUqONSmpu+d5vxzw/2jP82ELQNsrWO wVY4j/wDFw7VCQZEC1+iPibcsC1xAJ3tVaGXh4yX2KiucDqgRn02mHa5xBhEYawOSLMM vY0/KhLZS7lwICHZotsuAH0S3ubNSRanFQEyD3nouqCQw6FGOQpqTl8S3jqzLZlXMH59 AHBWyBdC9Bb2KgXHOX1zUeHNJtUIZKOzJurb8wCk+JktABB6yPpGZ4lWfpE38NA9IeoK otyMcY4cZgWuXlLYCM22FBbWfD4Jx9KwOXTBBiwrVkr9JC8SesYc7rmm7zrhWhosF+Qk sCQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=oXPMxPTih1gYh2eNNDYBxVlV1zOIAkdO4nQuUMiEzOI=; b=tpZ4/r6r6dEGbgzQ2trC4pw7oK8k0D5biKoMpdzOFN5IXWFGKsZZXSu1vjJYgGTFsI 83P8L1IymH1wSme3LqDN6yMLipvAduDatL81q0/cOnkf98GUoE4HSdHNN+XRO8KBGfRW jEzPbksrs29vI2yqs2tTcFhh03jaVAEPAX44LYPQaRlkQFIgotoJYch891jo0k2hjJaK 9zs3n4hS3G4zNLI90VU2AvLMWvLIQj9jmNzquClUemJiEN9IBYjCCbW0RAqYyvGdsJ5w /nuhBRxeoVn3t2f/gnY2GOEs7HTlGN/aqgg2hly7aCqR49X71TtNFLGyUdIOfvQg7drt B3BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=xuSrWc+9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n4si14626201pgq.198.2019.03.25.21.03.19; Mon, 25 Mar 2019 21:03:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=xuSrWc+9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726258AbfCZEDR (ORCPT + 31 others); Tue, 26 Mar 2019 00:03:17 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:30443 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725298AbfCZEDR (ORCPT ); Tue, 26 Mar 2019 00:03:17 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id x2Q432PC025839; Tue, 26 Mar 2019 13:03:02 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com x2Q432PC025839 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1553572982; bh=oXPMxPTih1gYh2eNNDYBxVlV1zOIAkdO4nQuUMiEzOI=; h=From:To:Cc:Subject:Date:From; b=xuSrWc+9gLR9RhjkYNCOWWIAhJ98RtZW7GyL8vglMiGz0CFeJFmmH27sGwvxF0MBT gWmYbX1RP9Pm3Ajvf7VA64l7YRQZYhSSAXzrBoIflPT4CvDzr5K0wt58ra9Bk748Gv vviBH6nLrx5qa8WT/kmY1Whua2DP6KSsR+3wlatSNO/ULLlmBww2yQXcqmbjRXniov nXddINu3n4qZH8NBJtWRlT37pUantma9cngGXEvC3KzvSsmetxhJL5UJiP51n5VpWQ VhTzM3AZWTNDWeTpO1Gp9sgdg/Z5z2a5IjP/Ph15DN5KIIwQD20V0CtZW3F857e7po RfxlVQTXTWgGw== 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] kbuild: skip parsing pre sub-make code for recursion Date: Tue, 26 Mar 2019 13:02:19 +0900 Message-Id: <1553572939-18940-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When Make recurses to the top Makefile with sub-make-done unset, the code block surrounded by 'ifneq ($(sub-make-done),1) ... endif' is parsed multiple times. This happens for in-tree building of include/config/auto.conf, *-pkg, etc. with GNU Make 4.x. This is a slight regression by commit 688931a5ad4e ("kbuild: skip sub-make for in-tree build with GNU Make 4.x") in terms of performance since that code block contains one $(shell ...) invocation. Fix it by exporting the variable irrespective of sub-make being run. I renamed it because GNU Make cannot properly export variables containing hyphens. This is probably a bug of GNU Make, and the issue in Kbuild had already been reported by commit 2bfbe7881ee0 ("kbuild: Do not use hyphen in exported variable name"). Signed-off-by: Masahiro Yamada --- Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index 41b25b2..5fe5431 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ _all: # descending is started. They are now explicitly listed as the # prepare rule. -ifneq ($(sub-make-done),1) +ifneq ($(sub_make_done),1) # Do not use make's built-in rules and variables # (this increases performance and avoids hard-to-debug behaviour) @@ -155,6 +155,8 @@ need-sub-make := 1 $(lastword $(MAKEFILE_LIST)): ; endif +export sub_make_done := 1 + ifeq ($(need-sub-make),1) PHONY += $(MAKECMDGOALS) sub-make @@ -164,12 +166,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) sub-make-done=1 \ + $(Q)$(MAKE) \ $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \ -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) endif # need-sub-make -endif # sub-make-done +endif # sub_make_done # We process the rest of the Makefile if this is the final invocation of make ifeq ($(need-sub-make),)