summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMarek BehĂșn <marek.behun@nic.cz>2021-05-20 13:24:02 +0200
committerTom Rini <trini@konsulko.com>2021-05-24 14:21:30 -0400
commit958f2e57eff72b5156f7b08b9c1415fb7e12833d (patch)
tree83fd65b7f13e5517cae346db9c37b63d610a4445 /Makefile
parent1445836ca70198471ee7b90ce691a6be2b9322d1 (diff)
downloadu-boot-958f2e57eff72b5156f7b08b9c1415fb7e12833d.tar.gz
u-boot-958f2e57eff72b5156f7b08b9c1415fb7e12833d.tar.xz
u-boot-958f2e57eff72b5156f7b08b9c1415fb7e12833d.zip
build: use thin archives instead of incremental linking
Currently we use incremental linking (ld -r) to link several object files from one directory into one built-in.o object file containing the linked code from that directory (and its subdirectories). Linux has, some time ago, moved to thin archives instead. Thin archives are archives (.a) that do not really contain the object files, only references to them. Using thin archives instead of incremental linking - saves disk space - apparently works better with dead code elimination - makes things easier for LTO The third point is the important one for us. With incremental linking there are several options how to do LTO, and that would unnecessarily complicate things. We have to use the --whole-archive/--no-whole-archive linking option instead of --start-group/--end-group, otherwise linking may fail because of unresolved symbols, or the resulting binary will be unusable. We also need to use the P flag for ar, otherwise final linking may fail. Signed-off-by: Marek BehĂșn <marek.behun@nic.cz> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile4
1 files changed, 2 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 92d2a1ff6a..03f74abe43 100644
--- a/Makefile
+++ b/Makefile
@@ -1713,9 +1713,9 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(ARCH)/Makefile.postlink)
quiet_cmd_u-boot__ ?= LD $@
cmd_u-boot__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@ \
-T u-boot.lds $(u-boot-init) \
- --start-group \
+ --whole-archive \
$(u-boot-main) \
- --end-group \
+ --no-whole-archive \
$(PLATFORM_LIBS) -Map u-boot.map; \
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)