Skip to contentSkip to conversation

support separate asm-offsets.h for SPL and TPL

PATCH Superseded Masahiro Yamada 3 participants 10 messages Apr 16, 2020 – Apr 19, 2020 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover support separate asm-offsets.h for SPL and TPL

Bin Meng asked me how to generate correct asm-offsets headers for SPL/TPL.

1/3: fix a bug that I just happened to find when touching this line 2/3: cherry-pick some Kbuild changes. This is a good resync regardless of 3/3 3/3: change as Bin Meng requested. This complicates the build process
a bit more, but if we want this, just go ahead.

Masahiro Yamada (3):
kbuild: add FORCE to dependency of $(obj)/dts/dt-platdata.o
kbuild: cherry-pick kbuild changes from Linux
kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL

 Kbuild                 | 49 +++++-------------------------------------
 Makefile               |  3 +--
 scripts/Makefile.build | 18 +++++-----------
 scripts/Makefile.host  | 12 -----------
 scripts/Makefile.lib   | 42 ++++++++++++++++++++++++++++--------
 scripts/Makefile.spl   | 13 ++++++++---
 6 files changed, 54 insertions(+), 83 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 kbuild: add FORCE to dependency of $(obj)/dts/dt-platdata.o

if_changed must have FORCE as a prerequisite.

Add $(obj)/dts/dt-platdata.o to 'targets' so that the corresponding .cmd file is included.

---

 scripts/Makefile.spl | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
scripts/Makefile.spl +3 -2
index 314b02ba07..98c04bbbfc 100644
@@ -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
Signature · 1 line
2.25.1
#3 lore raw

PATCH 2/3 kbuild: cherry-pick kbuild changes from Linux

In reply to Masahiro Yamada

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

---

 Kbuild                 | 45 +++---------------------------------------
 Makefile               |  3 +--
 scripts/Makefile.build | 18 +++++------------
 scripts/Makefile.host  | 12 -----------
 scripts/Makefile.lib   | 42 ++++++++++++++++++++++++++++++---------
 5 files changed, 42 insertions(+), 78 deletions(-)
Kbuild +3 -42
index e2e3b2995f..6014f7c34a 100644
@@ -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__)
Makefile +1 -2
index e5c05028dc..38689de77b 100644
@@ -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
scripts/Makefile.build +5 -13
index f8362fbd89..6fa1c7ffda 100644
@@ -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)
scripts/Makefile.host +0 -12
index e3379a3c51..3b2b3ff846 100644
@@ -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
scripts/Makefile.lib +33 -9

75 lines not on this page · raw message

Signature · 1 line
2.25.1
#5 lore raw

PATCH 3/3 kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL

In reply to Masahiro Yamada

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/.

---

 Kbuild               |  4 ++--
 scripts/Makefile.spl | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)
Kbuild +2 -2
index 6014f7c34a..1eac091594 100644
@@ -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__)
scripts/Makefile.spl +8 -2
index 98c04bbbfc..c3fa45f520 100644
@@ -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 $@ $<
Signature · 1 line
2.25.1
#6 lore raw

PATCH 3/3 kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL

Hi Masahiro,

Quoted 6 lines · Masahiro Yamada

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.

Thank you very much for doing this.

Quoted 10 lines

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.

Quoted 7 lines

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/.

This patch does not apply on top of u-boot/master, unfortunately.

Quoted 8 lines

---

 Kbuild               |  4 ++--
 scripts/Makefile.spl | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

I manually applied the changes and had a test, but it failed to build. See below:

Kbuild generic-offsets-file := include/generated/generic-asm-offsets.h · line 13

Quoted 10 lines
Kbuild +1 -1
index 6014f7c34a..1eac091594 100644
@@ -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

CC spl/./lib/asm-offsets.s
cc1: fatal error: can't open 'spl/./lib/asm-offsets.s' for writing: No such file or directory
compilation terminated.
scripts/Makefile.build:166: recipe for target 'spl/./lib/asm-offsets.s' failed make[2]: *** [spl/./lib/asm-offsets.s] Error 1 scripts/Makefile.spl:432: recipe for target 'prepare' failed make[1]: *** [prepare] Error 2
Makefile:1917: recipe for target 'spl/u-boot-spl' failed
make: *** [spl/u-boot-spl] Error 2

When I removed the changes for this line, and the line below, the build could pass.
The spl/include/generated/(generic-)asm-offsets.h were generated, and I verified the macro values are correct and different with the U-Boot proper one.

But since there is no $(obj) prepended to lib/asm-offsets.s, I believe this is still not perfect.

Quoted 38 lines
Kbuild +1 -1
        $(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__)
scripts/Makefile.spl +4 -2
index 98c04bbbfc..c3fa45f520 100644
@@ -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

