Skip to contentSkip to conversation

Makefile: Move PLATFORM_LIBS outside the the whole-archive region

PATCH Superseded Peter Robinson 2 participants 5 messages Nov 21 – Nov 22 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 840d02aa6ca..4323d5ec701 100644
@@ -2103,8 +2103,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
Signature · 1 line
2.56.1
#1 lore raw
Quoted 16 lines · Peter Robinson

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.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index 840d02aa6ca..4323d5ec701 100644

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2110

Quoted 9 lines
Makefile +1 -1
@@ -2103,8 +2103,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

Is this still an issue on the next branch after Josef Schlehofer's series? I'm wondering if the --gc-sections change there fixes this too, or not. Thanks.

Signature · 1 line
Tom
#2 lore raw
Quoted 32 lines · Tom Rini
Quoted 3 lines · Peter Robinson

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),

Quoted 13 lines

so the link fails, e.g. on p3450-0000. Place $(PLATFORM_LIBS) after --no-whole-archive, as the non-LTO link already does.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index 840d02aa6ca..4323d5ec701 100644

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2103

Quoted 1 line
Makefile +0 -0
@@ -2103,8 +2103,8 @@ quiet_cmd_u-boot__ ?= LTO     $@
              -Wl,--whole-archive
     \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2104

Quoted 1 line
Makefile +0 -0
                      $(u-boot-main)
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2105

Quoted 1 line
Makefile +0 -0
                      $(u-boot-keep-syms-lto)
     \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2106

Quoted 1 line
Makefile +0 -1
-                     $(PLATFORM_LIBS)
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2106

Quoted 1 line
Makefile +0 -0
              -Wl,--no-whole-archive
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2107

Quoted 1 line
Makefile +1 -0
+             $(PLATFORM_LIBS)
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2108

Quoted 1 line
Makefile +0 -0
              -Wl,-Map,u-boot.map;
Quoted 8 lines
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2109

Quoted 1 line
Makefile +0 -0
              $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@,

true)

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2110

Quoted 1 line
Makefile +0 -0
 else

Is this still an issue on the next branch after Josef Schlehofer's series? I'm wondering if the --gc-sections change there fixes this too, or not. Thanks.

I haven't tried next, but certainly it wa still a problem on main. I can try that next week though.

#3 lore raw
In reply to Tom Rini
Quoted 32 lines · Tom Rini
Quoted 3 lines · Peter Robinson

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),

Quoted 13 lines

so the link fails, e.g. on p3450-0000. Place $(PLATFORM_LIBS) after --no-whole-archive, as the non-LTO link already does.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index 840d02aa6ca..4323d5ec701 100644

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2103

Quoted 1 line
Makefile +0 -0
@@ -2103,8 +2103,8 @@ quiet_cmd_u-boot__ ?= LTO     $@
              -Wl,--whole-archive
     \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2104

Quoted 1 line
Makefile +0 -0
                      $(u-boot-main)
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2105

Quoted 1 line
Makefile +0 -0
                      $(u-boot-keep-syms-lto)
     \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2106

Quoted 1 line
Makefile +0 -1
-                     $(PLATFORM_LIBS)
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2106

Quoted 1 line
Makefile +0 -0
              -Wl,--no-whole-archive
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2107

Quoted 1 line
Makefile +1 -0
+             $(PLATFORM_LIBS)
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2108

Quoted 1 line
Makefile +0 -0
              -Wl,-Map,u-boot.map;
Quoted 8 lines
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2109

Quoted 1 line
Makefile +0 -0
              $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@,

true)

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2110

Quoted 1 line
Makefile +0 -0
 else

Is this still an issue on the next branch after Josef Schlehofer's series? I'm wondering if the --gc-sections change there fixes this too, or not. Thanks.

Yes, it's still a problem on p3450-0000_defconfig and this patch still fixes it on next.

#4 lore raw
Quoted 39 lines · Peter Robinson
Quoted 37 lines · Tom Rini
Quoted 3 lines · Peter Robinson

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),

Quoted 13 lines

so the link fails, e.g. on p3450-0000. Place $(PLATFORM_LIBS) after --no-whole-archive, as the non-LTO link already does.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index 840d02aa6ca..4323d5ec701 100644

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2103

Quoted 1 line
Makefile +0 -0
@@ -2103,8 +2103,8 @@ quiet_cmd_u-boot__ ?= LTO     $@
              -Wl,--whole-archive
     \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2104

Quoted 1 line
Makefile +0 -0
                      $(u-boot-main)
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2105

Quoted 1 line
Makefile +0 -0
                      $(u-boot-keep-syms-lto)
     \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2106

Quoted 1 line
Makefile +0 -1
-                     $(PLATFORM_LIBS)
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2106

Quoted 1 line
Makefile +0 -0
              -Wl,--no-whole-archive
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2107

Quoted 1 line
Makefile +1 -0
+             $(PLATFORM_LIBS)
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2108

Quoted 1 line
Makefile +0 -0
              -Wl,-Map,u-boot.map;
      \

Makefile quiet_cmd_u-boot__ ?= LTO $@ · line 2109

Quoted 1 line
Makefile +0 -0
              $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@,

true)

Quoted 1 line
Makefile +0 -0
 else
Quoted 7 lines
Quoted 3 lines

Is this still an issue on the next branch after Josef Schlehofer's series? I'm wondering if the --gc-sections change there fixes this too, or not. Thanks.

Yes, it's still a problem on p3450-0000_defconfig and this patch still fixes it on next.

OK, thanks.

Signature · 1 line
Tom