Skip to contentSkip to conversation

Makefile: Add missing .dep files for fw_*.elf.ld

PATCH New Jessica Clarke 2 participants 2 messages Feb 1, 2023 – Feb 8, 2023 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: Add missing .dep files for fw_*.elf.ld

Since we don't currently create these, changes to fw_base.ldS do not cause the preprocessed fw_*.elf.ld files to be rebuilt, and thus incremental builds can end up failing with missing symbols if crossing the recent commits that introduced _fw_rw_offset and then replaced it with _fw_rw_start.

---
 Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)
Makefile +9 -0
index b742d6d..b20404f 100644
@@ -254,6 +254,7 @@ deps-y=$(platform-objs-path-y:.o=.dep)
 deps-y+=$(libsbi-objs-path-y:.o=.dep)
 deps-y+=$(libsbiutils-objs-path-y:.o=.dep)
 deps-y+=$(firmware-objs-path-y:.o=.dep)
+deps-y+=$(firmware-elfs-path-y:=.dep)
 
 # Setup platform ABI, ISA and Code Model
 ifndef PLATFORM_RISCV_ABI
@@ -413,6 +414,11 @@ inst_file_list = $(CMD_PREFIX)if [ ! -z "$(4)" ]; then \
 inst_header_dir =  $(CMD_PREFIX)mkdir -p $(1); \
 	     echo " INSTALL   $(subst $(install_root_dir)/,,$(1))"; \
 	     cp -rf $(2) $(1)
+compile_cpp_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
+	     echo " CPP-DEP   $(subst $(build_dir)/,,$(1))"; \
+	     printf %s `dirname $(1)`/  > $(1) && \
+	     $(CC) $(CPPFLAGS) -x c -MM $(3) \
+	       -MT `basename $(1:.dep=$(2))` >> $(1) || rm -f $(1)
 compile_cpp = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
 	     echo " CPP       $(subst $(build_dir)/,,$(1))"; \
 	     $(CPP) $(CPPFLAGS) -x c $(2) | grep -v "\#" > $(1)
@@ -543,6 +549,9 @@ $(platform_build_dir)/%.bin: $(platform_build_dir)/%.elf
 $(platform_build_dir)/%.elf: $(platform_build_dir)/%.o $(platform_build_dir)/%.elf.ld $(platform_build_dir)/lib/libplatsbi.a
 	$(call compile_elf,$@,[email protected],$< $(platform_build_dir)/lib/libplatsbi.a)
 
+$(platform_build_dir)/%.dep: $(src_dir)/%.ldS $(KCONFIG_CONFIG)
+	$(call compile_cpp_dep,$@,.ld,$<)
+
 $(platform_build_dir)/%.ld: $(src_dir)/%.ldS
 	$(call compile_cpp,$@,$<)
 
Signature · 1 line
2.37.0
Applied
#1 lore raw

PATCH 1/1 Makefile: Add missing .dep files for fw_*.elf.ld

Quoted 9 lines · Jessica Clarke

Since we don't currently create these, changes to fw_base.ldS do not cause the preprocessed fw_*.elf.ld files to be rebuilt, and thus incremental builds can end up failing with missing symbols if crossing the recent commits that introduced _fw_rw_offset and then replaced it with _fw_rw_start.

Looks good to me.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 46 lines
---
 Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)
Makefile +9 -1
index b742d6d..b20404f 100644
@@ -254,6 +254,7 @@ deps-y=$(platform-objs-path-y:.o=.dep)
 deps-y+=$(libsbi-objs-path-y:.o=.dep)
 deps-y+=$(libsbiutils-objs-path-y:.o=.dep)
 deps-y+=$(firmware-objs-path-y:.o=.dep)
+deps-y+=$(firmware-elfs-path-y:=.dep)
 
 # Setup platform ABI, ISA and Code Model
 ifndef PLATFORM_RISCV_ABI
@@ -413,6 +414,11 @@ inst_file_list = $(CMD_PREFIX)if [ ! -z "$(4)" ]; then \
 inst_header_dir =  $(CMD_PREFIX)mkdir -p $(1); \
             echo " INSTALL   $(subst $(install_root_dir)/,,$(1))"; \
             cp -rf $(2) $(1)
+compile_cpp_dep = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
+            echo " CPP-DEP   $(subst $(build_dir)/,,$(1))"; \
+            printf %s `dirname $(1)`/  > $(1) && \
+            $(CC) $(CPPFLAGS) -x c -MM $(3) \
+              -MT `basename $(1:.dep=$(2))` >> $(1) || rm -f $(1)
 compile_cpp = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
             echo " CPP       $(subst $(build_dir)/,,$(1))"; \
             $(CPP) $(CPPFLAGS) -x c $(2) | grep -v "\#" > $(1)
@@ -543,6 +549,9 @@ $(platform_build_dir)/%.bin: $(platform_build_dir)/%.elf
 $(platform_build_dir)/%.elf: $(platform_build_dir)/%.o $(platform_build_dir)/%.elf.ld $(platform_build_dir)/lib/libplatsbi.a
        $(call compile_elf,$@,[email protected],$< $(platform_build_dir)/lib/libplatsbi.a)
 
+$(platform_build_dir)/%.dep: $(src_dir)/%.ldS $(KCONFIG_CONFIG)
+       $(call compile_cpp_dep,$@,.ld,$<)
+
 $(platform_build_dir)/%.ld: $(src_dir)/%.ldS
        $(call compile_cpp,$@,$<)
 
--

2.37.0

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi