aboutsummaryrefslogtreecommitdiff
path: root/Makefile.main
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2018-02-10 18:42:49 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2018-02-28 20:28:39 -0600
commitf6159cff5d91e5c0810d0c9285a1d2370a38e2b7 (patch)
treec6148aef1cc7f967baaf9b7a65486b7b4c95678f /Makefile.main
parentf30286c494312caa81333a077da58f501894c2bb (diff)
downloadskiboot-f6159cff5d91e5c0810d0c9285a1d2370a38e2b7.zip
skiboot-f6159cff5d91e5c0810d0c9285a1d2370a38e2b7.tar.gz
skiboot-f6159cff5d91e5c0810d0c9285a1d2370a38e2b7.tar.bz2
build: use thin archives rather than incremental linking
This changes to build system to use thin archives rather than incremental linking for built-in.o, similar to recent change to Linux. built-in.o is renamed to built-in.a, and is created as a thin archive with no index, for speed and size. All built-in.a are aggregated into a skiboot.tmp.a which is a thin archive built with an index, making it suitable or linking. This is input into the final link. The advantags of build size and linker code placement flexibility are not as great with skiboot as a bigger project like Linux, but it's a conceptually better way to build, and is more compatible with link time optimisation in toolchains which might be interesting for skiboot particularly for size reductions. Size of build tree before this patch is 34.4MB, afterwards 23.1MB. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'Makefile.main')
-rw-r--r--Makefile.main14
1 files changed, 9 insertions, 5 deletions
diff --git a/Makefile.main b/Makefile.main
index 46ad3b0..9683638 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -126,7 +126,7 @@ LDFLAGS += -Wl,-pie
LDFLAGS += -Wl,-Ttext-segment,$(LD_TEXT) -Wl,-N -Wl,--build-id=none
LDFLAGS += -Wl,--no-multi-toc
LDFLAGS += -mcpu=power7 -mbig-endian -Wl,--oformat,elf64-powerpc
-
+LDFLAGS_FINAL = $(LDFLAGS) -Wl,--whole-archive
LDRFLAGS=-melf64ppc
# Debug stuff
#LDFLAGS += -Wl,-v -Wl,-Map,foomap
@@ -213,8 +213,8 @@ OBJS += $(LIBC) $(CCAN) $(DEVSRC_OBJ) $(LIBPORE)
OBJS_NO_VER = $(OBJS)
ALL_OBJS = $(OBJS) version.o
-ALL_OBJS_1 = $(ALL_OBJS) asm/dummy_map.o
-ALL_OBJS_2 = $(ALL_OBJS) asm/real_map.o
+ALL_OBJS_1 = $(TARGET).tmp.a asm/dummy_map.o
+ALL_OBJS_2 = $(TARGET).tmp.a asm/real_map.o
$(TARGET).lid.xz: $(TARGET).lid
$(call Q,XZ, cat $^ | xz -9 -C crc32 > $@, $@)
@@ -228,13 +228,17 @@ $(TARGET).lid.stb: $(TARGET).lid libstb/create-container
$(TARGET).lid.xz.stb: $(TARGET).lid.xz libstb/create-container
$(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/ PAYLOAD,$@)
+$(TARGET).tmp.a: $(ALL_OBJS)
+ @rm -f $(TARGET).tmp.a
+ $(call Q,AR, $(AR) rcsTPD $@ $(ALL_OBJS), $@)
+
$(TARGET).tmp.elf: $(ALL_OBJS_1) $(TARGET).lds $(KERNEL)
- $(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS_1) -o $@, $@)
+ $(call Q,LD, $(CC) $(LDFLAGS_FINAL) -o $@ -T $(TARGET).lds $(ALL_OBJS_1), $@)
asm/real_map.o : $(TARGET).tmp.map
$(TARGET).elf: $(ALL_OBJS_2) $(TARGET).lds $(KERNEL)
- $(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS_2) -o $@, $@)
+ $(call Q,LD, $(CC) $(LDFLAGS_FINAL) -o $@ -T $(TARGET).lds $(ALL_OBJS_2), $@)
$(SUBDIRS):
$(call Q,MKDIR,mkdir -p $@, $@)