[PATCH u-boot 18/39] build: LTO: move platform libs into --start-group list

Marek Behún marek.behun at nic.cz
Sun Mar 7 05:25:17 CET 2021


When building with LTO, move $(PLATFORM_LIBS) into the --start-group /
--end-group list.
Otherwise some functions declared in assembly may not be resolved and
linking may fail.

Signed-off-by: Marek Behún <marek.behun at nic.cz>
---
 Makefile             | 3 ++-
 scripts/Makefile.spl | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 4eee0c4196..0f538270d7 100644
--- a/Makefile
+++ b/Makefile
@@ -1782,8 +1782,9 @@ quiet_cmd_u-boot__ ?= LTO     $@
 		-T u-boot.lds $(u-boot-init)					\
 		-Wl,--start-group -Wl,--whole-archive				\
 			$(u-boot-main)						\
+			$(PLATFORM_LIBS)					\
 		-Wl,--no-whole-archive -Wl,--end-group				\
-		$(PLATFORM_LIBS) -Wl,-Map,u-boot.map;				\
+		-Wl,-Map,u-boot.map;						\
 		$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
 else
 quiet_cmd_u-boot__ ?= LD      $@
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 6da5883442..d89917ca8e 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -428,8 +428,9 @@ quiet_cmd_u-boot-spl ?= LTO     $@
 		-Wl,--start-group -Wl,--whole-archive				\
 			$(patsubst $(obj)/%,%,$(u-boot-spl-main))		\
 			$(patsubst $(obj)/%,%,$(u-boot-spl-platdata))		\
+			$(PLATFORM_LIBS)					\
 		-Wl,--no-whole-archive -Wl,--end-group				\
-		$(PLATFORM_LIBS) -Wl,-Map,$(SPL_BIN).map -o $(SPL_BIN)		\
+		-Wl,-Map,$(SPL_BIN).map -o $(SPL_BIN)				\
 			)
 else
 quiet_cmd_u-boot-spl ?= LD      $@
-- 
2.26.2



More information about the U-Boot mailing list