Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2837537yba; Mon, 22 Apr 2019 14:00:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKNkVpCXY+ZUbCTkADu84opncxxrzWGzZhHDN78A7THho7vvvPcH8ro6Gtib+r/iJ2OKxY X-Received: by 2002:a63:82c6:: with SMTP id w189mr511496pgd.444.1555966841468; Mon, 22 Apr 2019 14:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555966841; cv=none; d=google.com; s=arc-20160816; b=RWEtuBNLjwuTgmIDyb7Uy8yqMAXafYKu55m/5lzGG1zMZwroXMhDvfr9f0S5+hIhr3 AQulhQnMRYclJMX5sJ8sLM3kikh0CZghW9dUVlM6CsmVfSV4sK67G02sfto5BQp9a8l0 Dyq47k118N6Sh6jnjoHil4Sne9EQYByQOK+lMGOWBY8QmeRJ9gQerL8cELE5f+K+xKjm juyh1dclLCoMNJhtjwGwd4ba0pZptUpG/g0MfDbF0aleemgDVbO80cV0ZNK8Z8FsxGJa HPbgqOYLxJHYdbJ+W/LgJtjVd/aE44M3ZU5fsM9jd5+3qLqwr5xE1iIt+/ZSlIFopkU2 e+YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XNTDk7FGWBSb/jrg5vuOxuxq4g8Y7DE3XHc8aJVeDhQ=; b=tYS8+GZoXl0Wxxq4qtqkRoXyDiQei627fxkU2ZFCZmJsztZhjqF51c2eC4A/oqDYsX JAkdKKcGbiH2m6rbKx/cxmk4XQBElFQB4PGqgXUNkXr0RDjBYp6uvP10uvah/XJ+OaFT aSN3pAuEZetCPkC0kBnx+aVIAMFmvALnbflG28zw6MZucqFILnDaFwbSpuKdprBkpq18 QgjDIsOZPxPNhxq73faR+HxuAfJq0OKWGNYYFEM6gDNHQFzTFN5EjCQwWB6f9Ywvdj1K sRVGDArIfRjmMb+XM2N2T7+TdJ3eU5dwCPLz1U13UG+4fwvbBUWZfTzRfuPvqWQD29z4 4Aog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VFG8Fq5s; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d125si13129775pgc.197.2019.04.22.14.00.26; Mon, 22 Apr 2019 14:00:41 -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=@kernel.org header.s=default header.b=VFG8Fq5s; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729477AbfDVTob (ORCPT + 99 others); Mon, 22 Apr 2019 15:44:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:45570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729461AbfDVTo1 (ORCPT ); Mon, 22 Apr 2019 15:44:27 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ACB67217D4; Mon, 22 Apr 2019 19:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962267; bh=i+JjBN1jzFpFdQR8509H4Spqc+UizChTcAJ1UAAzVoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VFG8Fq5sZNaLiaCqsScOp+irf/p0owdkX8gNjXG959HE+7BlM07es5hoOm4NQRvl+ U++vRMcXXyDYPDPf+ThIO66b/YqZODzwYV4EIUcE6T4kP5mHQjyT/CHqmhzHjQFZis 3xyaOhnPyaJmN5iTRyeIPprxl7+HKef87GD2G9TQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Masahiro Yamada , Sasha Levin , linux-kbuild@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 75/98] kbuild: skip parsing pre sub-make code for recursion Date: Mon, 22 Apr 2019 15:41:42 -0400 Message-Id: <20190422194205.10404-75-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194205.10404-1-sashal@kernel.org> References: <20190422194205.10404-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada [ Upstream commit 221cc2d27ddc49b3e06d4637db02bf78e70c573c ] 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 Signed-off-by: Sasha Levin (Microsoft) --- Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ef192ca04330..ed3ad29d2db7 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) @@ -159,6 +159,8 @@ need-sub-make := 1 $(lastword $(MAKEFILE_LIST)): ; endif +export sub_make_done := 1 + ifeq ($(need-sub-make),1) PHONY += $(MAKECMDGOALS) sub-make @@ -168,12 +170,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),) -- 2.19.1