From 026f9cf24f3c9d30c47c42bac622a64338caf596 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 5 Mar 2014 16:59:40 +0900 Subject: kbuild: improve Kbuild speed Kbuild brought about many advantages for us but a significant performance regression was reported by Simon Glass. After some discussions and analysis, it turned out its main cause is in $(call cc-option,...). Historically, U-Boot parses all config.mk (arch/*/config.mk and board/*/config.mk) every time descending into subdirectories. That means cc-options are evaluated over and over again. $(call cc-option,...) is useful but costly. So we want to evaluate them only in ./Makefile and spl/Makefile and export compiler flags. This commit changes the build system as follows: - Modify scripts/Makefile.build to not include config.mk Instead, add $(PLATFORM_CPPFLAGS) to asflags-y, ccflags-y, cppflags-y. - Export many variables Going forward, Kbuild will not parse config.mk files when it descends into subdirectories. If we want to set variables in config.mk and use them in subdirectories, they must be exported. This is the list of variables to get exported: PLATFORM_CPPFLAGS CPUDIR BOARDDIR OBJCOPYFLAGS LDFLAGS LDFLAGS_FINAL (used in nand_spl/board/*/*/Makefile) CONFIG_STANDALONE_LOAD_ADDR (used in examples/standalone/Makefile) SYM_PREFIX (used in examples/standalone/Makefile) RELFLAGS (used in examples/standalone/Makefile) - Delete CPPFLAGS This variable has been replaced with PLATFORM_CPPFLAGS - Copy gcclibdir from example/standalone/Makefile to arch/sparc/config.mk The reference in CONFIG_STANDALONE_LOAD_ADDR must be resolved before it is exported. Signed-off-by: Masahiro Yamada Reported-by: Simon Glass Acked-by: Simon Glass Tested-by: Simon Glass [on Sandbox] Tested-by: Stephen Warren [on Tegra] --- config.mk | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'config.mk') diff --git a/config.mk b/config.mk index af25c115cc..4657577f9d 100644 --- a/config.mk +++ b/config.mk @@ -6,11 +6,18 @@ # ######################################################################### -# clean the slate ... -PLATFORM_RELFLAGS = -PLATFORM_CPPFLAGS = -PLATFORM_LDFLAGS = - +# This file is included from ./Makefile and spl/Makefile. +# Clean the state to avoid the same flags added twice. +# +# (Tegra needs different flags for SPL. +# That's the reason why this file must be included from spl/Makefile too. +# If we did not have Tegra SoCs, build system would be much simpler...) +PLATFORM_RELFLAGS := +PLATFORM_CPPFLAGS := +PLATFORM_LDFLAGS := +LDFLAGS := +LDFLAGS_FINAL := +OBJCOPYFLAGS := ######################################################################### # Some architecture config.mk files need to know what CPUDIR is set to, @@ -41,12 +48,17 @@ endif ######################################################################### -RELFLAGS= $(PLATFORM_RELFLAGS) +RELFLAGS := $(PLATFORM_RELFLAGS) OBJCOPYFLAGS += --gap-fill=0xff -CPPFLAGS = $(RELFLAGS) -CPPFLAGS += -pipe $(PLATFORM_CPPFLAGS) +PLATFORM_CPPFLAGS += $(RELFLAGS) +PLATFORM_CPPFLAGS += -pipe LDFLAGS += $(PLATFORM_LDFLAGS) LDFLAGS_FINAL += -Bstatic + +export PLATFORM_CPPFLAGS +export RELFLAGS +export LDFLAGS_FINAL +export CONFIG_STANDALONE_LOAD_ADDR -- cgit v1.2.1