[coreboot] New patch to review for coreboot: 4ab6244 build system: Split linking into multiple steps

Patrick Georgi (patrick@georgi-clan.de) gerrit at coreboot.org
Sun Nov 25 18:14:00 CET 2012


Patrick Georgi (patrick at georgi-clan.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1911

-gerrit

commit 4ab6244c706b9da09cc5c33aa421a681e3f185f3
Author: Patrick Georgi <patrick at georgi-clan.de>
Date:   Sun Nov 25 17:10:47 2012 +0100

    build system: Split linking into multiple steps
    
    After collecting dependencies for ramstage, add an intermediate step
    in which object files are linked per directory. The results are then
    linked into the final binary.
    
    This reduces the maximum command line length and might also help with
    future use of LTO linking.
    
    Also adapt the lint test for build dir handling, since printall
    doesn't provide individual object files for ramstage anymore.
    
    Change-Id: Ie40febd8c1eaf4609944eedeab46d870639e53df
    Signed-off-by: Patrick Georgi <patrick at georgi-clan.de>
---
 Makefile.inc                                 | 34 ++++++++++++++++++++++++++++
 util/lint/lint-stable-002-build-dir-handling |  8 +++----
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/Makefile.inc b/Makefile.inc
index 0fa3b8e..db1bc75 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -61,6 +61,40 @@ subdirs-y += site-local
 # Add source classes and their build options
 classes-y := ramstage romstage smm cpu_microcode
 
+#######################################################################
+# Helper functions for ramstage postprocess
+spc :=
+spc +=
+$(spc) :=
+$(spc) +=
+
+# files-in-dir-recursive,dir,files
+files-in-dir-recursive=$(filter $(1)%,$(2))
+
+# parent-dir,dir/
+parent-dir=$(dir $(subst $( ),/,$(strip $(subst /, ,$(1)))))
+
+# filters out exactly the directory specified
+# filter-out-dir,dir_to_keep,dirs
+filter-out-dir=$(filter-out $(1),$(2))
+
+# filters out dir_to_keep and all its parents
+# filter-out-dirs,dir_to_keep,dirs
+filter-out-dirs=$(if $(filter-out ./,$(1)),$(call filter-out-dirs,$(call parent-dir,$(1)),$(call filter-out-dir,$(1),$(2))),$(call filter-out-dir,$(1),$(2)))
+
+# dir-wildcards,dirs
+dir-wildcards=$(addsuffix %,$(1))
+
+# files-in-dir,dir,files
+files-in-dir=$(filter-out $(call dir-wildcards,$(call filter-out-dirs,$(1),$(dir $(2)))),$(call files-in-dir-recursive,$(1),$(2)))
+
+#######################################################################
+# reduce command line length by linking the objects of each
+# directory into an intermediate file
+ramstage-postprocess=$(foreach d,$(sort $(dir $(1))), \
+	$(eval $(d)ramstage.o: $(call files-in-dir,$(d),$(1)); $$(LD) -o $$@ -r $$^ ) \
+	$(eval ramstage-objs:=$(d)ramstage.o $(filter-out $(call files-in-dir,$(d),$(1)),$(ramstage-objs))))
+
 romstage-c-ccopts:=-D__PRE_RAM__
 romstage-S-ccopts:=-D__PRE_RAM__
 ifeq ($(CONFIG_TRACE),y)
diff --git a/util/lint/lint-stable-002-build-dir-handling b/util/lint/lint-stable-002-build-dir-handling
index ca61a35..2dad8a6 100755
--- a/util/lint/lint-stable-002-build-dir-handling
+++ b/util/lint/lint-stable-002-build-dir-handling
@@ -61,10 +61,10 @@ $MAKE DOTCONFIG=$TMPCONFIG allyesconfig >/dev/null
 CURRENTDIR=`pwd -P`
 PARENTDIR=`dirname $CURRENTDIR`
 
-compare_output "`run_printall build`" "build/.../static.c build/.../static.c build/.../static.ramstage.o build/.../static.romstage.o"
-compare_output "`run_printall ../obj`" "$PARENTDIR/obj/.../static.c $PARENTDIR/obj/.../static.c $PARENTDIR/obj/.../static.ramstage.o $PARENTDIR/obj/.../static.romstage.o"
-compare_output "`run_printall /tmp`" "/tmp/.../static.c /tmp/.../static.c /tmp/.../static.ramstage.o /tmp/.../static.romstage.o"
-compare_output "`run_printall /../tmp`" "/tmp/.../static.c /tmp/.../static.c /tmp/.../static.ramstage.o /tmp/.../static.romstage.o"
+compare_output "`run_printall build`" "build/.../static.c build/.../static.c build/.../static.romstage.o"
+compare_output "`run_printall ../obj`" "$PARENTDIR/obj/.../static.c $PARENTDIR/obj/.../static.c $PARENTDIR/obj/.../static.romstage.o"
+compare_output "`run_printall /tmp`" "/tmp/.../static.c /tmp/.../static.c /tmp/.../static.romstage.o"
+compare_output "`run_printall /../tmp`" "/tmp/.../static.c /tmp/.../static.c /tmp/.../static.romstage.o"
 
 rm -f $TMPCONFIG
 




More information about the coreboot mailing list