Attention is currently required from: Julius Werner, Jérémy Compostella, Philipp Hug, Ron Minnich.
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/83574?usp=email )
Change subject: Makefile.inc: Add a common link_stage function and use it ......................................................................
Makefile.inc: Add a common link_stage function and use it
A few differences with the original link targets: - 'libs' is now supported on all arch even though only x86 uses it - compiler_rt is included on arch that previously did not (arm). This however has no impact as there compiler_rt is not defined for those arch in xcompile - LIBGCC_FILE_NAME_bootblock is not included, but this was not defined anywhere so this is a noop - the x86 --oformat is dropped as it is not needed.
Change-Id: I64f7686894c99732d06972e7ba327061db6d7c44 Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M Makefile.mk M src/arch/arm/Makefile.mk M src/arch/arm64/Makefile.mk M src/arch/ppc64/Makefile.mk M src/arch/riscv/Makefile.mk M src/arch/x86/Makefile.mk 6 files changed, 30 insertions(+), 92 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/74/83574/1
diff --git a/Makefile.mk b/Makefile.mk index e9ad2cc..ac09712 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -1317,6 +1317,15 @@ fi endif # CONFIG_CBFS_VERIFICATION
+define link_stage +# $1 stage name + +$$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs) + @printf " LINK $$(subst $$(obj)/,,$$(@))\n" + $$(LD_$(1)) $$(LDFLAGS_$(1)) -o $$@ -L$$(obj) $$(COMPILER_RT_FLAGS_$(1)) --whole-archive --start-group $$(filter-out %.ld,$$($(1)-objs)) $$($(1)-libs) --no-whole-archive $$(COMPILER_RT_$(1)) --end-group -T $(call src-to-obj,$(1),$(CONFIG_MEMLAYOUT_LD_FILE)) + +endef + ifeq ($(CONFIG_SEPARATE_ROMSTAGE),y) cbfs-files-y += $(CONFIG_CBFS_PREFIX)/romstage $(CONFIG_CBFS_PREFIX)/romstage-file := $(objcbfs)/romstage.elf diff --git a/src/arch/arm/Makefile.mk b/src/arch/arm/Makefile.mk index b18b137..3f8232f 100644 --- a/src/arch/arm/Makefile.mk +++ b/src/arch/arm/Makefile.mk @@ -43,13 +43,8 @@ bootblock-y += clock.c bootblock-y += stages.c
-$(objcbfs)/bootblock.debug: $$(bootblock-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) -T $(call src-to-obj,bootblock,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) --end-group - -$(objcbfs)/decompressor.debug: $$(decompressor-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) -T $(call src-to-obj,decompressor,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(decompressor-objs)) --end-group +$(eval $(call link_stage,bootblock)) +$(eval $(call link_stage,decompressor))
endif # CONFIG_ARCH_BOOTBLOCK_ARM
@@ -59,9 +54,7 @@
ifeq ($(CONFIG_ARCH_VERSTAGE_ARM),y)
-$(objcbfs)/verstage.debug: $$(verstage-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_verstage) $(LDFLAGS_verstage) -o $@ -L$(obj) -T $(call src-to-obj,verstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(verstage-objs)) --end-group +$(eval $(call link_stage,verstage))
verstage-y += boot.c verstage-y += div0.c @@ -92,9 +85,7 @@ rmodules_arm-y += memmove.S rmodules_arm-y += eabi_compat.c
-$(objcbfs)/romstage.debug: $$(romstage-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group +$(eval $(call link_stage,romstage))
endif # CONFIG_ARCH_ROMSTAGE_ARM
@@ -122,8 +113,6 @@ rmodules_arm-y += eabi_compat.c ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c)
-$(objcbfs)/ramstage.debug: $$(ramstage-objs) - @printf " CC $(subst $(obj)/,,$(@))\n" - $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group +$(eval $(call link_stage,ramstage))
endif # CONFIG_ARCH_RAMSTAGE_ARM diff --git a/src/arch/arm64/Makefile.mk b/src/arch/arm64/Makefile.mk index cb43897..f4ca29b 100644 --- a/src/arch/arm64/Makefile.mk +++ b/src/arch/arm64/Makefile.mk @@ -43,13 +43,8 @@
# Build the bootblock
-$(objcbfs)/bootblock.debug: $$(bootblock-objs) $(obj)/config.h - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) --end-group -T $(call src-to-obj,bootblock,$(CONFIG_MEMLAYOUT_LD_FILE)) - -$(objcbfs)/decompressor.debug: $$(decompressor-objs) $(obj)/config.h - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(decompressor-objs)) --end-group -T $(call src-to-obj,decompressor,$(CONFIG_MEMLAYOUT_LD_FILE)) +$(eval $(call link_stage,bootblock)) +$(eval $(call link_stage,decompressor))
endif # CONFIG_ARCH_BOOTBLOCK_ARM64
@@ -59,9 +54,7 @@
ifeq ($(CONFIG_ARCH_VERSTAGE_ARM64),y)
-$(objcbfs)/verstage.debug: $$(verstage-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_verstage) $(LDFLAGS_verstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(verstage-objs)) --end-group -T $(call src-to-obj,verstage,$(CONFIG_MEMLAYOUT_LD_FILE)) +$(eval $(call link_stage,verstage))
verstage-y += boot.c verstage-y += div0.c @@ -103,9 +96,7 @@ rmodules_arm64-y += memmove.S rmodules_arm64-y += eabi_compat.c
-$(objcbfs)/romstage.debug: $$(romstage-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group -T $(call src-to-obj,romstage,$(CONFIG_MEMLAYOUT_LD_FILE)) +$(eval $(call link_stage,romstage))
endif # CONFIG_ARCH_ROMSTAGE_ARM64
@@ -144,9 +135,7 @@
# Build the ramstage
-$(objcbfs)/ramstage.debug: $$(ramstage-objs) - @printf " CC $(subst $(obj)/,,$(@))\n" - $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) +$(eval $(call link_stage,ramstage))
# Build ARM Trusted Firmware (BL31)
diff --git a/src/arch/ppc64/Makefile.mk b/src/arch/ppc64/Makefile.mk index 92b1e39..4299e74 100644 --- a/src/arch/ppc64/Makefile.mk +++ b/src/arch/ppc64/Makefile.mk @@ -21,11 +21,7 @@
bootblock-generic-ccopts += $(ppc64_flags)
-$(objcbfs)/bootblock.debug: $$(bootblock-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) \ - -T $(call src-to-obj,bootblock,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) \ - $(LIBGCC_FILE_NAME_bootblock) --end-group $(COMPILER_RT_bootblock) +$(eval $(call link_stage,bootblock))
endif
@@ -48,9 +44,7 @@
# Build the romstage
-$(objcbfs)/romstage.debug: $$(romstage-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group $(COMPILER_RT_romstage) +$(eval $(call link_stage,romstage))
romstage-c-ccopts += $(ppc64_flags) romstage-S-ccopts += $(ppc64_asm_flags) @@ -81,9 +75,7 @@
# Build the ramstage
-$(objcbfs)/ramstage.debug: $$(ramstage-objs) - @printf " CC $(subst $(obj)/,,$(@))\n" - $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group $(COMPILER_RT_ramstage) +$(eval $(call link_stage,ramstage))
ramstage-c-ccopts += $(ppc64_flags) ramstage-S-ccopts += $(ppc64_asm_flags) diff --git a/src/arch/riscv/Makefile.mk b/src/arch/riscv/Makefile.mk index d5defea..f6b210a 100644 --- a/src/arch/riscv/Makefile.mk +++ b/src/arch/riscv/Makefile.mk @@ -75,11 +75,7 @@
bootblock-y = bootblock.S
-$(objcbfs)/bootblock.debug: $$(bootblock-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) \ - -T $(call src-to-obj,bootblock,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) \ - $(LIBGCC_FILE_NAME_bootblock) --end-group $(COMPILER_RT_bootblock) +$(eval $(call link_stage,bootblock))
bootblock-c-ccopts += $(riscv_flags) bootblock-S-ccopts += $(riscv_asm_flags) @@ -100,9 +96,7 @@
# Build the romstage
-$(objcbfs)/romstage.debug: $$(romstage-objs) - @printf " LINK $(subst $(obj)/,,$(@))\n" - $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group $(COMPILER_RT_romstage) +$(eval $(call link_stage,romstage))
romstage-c-ccopts += $(riscv_flags) romstage-S-ccopts += $(riscv_asm_flags) @@ -131,9 +125,7 @@
# Build the ramstage
-$(objcbfs)/ramstage.debug: $$(ramstage-objs) - @printf " CC $(subst $(obj)/,,$(@))\n" - $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group $(COMPILER_RT_ramstage) +$(eval $(call link_stage,ramstage))
ramstage-c-ccopts += $(riscv_flags) ramstage-S-ccopts += $(riscv_asm_flags) diff --git a/src/arch/x86/Makefile.mk b/src/arch/x86/Makefile.mk index 2832ac3..43c7bd4 100644 --- a/src/arch/x86/Makefile.mk +++ b/src/arch/x86/Makefile.mk @@ -51,19 +51,6 @@ endif # CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA
############################################################################### -# common support for early assembly includes -############################################################################### - -define x86_stage -# $1 stage name -# $2 oformat - -$$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs) - @printf " LINK $$(subst $$(obj)/,,$$(@))\n" - $$(LD_$(1)) $$(LDFLAGS_$(1)) -o $$@ -L$$(obj) $$(COMPILER_RT_FLAGS_$(1)) --whole-archive --start-group $$(filter-out %.ld,$$($(1)-objs)) $$($(1)-libs) --no-whole-archive $$(COMPILER_RT_$(1)) --end-group -T $(call src-to-obj,$(1),$(CONFIG_MEMLAYOUT_LD_FILE)) --oformat $(2) -endef - -############################################################################### # bootblock ###############################################################################
@@ -91,11 +78,7 @@
$(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h
-ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y) -$(eval $(call x86_stage,bootblock,elf32-i386)) -else -$(eval $(call x86_stage,bootblock,elf64-x86-64)) -endif +$(eval $(call link_stage,bootblock))
ifeq ($(CONFIG_BOOTBLOCK_IN_CBFS),y) add_bootblock = \ @@ -144,11 +127,7 @@
verstage-libs ?=
-ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y) -$(eval $(call x86_stage,verstage,elf32-i386)) -else -$(eval $(call x86_stage,verstage,elf64-x86-64)) -endif +$(eval $(call link_stage,verstage))
endif # CONFIG_ARCH_VERSTAGE_X86_32 / CONFIG_ARCH_VERSTAGE_X86_64
@@ -183,11 +162,7 @@ romstage-srcs += $(wildcard $(src)/mainboard/$(MAINBOARDDIR)/romstage.c) romstage-libs ?=
-ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) -$(eval $(call x86_stage,romstage,elf32-i386)) -else -$(eval $(call x86_stage,romstage,elf64-x86-64)) -endif +$(eval $(call link_stage,romstage))
# Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428 romstage-S-ccopts += -g0 @@ -225,11 +200,7 @@
LDFLAGS_postcar += -Map $(objcbfs)/postcar.map
-ifeq ($(CONFIG_ARCH_POSTCAR_X86_32),y) -$(eval $(call x86_stage,postcar,elf32-i386)) -else -$(eval $(call x86_stage,postcar,elf64-x86-64)) -endif +$(eval $(call link_stage,postcar))
$(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod cp $< $@ @@ -308,11 +279,7 @@
ramstage-libs ?=
-ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) -$(eval $(call x86_stage,ramstage,elf32-i386)) -else -$(eval $(call x86_stage,ramstage,elf64-x86-64)) -endif +$(eval $(call link_stage,ramstage))
$(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod cp $< $@