summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2019-03-26 00:02:19 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2019-03-28 10:46:54 -0400
commit221cc2d27ddc49b3e06d4637db02bf78e70c573c (patch)
tree886060b5f3f242cd763c0ea5c00ef80cda597c6f /Makefile
parent7265f5b72640f43e558af80347c62e32d568371f (diff)
kbuild: skip parsing pre sub-make code for recursion
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 <yamada.masahiro@socionext.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile8
1 files changed, 5 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 6c0635f69982..3c788a65d652 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,7 @@ _all:
31# descending is started. They are now explicitly listed as the 31# descending is started. They are now explicitly listed as the
32# prepare rule. 32# prepare rule.
33 33
34ifneq ($(sub-make-done),1) 34ifneq ($(sub_make_done),1)
35 35
36# Do not use make's built-in rules and variables 36# Do not use make's built-in rules and variables
37# (this increases performance and avoids hard-to-debug behaviour) 37# (this increases performance and avoids hard-to-debug behaviour)
@@ -155,6 +155,8 @@ need-sub-make := 1
155$(lastword $(MAKEFILE_LIST)): ; 155$(lastword $(MAKEFILE_LIST)): ;
156endif 156endif
157 157
158export sub_make_done := 1
159
158ifeq ($(need-sub-make),1) 160ifeq ($(need-sub-make),1)
159 161
160PHONY += $(MAKECMDGOALS) sub-make 162PHONY += $(MAKECMDGOALS) sub-make
@@ -164,12 +166,12 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
164 166
165# Invoke a second make in the output directory, passing relevant variables 167# Invoke a second make in the output directory, passing relevant variables
166sub-make: 168sub-make:
167 $(Q)$(MAKE) sub-make-done=1 \ 169 $(Q)$(MAKE) \
168 $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \ 170 $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \
169 -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) 171 -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
170 172
171endif # need-sub-make 173endif # need-sub-make
172endif # sub-make-done 174endif # sub_make_done
173 175
174# We process the rest of the Makefile if this is the final invocation of make 176# We process the rest of the Makefile if this is the final invocation of make
175ifeq ($(need-sub-make),) 177ifeq ($(need-sub-make),)