Attention is currently required from: Jérémy Compostella.

Arthur Heymans has uploaded this change for review.

View Change

arch,cpu,lib: Use thin archives instead of partial linking

x86 ramstage and smm compilation currently use partial linking, which is
not supported by link time optimization. Collect the object files into
thin archives instead, and link them all at once at the very end.

Change-Id: I122a4542d1e98d89545897d5177c93ee463d0cdb
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
---
M src/arch/x86/Makefile.mk
M src/cpu/x86/smm/Makefile.mk
M src/lib/Makefile.mk
3 files changed, 8 insertions(+), 11 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/23/80723/1
diff --git a/src/arch/x86/Makefile.mk b/src/arch/x86/Makefile.mk
index 46d8450..0973cc7 100644
--- a/src/arch/x86/Makefile.mk
+++ b/src/arch/x86/Makefile.mk
@@ -315,13 +315,9 @@
$(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod
cp $< $@

-$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE))
+$(objcbfs)/ramstage.debug: $$(ramstage-objs) $$(ramstage-libs) $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE))
@printf " CC $(subst $(obj)/,,$(@))\n"
- $(CC_ramstage) $(CPPFLAGS) $(LDFLAGS_ramstage) -o $@ -L$(obj) $< -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE))
-
-$(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs)
- @printf " CC $(subst $(obj)/,,$(@))\n"
- $(CC_ramstage) $(LD_MACHINE) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_ramstage) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs) -Wl,--no-whole-archive $(COMPILER_RT_ramstage) -Wl,--end-group
+ $(CC_ramstage) $(LD_MACHINE) $(CPPFLAGS) $(LDFLAGS_ramstage) $(COMPILER_RT_FLAGS_ramstage) -o $@ -L$(obj) -Wl,--whole-archive,--start-group $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs) -Wl,--no-whole-archive $(COMPILER_RT_ramstage) -Wl,--end-group -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE))

endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64

diff --git a/src/cpu/x86/smm/Makefile.mk b/src/cpu/x86/smm/Makefile.mk
index 2c90236..bb94978 100644
--- a/src/cpu/x86/smm/Makefile.mk
+++ b/src/cpu/x86/smm/Makefile.mk
@@ -17,8 +17,9 @@
smm-generic-ccopts += -D__SMM__
smm-c-deps+=$$(OPTION_TABLE_H)

-$(obj)/smm/smm.o: $$(smm-objs) $(COMPILER_RT_smm)
- $(CC_smm) $(CFLAGS_smm) -r -o $@ $(COMPILER_RT_FLAGS_smm) -Wl,--whole-archive,--start-group $(filter-out %.ld, $(smm-objs)) -Wl,--no-whole-archive $(COMPILER_RT_smm) -Wl,--end-group
+$(obj)/smm/smm.a: $$(smm-objs)
+ @printf " AR $(subst $(obj)/,,$(@))\n"
+ $(AR_smm) rcT $@ $(filter-out %.ld, $(smm-objs))

# change to the target path because objcopy will use the path name in its
# ELF symbol names.
@@ -66,9 +67,9 @@
# C-based SMM handler.

ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
-$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o, 0,x86_32))
+$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.a, 0,x86_32))
else
-$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o, 0,x86_64))
+$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.a, 0,x86_64))
endif

$(obj)/smm/smm: $(obj)/smm/smm.elf.rmod
diff --git a/src/lib/Makefile.mk b/src/lib/Makefile.mk
index 0bc9966..d8bdabe 100644
--- a/src/lib/Makefile.mk
+++ b/src/lib/Makefile.mk
@@ -318,7 +318,7 @@
# rmdoule is named $(1).rmod
define rmodule_link
$(strip $(1)): $(strip $(2)) $$(COMPILER_RT_rmodules_$(4)) $(call src-to-obj,rmodules_$(4),src/lib/rmodule.ld) | $$(RMODTOOL)
- $$(CC_rmodules_$(4)) $$(LDFLAGS_rmodules_$(4)) $(RMODULE_LDFLAGS) $(addprefix,-Wl,$($(1)-ldflags)) -T $(call src-to-obj,rmodules_$(4),src/lib/rmodule.ld) -Wl,--defsym=__heap_size=$(strip $(3)) -o $$@ -Wl,--whole-archive,--start-group $(filter-out %.ld,$(2)) -Wl,--end-group
+ $$(CC_rmodules_$(4)) $$(LDFLAGS_rmodules_$(4)) $$(COMPILER_RT_FLAGS_rmodules_$(4)) $(RMODULE_LDFLAGS) -T $(call src-to-obj,rmodules_$(4),src/lib/rmodule.ld) -Wl,--defsym=__heap_size=$(strip $(3)) -o $$@ -Wl,--whole-archive,--start-group $(filter-out %.ld,$(2)) -Wl,--no-whole-archive $$(COMPILER_RT_rmodules_$(4)) -Wl,--end-group
$$(NM_rmodules_$(4)) -n $$@ > $$(basename $$@).map
endef


To view, visit change 80723. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: I122a4542d1e98d89545897d5177c93ee463d0cdb
Gerrit-Change-Number: 80723
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur@aheymans.xyz>
Gerrit-Reviewer: Jérémy Compostella <jeremy.compostella@intel.com>
Gerrit-Attention: Jérémy Compostella <jeremy.compostella@intel.com>
Gerrit-MessageType: newchange