Skip to contentSkip to conversation

Makefile: Move PLATFORM_LIBS outside the the whole-archive region

PATCH New Peter Robinson 1 participant 1 message Nov 23 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Makefile: Move PLATFORM_LIBS outside the the whole-archive region

The LTO link passes $(PLATFORM_LIBS) (-lgcc) inside the --whole-archive region, forcing every libgcc.a member to be linked. On AArch64 this pulls in members needing libc symbols U-Boot lacks (__getauxval, abort, stderr), so the link fails, e.g. on p3450-0000. Place $(PLATFORM_LIBS) after --no-whole-archive, as the non-LTO link already does, on both the main Makefile and the XPL Makefile as they both exhibit the same issue.

---

v2:
- Also Update Makefile.xpl

 Makefile             | 2 +-
 scripts/Makefile.xpl | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Makefile +1 -1
index 519866b82ea..e31b43c3d10 100644
@@ -2093,8 +2093,8 @@ quiet_cmd_u-boot__ ?= LTO     $@
 		-Wl,--whole-archive						\
 			$(u-boot-main)						\
 			$(u-boot-keep-syms-lto)					\
-			$(PLATFORM_LIBS)					\
 		-Wl,--no-whole-archive						\
+		$(PLATFORM_LIBS)						\
 		-Wl,-Map,u-boot.map;						\
 		$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
 else
scripts/Makefile.xpl +1 -1
index 77746ec07cd..3b87586fa7f 100644
@@ -521,8 +521,8 @@ quiet_cmd_u-boot-spl ?= LTO     $@
 			$(patsubst $(obj)/%,%,$(u-boot-spl-main))		\
 			$(patsubst $(obj)/%,%,$(u-boot-spl-platdata))		\
 			$(patsubst $(obj)/%,%,$(u-boot-spl-keep-syms-lto))	\
-			$(PLATFORM_LIBS)					\
 		-Wl,--no-whole-archive						\
+		$(PLATFORM_LIBS)						\
 		-Wl,-Map,$(SPL_BIN).map -o $(SPL_BIN)				\
 	)
 else
Signature · 1 line
2.56.1