diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2019-03-26 00:02:19 -0400 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2019-03-28 10:46:54 -0400 |
commit | 221cc2d27ddc49b3e06d4637db02bf78e70c573c (patch) | |
tree | 886060b5f3f242cd763c0ea5c00ef80cda597c6f /Makefile | |
parent | 7265f5b72640f43e558af80347c62e32d568371f (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-- | Makefile | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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 | ||
34 | ifneq ($(sub-make-done),1) | 34 | ifneq ($(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)): ; |
156 | endif | 156 | endif |
157 | 157 | ||
158 | export sub_make_done := 1 | ||
159 | |||
158 | ifeq ($(need-sub-make),1) | 160 | ifeq ($(need-sub-make),1) |
159 | 161 | ||
160 | PHONY += $(MAKECMDGOALS) sub-make | 162 | PHONY += $(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 |
166 | sub-make: | 168 | sub-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 | ||
171 | endif # need-sub-make | 173 | endif # need-sub-make |
172 | endif # sub-make-done | 174 | endif # 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 |
175 | ifeq ($(need-sub-make),) | 177 | ifeq ($(need-sub-make),) |