From patchwork Thu Apr 16 04:38:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 1271484 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.a=rsa-sha256 header.s=dec2015msa header.b=bDo5ubv4; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 492mjF3cQCz9sPF for ; Thu, 16 Apr 2020 14:39:42 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0994A804D5; Thu, 16 Apr 2020 06:39:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="bDo5ubv4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BAA06819AB; Thu, 16 Apr 2020 06:39:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 738A9804D5 for ; Thu, 16 Apr 2020 06:39:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=masahiroy@kernel.org Received: from oscar.flets-west.jp (softbank060142179096.bbtec.net [60.142.179.96]) (authenticated) by conuserg-08.nifty.com with ESMTP id 03G4cUkO008921; Thu, 16 Apr 2020 13:38:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 03G4cUkO008921 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1587011912; bh=63mkiu/omPkB0Rzwx1zy+WnMcbM9iXfw8YhJtrQuGcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bDo5ubv4VMv2PU8EHtKHQVSt05EiWZL33SZQNJcRH+hLjN8M5bsktV5QEbI1p/F1C nG01ZmlLKVbORtPpFIPVD/RSZUhKitMugCkSew68p7BhynD3YsuGkzwkG17WXm6Mw3 Z8dDnafgoJHJ9OSKQPAiBUW61RyR5tH4Wi5WHMUWdoj5cFPBNdLYCBB1rPLZ5BsJSL ZiE7yWC4/VLNqvGY4JxKb2MaD2XOmUb2DuJFZFdSE36h0Zvws9YpoIUiSNq8V3POpd yvCQ4fz5Zk8dIBduc1BNVVGRRIkQe056jUJJFEX1juD1ZNQ5FrYpv5RLXbMKYRqH2b B8WJ6xSnin0MQ== X-Nifty-SrcIP: [60.142.179.96] From: Masahiro Yamada To: u-boot@lists.denx.de Cc: Bin Meng , Masahiro Yamada , Heiko Stuebner , Kever Yang , Simon Glass , Vignesh Raghavendra Subject: [PATCH 1/3] kbuild: add FORCE to dependency of $(obj)/dts/dt-platdata.o Date: Thu, 16 Apr 2020 13:38:24 +0900 Message-Id: <20200416043826.490120-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200416043826.490120-1-masahiroy@kernel.org> References: <20200416043826.490120-1-masahiroy@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean if_changed must have FORCE as a prerequisite. Add $(obj)/dts/dt-platdata.o to 'targets' so that the corresponding .cmd file is included. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- scripts/Makefile.spl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index 314b02ba07..98c04bbbfc 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -307,10 +307,11 @@ quiet_cmd_dtoch = DTOC H $@ cmd_dtoch = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ struct quiet_cmd_plat = PLAT $@ -cmd_plat = $(CC) $(c_flags) -c $< -o $@ +cmd_plat = $(CC) $(c_flags) -c $< -o $(filter-out $(PHONY),$@) +targets += $(obj)/dts/dt-platdata.o $(obj)/dts/dt-platdata.o: $(obj)/dts/dt-platdata.c \ - include/generated/dt-structs-gen.h + include/generated/dt-structs-gen.h FORCE $(call if_changed,plat) PHONY += dts_dir From patchwork Thu Apr 16 04:38:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 1271487 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.a=rsa-sha256 header.s=dec2015msa header.b=tUtHMNK+; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 492mjn0Gmfz9sPF for ; Thu, 16 Apr 2020 14:40:12 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 91FAB819BA; Thu, 16 Apr 2020 06:39:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="tUtHMNK+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9CC8681A05; Thu, 16 Apr 2020 06:39:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 75EA0819E3 for ; Thu, 16 Apr 2020 06:39:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=masahiroy@kernel.org Received: from oscar.flets-west.jp (softbank060142179096.bbtec.net [60.142.179.96]) (authenticated) by conuserg-08.nifty.com with ESMTP id 03G4cUkP008921; Thu, 16 Apr 2020 13:38:32 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 03G4cUkP008921 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1587011913; bh=9LDvfGub2M0Jdv+zQmfvCnbo4p8jV6RbSh45rjx/R4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tUtHMNK+W/SHl5u9mc64FtflS0zS+IOL36WGXGjjg18blwCqQxPadPTUaiuFiBivM lgDRsj5M1d/uoPaCBUOKsNePXpWaY4/83EaybGjzmitBNRkMBsr6U/SJSOL7cxdC1p AUF+0Q/mRHBW2Vo09EYENFV/h0+jgk4boXmp5GqIrvXADXMLJqNpnxFGn/2No8jqCR 2v7UFOFuLUqy+iMkLXHfDZAParKCR38TkI4fI6U0Mi+RUMHmcd2h+gPKb04WhKU5cO W72U6x5qy2GbCSmJcrVltkgrWh+GfkPy49lzjANnzUSQFUjjopyrn0puTynBMLB7bM bP1SChwBM6Hmg== X-Nifty-SrcIP: [60.142.179.96] From: Masahiro Yamada To: u-boot@lists.denx.de Cc: Bin Meng , Masahiro Yamada , AKASHI Takahiro , Anatolij Gustschin , Fabio Estevam , Heinrich Schuchardt , Jagan Teki , Jean-Jacques Hiblot , Kever Yang , Simon Glass Subject: [PATCH 2/3] kbuild: cherry-pick kbuild changes from Linux Date: Thu, 16 Apr 2020 13:38:25 +0900 Message-Id: <20200416043826.490120-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200416043826.490120-1-masahiroy@kernel.org> References: <20200416043826.490120-1-masahiroy@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Import the following commits from Linux. They are mostly nice cleanups. b42841b7bb62 kbuild: Get rid of KBUILD_STR ebf003f0cfb3 kbuild: Consolidate header generation from ASM offset information 2982c953570b kbuild: remove redundant $(wildcard ...) for cmd_files calculation 8a78756eb545 kbuild: create object directories simpler and faster 4d4b5c2e3b6e treewide: remove explicit rules for *offsets.s 01d509a48b46 kbuild: remove unimportant comments from ./Kbuild Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass Tested-by: Simon Glass --- Kbuild | 45 +++--------------------------------------- Makefile | 3 +-- scripts/Makefile.build | 18 +++++------------ scripts/Makefile.host | 12 ----------- scripts/Makefile.lib | 42 ++++++++++++++++++++++++++++++--------- 5 files changed, 42 insertions(+), 78 deletions(-) diff --git a/Kbuild b/Kbuild index e2e3b2995f..6014f7c34a 100644 --- a/Kbuild +++ b/Kbuild @@ -1,54 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0 # # Kbuild for top-level directory of U-Boot -# This file takes care of the following: -# 1) Generate generic-asm-offsets.h -# 2) Generate asm-offsets.h - -# Default sed regexp - multiline due to syntax constraints -define sed-y - "s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; \ - /^->/{s:->#\(.*\):/* \1 */:; \ - s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ - s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ - s:->::; p;}" -endef - -# Use filechk to avoid rebuilds when a header changes, but the resulting file -# does not -define filechk_offsets - (set -e; \ - echo "#ifndef $2"; \ - echo "#define $2"; \ - echo "/*"; \ - echo " * DO NOT MODIFY."; \ - echo " *"; \ - echo " * This file was generated by Kbuild"; \ - echo " */"; \ - echo ""; \ - sed -ne $(sed-y); \ - echo ""; \ - echo "#endif" ) -endef ##### -# 1) Generate generic-asm-offsets.h +# Generate generic-asm-offsets.h generic-offsets-file := include/generated/generic-asm-offsets.h always := $(generic-offsets-file) targets := lib/asm-offsets.s -# We use internal kbuild rules to avoid the "is up to date" message from make -lib/asm-offsets.s: lib/asm-offsets.c FORCE - $(Q)mkdir -p $(dir $@) - $(call if_changed_dep,cc_s_c) - $(obj)/$(generic-offsets-file): lib/asm-offsets.s FORCE $(call filechk,offsets,__GENERIC_ASM_OFFSETS_H__) ##### -# 2) Generate asm-offsets.h -# +# Generate asm-offsets.h ifneq ($(wildcard $(srctree)/arch/$(ARCH)/lib/asm-offsets.c),) offsets-file := include/generated/asm-offsets.h @@ -59,10 +25,5 @@ targets += arch/$(ARCH)/lib/asm-offsets.s CFLAGS_asm-offsets.o := -DDO_DEPS_ONLY -# We use internal kbuild rules to avoid the "is up to date" message from make -arch/$(ARCH)/lib/asm-offsets.s: arch/$(ARCH)/lib/asm-offsets.c FORCE - $(Q)mkdir -p $(dir $@) - $(call if_changed_dep,cc_s_c) - $(obj)/$(offsets-file): arch/$(ARCH)/lib/asm-offsets.s FORCE $(call filechk,offsets,__ASM_OFFSETS_H__) diff --git a/Makefile b/Makefile index e5c05028dc..38689de77b 100644 --- a/Makefile +++ b/Makefile @@ -2190,8 +2190,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)) # read all saved command lines -targets := $(wildcard $(sort $(targets))) -cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) +cmd_files := $(wildcard .*.cmd $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd)) ifneq ($(cmd_files),) $(cmd_files): ; # Do not try to update included dependency files diff --git a/scripts/Makefile.build b/scripts/Makefile.build index f8362fbd89..6fa1c7ffda 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -82,17 +82,6 @@ ifneq ($(hostprogs-y)$(hostprogs-m),) include scripts/Makefile.host endif -# Uncommented for U-Boot -# We need to create output dicrectory for SPL and TPL even for in-tree build -#ifneq ($(KBUILD_SRC),) -# Create output directory if not already present -_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) - -# Create directories for object files if directory does not exist -# Needed when obj-y := dir/file.o syntax is used -_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) -#endif - ifndef obj $(warning kbuild: Makefile.build is included improperly) endif @@ -448,11 +437,14 @@ FORCE: # optimization, we don't need to read them if the target does not # exist, we will rebuild anyway in that case. -targets := $(wildcard $(sort $(targets))) -cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) +cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd)) ifneq ($(cmd_files),) include $(cmd_files) endif +# Create directories for object files if they do not exist +obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets)))) +$(shell mkdir -p $(obj-dirs)) + .PHONY: $(PHONY) diff --git a/scripts/Makefile.host b/scripts/Makefile.host index e3379a3c51..3b2b3ff846 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host @@ -47,24 +47,12 @@ host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m))) # C++ Object (.o) files compiled from .cc files host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) -# output directory for programs/.o files -# hostprogs-y := tools/build may have been specified. -# Retrieve also directory of .o files from prog-objs or prog-cxxobjs notation -host-objdirs := $(dir $(__hostprogs) $(host-cobjs) $(host-cxxobjs)) - -host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs)))) - - -__hostprogs := $(addprefix $(obj)/,$(__hostprogs)) host-csingle := $(addprefix $(obj)/,$(host-csingle)) host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti)) host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs)) host-shared := $(addprefix $(obj)/,$(host-shared)) -host-objdirs := $(addprefix $(obj)/,$(host-objdirs)) - -obj-dirs += $(host-objdirs) ##### # Handle options to gcc. Support building with separate output directory diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 8c77eaaa4e..89e8dfb03a 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -57,15 +57,11 @@ single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m))) # objects depend on those (obviously) multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y))) multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) -multi-objs := $(multi-objs-y) $(multi-objs-m) # $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to # tell kbuild to descend subdir-obj-y := $(filter %/built-in.o, $(obj-y)) -# $(obj-dirs) is a list of directories that contain object files -obj-dirs := $(dir $(multi-objs) $(obj-y)) - # Replace multi-part objects by their individual parts, look at local dir only real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y) real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) @@ -88,7 +84,6 @@ multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) -obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) # These flags are needed for modversions and compiling, so we define them here # already @@ -97,10 +92,10 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) # Note: Files that end up in two or more modules are compiled without the # KBUILD_MODNAME definition. The reason is that any made-up name would # differ in different configs. -name-fix = $(subst $(comma),_,$(subst -,_,$1)) -basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" +name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) +basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) modname_flags = $(if $(filter 1,$(words $(modname))),\ - -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") + -DKBUILD_MODNAME=$(call name-fix,$(modname))) orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ $(ccflags-y) $(CFLAGS_$(basetarget).o) @@ -153,7 +148,7 @@ endif # Modified for U-Boot: LINUXINCLUDE -> UBOOTINCLUDE c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ $(__c_flags) $(modkern_cflags) \ - -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) + $(basename_flags) $(modname_flags) a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ $(__a_flags) $(modkern_aflags) @@ -577,3 +572,32 @@ quiet_cmd_fdtgrep = FDTGREP $@ quiet_cmd_fdt_rm_props = FDTGREP $@ cmd_fdt_rm_props = cat $< | $(objtree)/tools/fdtgrep -r -O dtb - -o $@ \ $(addprefix -P ,$(subst $\",,$(CONFIG_OF_REMOVE_PROPS))) + +# ASM offsets +# --------------------------------------------------------------------------- + +# Default sed regexp - multiline due to syntax constraints +define sed-offsets + "s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; \ + /^->/{s:->#\(.*\):/* \1 */:; \ + s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ + s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ + s:->::; p;}" +endef + +# Use filechk to avoid rebuilds when a header changes, but the resulting file +# does not +define filechk_offsets + (set -e; \ + echo "#ifndef $2"; \ + echo "#define $2"; \ + echo "/*"; \ + echo " * DO NOT MODIFY."; \ + echo " *"; \ + echo " * This file was generated by Kbuild"; \ + echo " */"; \ + echo ""; \ + sed -ne $(sed-offsets); \ + echo ""; \ + echo "#endif" ) +endef From patchwork Thu Apr 16 04:38:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 1271485 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.a=rsa-sha256 header.s=dec2015msa header.b=VbWULQiy; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 492mjM5x0tz9sPF for ; Thu, 16 Apr 2020 14:39:51 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3EDC9819F3; Thu, 16 Apr 2020 06:39:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="VbWULQiy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2B6CF805A4; Thu, 16 Apr 2020 06:39:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6E3258047E for ; Thu, 16 Apr 2020 06:39:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=masahiroy@kernel.org Received: from oscar.flets-west.jp (softbank060142179096.bbtec.net [60.142.179.96]) (authenticated) by conuserg-08.nifty.com with ESMTP id 03G4cUkQ008921; Thu, 16 Apr 2020 13:38:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 03G4cUkQ008921 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1587011914; bh=jI44O/d2UEpwYcwa+QorN6oZJ18F63EdLkyRUpa0hW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VbWULQiyRr8P6rGAnZyYjN2igc4EZSxD5dqvyqg3oqp4kIFglKbqgSreyN8c7Y7Dd cTL+uFwd34YdfDrMWxRuUvW6EFJxrNFUIjvDay3naxHZ6WKe2yZlJoOdBsKET1GcmG FEZesS6XR1LjLsk4jlyx0IdlgZEQpoagkAt/vmHIuFs4By4UnEvrDjQSIAM4c++HnU w9EAfv/IxJ4euWpiTYJulsL+j+o1aMHQtVeQ1zf7QvnAsFcOP42lm7mpyRS459JY6p i8YFAD7fEILFLs7YZg7QcYfa+mc0tIcEkdSCJLHEugJ/06NP8lDgXDPMV/R2WQNGML rQkXaw0akG0yg== X-Nifty-SrcIP: [60.142.179.96] From: Masahiro Yamada To: u-boot@lists.denx.de Cc: Bin Meng , Masahiro Yamada , Heiko Stuebner , Kever Yang , Simon Glass , Vignesh Raghavendra Subject: [PATCH 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL Date: Thu, 16 Apr 2020 13:38:26 +0900 Message-Id: <20200416043826.490120-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200416043826.490120-1-masahiroy@kernel.org> References: <20200416043826.490120-1-masahiroy@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Currently generic-asm-offsets.h and asm-offsets.h are generated based on U-Boot proper config options. The same asm-offsets headers are used for building U-Boot SPL/TPL, which causes potential offset mismatch if U-Boot proper has different config options from U-Boot SPL/TPL. This commit adds: spl/include/generated/(generic-)asm-offsets.h tpl/include/generated/(generic-)asm-offsets.h spl/include/generated/(generic-)asm-offsets.h is generated if CONFIG_SPL=y, and included when building SPL. tpl/include/generated/(generic-)asm-offsets.h is generated if CONFIG_TPL=y, and included when building TPL. They are created before Kbuild descends into SPL/TPL object directories and builds $(obj)/dts/dt-platdata.o because $(obj)/dts/dt-platdata.c includes a bunch of headers. Prepend -I$(obj)/include to $(UBOOTINCLUDE) so (generic-)asm-offsets.h is searched in {spl,tpl}/include/generated/. Requested-by: Bin Meng Signed-off-by: Masahiro Yamada --- Kbuild | 4 ++-- scripts/Makefile.spl | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Kbuild b/Kbuild index 6014f7c34a..1eac091594 100644 --- a/Kbuild +++ b/Kbuild @@ -10,7 +10,7 @@ generic-offsets-file := include/generated/generic-asm-offsets.h always := $(generic-offsets-file) targets := lib/asm-offsets.s -$(obj)/$(generic-offsets-file): lib/asm-offsets.s FORCE +$(obj)/$(generic-offsets-file): $(obj)/lib/asm-offsets.s FORCE $(call filechk,offsets,__GENERIC_ASM_OFFSETS_H__) ##### @@ -25,5 +25,5 @@ targets += arch/$(ARCH)/lib/asm-offsets.s CFLAGS_asm-offsets.o := -DDO_DEPS_ONLY -$(obj)/$(offsets-file): arch/$(ARCH)/lib/asm-offsets.s FORCE +$(obj)/$(offsets-file): $(obj)/arch/$(ARCH)/lib/asm-offsets.s FORCE $(call filechk,offsets,__ASM_OFFSETS_H__) diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index 98c04bbbfc..c3fa45f520 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -22,6 +22,8 @@ include $(srctree)/scripts/Kbuild.include -include include/config/auto.conf -include $(obj)/include/autoconf.mk +UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE) + KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD ifeq ($(CONFIG_TPL_BUILD),y) KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD @@ -311,7 +313,7 @@ cmd_plat = $(CC) $(c_flags) -c $< -o $(filter-out $(PHONY),$@) targets += $(obj)/dts/dt-platdata.o $(obj)/dts/dt-platdata.o: $(obj)/dts/dt-platdata.c \ - include/generated/dt-structs-gen.h FORCE + include/generated/dt-structs-gen.h prepare FORCE $(call if_changed,plat) PHONY += dts_dir @@ -422,9 +424,13 @@ $(obj)/$(SPL_BIN): $(u-boot-spl-platdata) $(u-boot-spl-init) \ $(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ; PHONY += $(u-boot-spl-dirs) -$(u-boot-spl-dirs): $(u-boot-spl-platdata) +$(u-boot-spl-dirs): $(u-boot-spl-platdata) prepare $(Q)$(MAKE) $(build)=$@ +PHONY += prepare +prepare: + $(Q)$(MAKE) $(build)=$(obj)/. + quiet_cmd_cpp_lds = LDS $@ cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \ -D__ASSEMBLY__ -x assembler-with-cpp -std=c99 -P -o $@ $<