From: Marek BehĂșn <marek.behun@nic.cz>
Date: Thu, 20 May 2021 11:24:24 +0000 (+0200)
Subject: ARM: don't use --gc-sections with LTO when using private libgcc
X-Git-Tag: v2025.01-rc5-pxa1908~1867^2~2
X-Git-Url: http://git.dujemihanovic.xyz/img/html/static/%7B%7B?a=commitdiff_plain;h=34ccadcd3334d695806acb84e4d4e5f4ef322e9e;p=u-boot.git

ARM: don't use --gc-sections with LTO when using private libgcc

When using LTO, we can throw away the --gc-sections flag, but only if
using private libgcc.

When using system's libgcc, --gc-sections is still needed, otherwise
linking will fail due to undefined references to libc's symbols.

Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index f556ee3329..16c63e1266 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -15,7 +15,9 @@ CFLAGS_NON_EFI := -fno-pic -ffixed-r9 -ffunction-sections -fdata-sections \
 		  -fstack-protector-strong
 CFLAGS_EFI := -fpic -fshort-wchar
 
+ifneq ($(CONFIG_LTO)$(CONFIG_USE_PRIVATE_LIBGCC),yy)
 LDFLAGS_FINAL += --gc-sections
+endif
 
 ifndef CONFIG_LTO
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections