From patchwork Fri Feb 28 04:27:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 325013 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 5C8F12C0092 for ; Fri, 28 Feb 2014 15:27:58 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D26E84B5BB; Fri, 28 Feb 2014 05:27:56 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U3nLQOq-eXEE; Fri, 28 Feb 2014 05:27:56 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 70ED04B5C6; Fri, 28 Feb 2014 05:27:51 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 200864B579 for ; Fri, 28 Feb 2014 05:27:39 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NEy+uB31nnYN for ; Fri, 28 Feb 2014 05:27:39 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp.mei.co.jp (smtp.mei.co.jp [133.183.100.20]) by theia.denx.de (Postfix) with ESMTP id 4CDB14B174 for ; Fri, 28 Feb 2014 05:27:33 +0100 (CET) Received: from mail-gw.jp.panasonic.com ([157.8.1.157]) by smtp.mei.co.jp (8.12.11.20060614/3.7W/kc-maile12) with ESMTP id s1S4RS4c019980; Fri, 28 Feb 2014 13:27:29 +0900 (JST) Received: from epochmail.jp.panasonic.com ([157.8.1.130]) by mail.jp.panasonic.com (8.11.6p2/3.7W/kc-maili17) with ESMTP id s1S4RT304651; Fri, 28 Feb 2014 13:27:29 +0900 Received: by epochmail.jp.panasonic.com (8.12.11.20060308/3.7W/lomi12) id s1S4RTbF019226; Fri, 28 Feb 2014 13:27:29 +0900 Received: from poodle by lomi12.jp.panasonic.com (8.12.11.20060308/3.7W) with ESMTP id s1S4RSu3019165; Fri, 28 Feb 2014 13:27:28 +0900 Received: from beagle.diag.org (beagle.diag.org [10.184.179.16]) by poodle (Postfix) with ESMTP id CC80A2740043; Fri, 28 Feb 2014 13:27:28 +0900 (JST) From: Masahiro Yamada To: u-boot@lists.denx.de Date: Fri, 28 Feb 2014 13:27:26 +0900 Message-Id: <1393561646-882-5-git-send-email-yamada.m@jp.panasonic.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1393561646-882-1-git-send-email-yamada.m@jp.panasonic.com> References: <1393561646-882-1-git-send-email-yamada.m@jp.panasonic.com> Cc: Tom Rini , Stephen Warren Subject: [U-Boot] [RESEND PATCH v2 4/4] kbuild: improve Kbuild speed X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 Tested-by: Stephen Warren --- Changes in v2: None Makefile | 7 ++++--- arch/blackfin/config.mk | 1 + arch/sparc/config.mk | 2 ++ config.mk | 28 ++++++++++++++++++++-------- examples/standalone/Makefile | 5 ++--- scripts/Makefile.build | 10 +++++----- scripts/Makefile.lib | 7 +++---- spl/Makefile | 7 +++---- 8 files changed, 40 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 56ba1ef..e49a240 100644 --- a/Makefile +++ b/Makefile @@ -358,13 +358,13 @@ UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null) UBOOTVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) export VERSION PATCHLEVEL SUBLEVEL UBOOTRELEASE UBOOTVERSION -export ARCH CPU BOARD VENDOR SOC +export ARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIR export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC export CPP AR NM LDR STRIP OBJCOPY OBJDUMP export MAKE AWK export DTC CHECK CHECKFLAGS -export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE +export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE OBJCOPYFLAGS LDFLAGS export KBUILD_CFLAGS KBUILD_AFLAGS # When compiling out-of-tree modules, put MODVERDIR in the module @@ -567,7 +567,8 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) CHECKFLAGS += $(NOSTDINC_FLAGS) # FIX ME -cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS) +cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \ + $(NOSTDINC_FLAGS) c_flags := $(KBUILD_CFLAGS) $(cpp_flags) ######################################################################### diff --git a/arch/blackfin/config.mk b/arch/blackfin/config.mk index c752025..8510e1c 100644 --- a/arch/blackfin/config.mk +++ b/arch/blackfin/config.mk @@ -41,6 +41,7 @@ CREATE_LDR_ENV = endif SYM_PREFIX = _ +export SYM_PREFIX LDR_FLAGS-y := LDR_FLAGS-$(CONFIG_BFIN_BOOTROM_USES_EVT1) += -J diff --git a/arch/sparc/config.mk b/arch/sparc/config.mk index 154d00e..7daf4ef 100644 --- a/arch/sparc/config.mk +++ b/arch/sparc/config.mk @@ -7,6 +7,8 @@ CROSS_COMPILE ?= sparc-elf- +gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`) + CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000 -L $(gcclibdir) \ -T $(srctree)/examples/standalone/sparc.lds diff --git a/config.mk b/config.mk index e59697f..bb3da0d 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, @@ -39,12 +46,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 diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile index 5b227cd..7e0e5b7 100644 --- a/examples/standalone/Makefile +++ b/examples/standalone/Makefile @@ -44,9 +44,8 @@ gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`) # relocatable executable. The relocation data is not needed, and # also causes the entry point of the standalone application to be # inconsistent. -ifeq ($(ARCH),powerpc) -# FIX ME -CPPFLAGS := $(filter-out $(RELFLAGS), $(CPPFLAGS)) +ifeq ($(CONFIG_PPC),y) +PLATFORM_CPPFLAGS := $(filter-out $(RELFLAGS),$(PLATFORM_CPPFLAGS)) endif # We don't want gcc reordering functions if possible. This ensures that an diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 59361f4..36346fd 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -55,11 +55,6 @@ endif include scripts/Kbuild.include -# Added for U-Boot -# We must include config.mk after Kbuild.include -# so that some config.mk can use cc-option. -include config.mk - # For backward compatibility check that these variables do not change save-cflags := $(CFLAGS) @@ -68,6 +63,11 @@ kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) include $(kbuild-file) +# Added for U-Boot +asflags-y += $(PLATFORM_CPPFLAGS) +ccflags-y += $(PLATFORM_CPPFLAGS) +cppflags-y += $(PLATFORM_CPPFLAGS) + # If the save-* variables changed error out ifeq ($(KBUILD_NOPEDANTIC),) ifneq ("$(save-cflags)","$(CFLAGS)") diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 02b17b1..d568fde 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -101,13 +101,12 @@ basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" modname_flags = $(if $(filter 1,$(words $(modname))),\ -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") -# U-Boot also uses $(CPPFLAGS) -orig_c_flags = $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ +orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ $(ccflags-y) $(CFLAGS_$(basetarget).o) _c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) -_a_flags = $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \ +_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \ $(asflags-y) $(AFLAGS_$(basetarget).o) -_cpp_flags = $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F)) +_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F)) # # Enable gcov profiling flags for a file, directory or for all files depending diff --git a/spl/Makefile b/spl/Makefile index e1a0601..781abf6 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -51,7 +51,9 @@ endif include $(TOPDIR)/config.mk # FIX ME -c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS) +cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \ + $(NOSTDINC_FLAGS) +c_flags := $(KBUILD_CFLAGS) $(cpp_flags) # Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL) quiet_cmd_autoconf = GEN $@ @@ -228,9 +230,6 @@ PHONY += $(u-boot-spl-dirs) $(u-boot-spl-dirs): $(Q)$(MAKE) $(build)=$@ -# FIX ME -cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS) - quiet_cmd_cpp_lds = LDS $@ cmd_cpp_lds = $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ \ -x assembler-with-cpp -P -o $@ $<