scripts/Makefile.spl $(obj)/$(SPL_BIN): $(u-boot-spl-platdata) $(u-boot-spl-init) \

Quoted 10 lines
scripts/Makefile.spl +4 -1
        $(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 $@ $<
--

Regards,
Bin

#7 lore raw

PATCH 3/3 kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL

Quoted 67 lines · Bin Meng

Hi Masahiro,

Quoted 6 lines · Masahiro Yamada

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.

Thank you very much for doing this.

Quoted 10 lines

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.

Quoted 7 lines

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/.

This patch does not apply on top of u-boot/master, unfortunately.

Quoted 8 lines

---

 Kbuild               |  4 ++--
 scripts/Makefile.spl | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

I manually applied the changes and had a test, but it failed to build. See below:

Kbuild generic-offsets-file := include/generated/generic-asm-offsets.h · line 13

Quoted 10 lines
Kbuild +1 -1
index 6014f7c34a..1eac091594 100644
@@ -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

CC spl/./lib/asm-offsets.s
cc1: fatal error: can't open 'spl/./lib/asm-offsets.s' for writing: No such file or directory
compilation terminated.
scripts/Makefile.build:166: recipe for target 'spl/./lib/asm-offsets.s' failed make[2]: *** [spl/./lib/asm-offsets.s] Error 1 scripts/Makefile.spl:432: recipe for target 'prepare' failed make[1]: *** [prepare] Error 2
Makefile:1917: recipe for target 'spl/u-boot-spl' failed
make: *** [spl/u-boot-spl] Error 2

Quoted 8 lines

When I removed the changes for this line, and the line below, the build could pass.
The spl/include/generated/(generic-)asm-offsets.h were generated, and I verified the macro values are correct and different with the U-Boot proper one.

But since there is no $(obj) prepended to lib/asm-offsets.s, I believe this is still not perfect.

This is because you remove the needed changes.

Signature · 2 lines
Best Regards
Masahiro Yamada
#8 lore raw

PATCH 3/3 kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL

Hi Masahiro,

Quoted 75 lines · Masahiro Yamada
Quoted 73 lines · Bin Meng

Hi Masahiro,

Quoted 6 lines · Masahiro Yamada

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.

Thank you very much for doing this.

Quoted 10 lines

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.

Quoted 7 lines

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/.

This patch does not apply on top of u-boot/master, unfortunately.

Quoted 8 lines

---

 Kbuild               |  4 ++--
 scripts/Makefile.spl | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

I manually applied the changes and had a test, but it failed to build. See below:

Kbuild generic-offsets-file := include/generated/generic-asm-offsets.h · line 13

Quoted 10 lines
Kbuild +1 -1
index 6014f7c34a..1eac091594 100644
@@ -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

CC spl/./lib/asm-offsets.s
cc1: fatal error: can't open 'spl/./lib/asm-offsets.s' for writing: No such file or directory
compilation terminated.
scripts/Makefile.build:166: recipe for target 'spl/./lib/asm-offsets.s' failed make[2]: *** [spl/./lib/asm-offsets.s] Error 1 scripts/Makefile.spl:432: recipe for target 'prepare' failed make[1]: *** [prepare] Error 2
Makefile:1917: recipe for target 'spl/u-boot-spl' failed
make: *** [spl/u-boot-spl] Error 2

When I removed the changes for this line, and the line below, the build could pass.
The spl/include/generated/(generic-)asm-offsets.h were generated, and I verified the macro values are correct and different with the U-Boot proper one.

Quoted 5 lines
Quoted 2 lines

But since there is no $(obj) prepended to lib/asm-offsets.s, I believe this is still not perfect.

This is because you remove the needed changes.

I applied patch 1, and manually applied patch 3 in this series. Do you mean patch 2 is needed for patch 3 to work properly?

Regards,
Bin

#9 lore raw

PATCH 3/3 kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL

Hi Bin,

Quoted 10 lines · Bin Meng

Hi Masahiro,

Quoted 3 lines

This is because you remove the needed changes.

I applied patch 1, and manually applied patch 3 in this series. Do you mean patch 2 is needed for patch 3 to work properly?

Yes, that's why I sent the 3 patches in a series.

Signature · 2 lines
Best Regards
Masahiro Yamada
#4 lore raw

PATCH 2/3 kbuild: cherry-pick kbuild changes from Linux

In reply to Masahiro Yamada
Quoted 11 lines · Masahiro Yamada

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

Quoted 9 lines

---

 Kbuild                 | 45 +++---------------------------------------
 Makefile               |  3 +--
 scripts/Makefile.build | 18 +++++------------
 scripts/Makefile.host  | 12 -----------
 scripts/Makefile.lib   | 42 ++++++++++++++++++++++++++++++---------
 5 files changed, 42 insertions(+), 78 deletions(-)

Tested on sandbox with buildman, etc.: