All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] arm: Make the LTO conditions in arch/arm/config.mk take effect
@ 2026-10-13  7:43 Josef Schlehofer
  2026-10-13  7:43 ` [PATCH 1/2] arm: Keep --gc-sections with LTO Josef Schlehofer
  2026-10-13  7:43 ` [PATCH 2/2] Makefile: Set LTO_ENABLE before including config.mk Josef Schlehofer
  0 siblings, 2 replies; 3+ messages in thread
From: Josef Schlehofer @ 2026-10-13  7:43 UTC (permalink / raw)
  To: u-boot

As requested in the review of the mpc85xx LTO series [1], this sets
LTO_ENABLE before the top Makefile reads arch/arm/config.mk, so that
U-Boot proper of the ARM LTO boards is no longer built with
-ffunction-sections -fdata-sections.

The first patch keeps --gc-sections, which the same change would
otherwise drop for LTO with the private libgcc, making most of these
images larger.

[1] https://lore.kernel.org/u-boot/20261012190720.GF3722450@bill-the-cat/

Josef Schlehofer (2):
  arm: Keep --gc-sections with LTO
  Makefile: Set LTO_ENABLE before including config.mk

 Makefile           | 14 +++++++-------
 arch/arm/config.mk |  2 --
 2 files changed, 7 insertions(+), 9 deletions(-)


base-commit: 5e3b01c8466dbe45cd6a06299f8f4c7e8c1c2363
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] arm: Keep --gc-sections with LTO
  2026-10-13  7:43 [PATCH 0/2] arm: Make the LTO conditions in arch/arm/config.mk take effect Josef Schlehofer
@ 2026-10-13  7:43 ` Josef Schlehofer
  2026-10-13  7:43 ` [PATCH 2/2] Makefile: Set LTO_ENABLE before including config.mk Josef Schlehofer
  1 sibling, 0 replies; 3+ messages in thread
From: Josef Schlehofer @ 2026-10-13  7:43 UTC (permalink / raw)
  To: u-boot; +Cc: Tom Rini, Marek Behún, Simon Glass

Commit 34ccadcd3334 ("ARM: don't use --gc-sections with LTO when using
private libgcc") left out --gc-sections for LTO builds that use the
private libgcc. Since commit a55014d09b29 ("Makefile: Allow LTO to be
disabled for a build"), the condition tests LTO_ENABLE, which the top
Makefile sets only after it has read arch/arm/config.mk, so U-Boot
proper has been linked with --gc-sections ever since.

Once the next patch sets LTO_ENABLE in time, the condition would take
effect again. U-Boot proper would then grow on most of these boards and
keep the .discard.addressable section of keep-syms-lto.o in its ELF
file. Keep --gc-sections for all builds; this changes no image on main.

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Marek Behún <kabel@kernel.org>
Cc: Simon Glass <sjg@chromium.org>
---
With Debian's GCC 14.2 and the next patch, but without this one, U-Boot
proper grows on 18 of the 25 ARM LTO defconfigs that use the private
libgcc, by up to 6728 bytes. With both patches, all 25 shrink by 896 to
4512 bytes.
---
 arch/arm/config.mk | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index bce9a31e966..a10b2022d4e 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -13,9 +13,7 @@ CFLAGS_NON_EFI := -fno-pic $(FIXED_REG) -ffunction-sections -fdata-sections \
 		  -fstack-protector-strong
 CFLAGS_EFI := -fpic -fshort-wchar
 
-ifneq ($(LTO_ENABLE)$(CONFIG_USE_PRIVATE_LIBGCC),yy)
 LDFLAGS_FINAL += --gc-sections
-endif
 
 ifneq ($(LTO_ENABLE),y)
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] Makefile: Set LTO_ENABLE before including config.mk
  2026-10-13  7:43 [PATCH 0/2] arm: Make the LTO conditions in arch/arm/config.mk take effect Josef Schlehofer
  2026-10-13  7:43 ` [PATCH 1/2] arm: Keep --gc-sections with LTO Josef Schlehofer
@ 2026-10-13  7:43 ` Josef Schlehofer
  1 sibling, 0 replies; 3+ messages in thread
From: Josef Schlehofer @ 2026-10-13  7:43 UTC (permalink / raw)
  To: u-boot; +Cc: Tom Rini, Simon Glass, Marek Behún

Commit a55014d09b29 ("Makefile: Allow LTO to be disabled for a build")
made the condition in arch/arm/config.mk that leaves out
-ffunction-sections -fdata-sections with LTO test LTO_ENABLE. The top
Makefile, however, sets LTO_ENABLE only after it has included config.mk,
which reads arch/$(ARCH)/config.mk, so for U-Boot proper the condition
has seen an empty LTO_ENABLE since then. The xPL builds are not
affected, as scripts/Makefile.xpl adds these flags for them anyway.

Set LTO_ENABLE before config.mk is included.

Fixes: a55014d09b29 ("Makefile: Allow LTO to be disabled for a build")
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Marek Behún <kabel@kernel.org>
---
As requested in
https://lore.kernel.org/u-boot/20261012190720.GF3722450@bill-the-cat/

With Debian's GCC 14.2, this changes u-boot-nodtb.bin of the 27 ARM LTO
defconfigs that build on main by -7720 to +2144 bytes; the 22 of them
that use the private libgcc all shrink. Their SPLs do not change, and
neither does sandbox, whose config.mk does not test LTO_ENABLE.

The other three ARM LTO defconfigs, imx6dl_mamoj, phycore-rk3288 and
turris_omnia, do not build on main with Debian's GCC 14.2, with or
without this patch. "Makefile: Pass -static to the LTO link", sent
separately, makes them build; with it, this patch changes their
u-boot-nodtb.bin by -4512, -4112 and -3560 bytes, and turris_omnia
u-boot-with-spl.kwb goes from 976640 to 973056 bytes, against a limit
of 983040 bytes.
---
 Makefile | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 6303a0cca6a..547053d7bab 100644
--- a/Makefile
+++ b/Makefile
@@ -819,6 +819,13 @@ u-boot.cfg spl/u-boot.cfg tpl/u-boot.cfg vpl/u-boot.cfg:
 -include include/autoconf.mk
 -include include/autoconf.mk.dep
 
+export LTO_ENABLE
+
+# This is y if LTO is enabled for this build. See NO_LTO=1 to disable LTO
+ifeq ($(NO_LTO),)
+LTO_ENABLE=$(if $(CONFIG_LTO),y)
+endif
+
 # We want to include arch/$(ARCH)/config.mk only when include/config/auto.conf
 # is up-to-date. When we switch to a different board configuration, old CONFIG
 # macros are still remaining in include/config/auto.conf. Without the following
@@ -858,13 +865,6 @@ export CFLAGS_EFI	# Compiler flags to add when building EFI app
 export CFLAGS_NON_EFI	# Compiler flags to remove when building EFI app
 export EFI_TARGET	# binutils target if EFI is natively supported
 
-export LTO_ENABLE
-
-# This is y if LTO is enabled for this build. See NO_LTO=1 to disable LTO
-ifeq ($(NO_LTO),)
-LTO_ENABLE=$(if $(CONFIG_LTO),y)
-endif
-
 # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
 # that (or fail if absent).  Otherwise, search for a linker script in a
 # standard location.
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-13  7:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13  7:43 [PATCH 0/2] arm: Make the LTO conditions in arch/arm/config.mk take effect Josef Schlehofer
2026-10-13  7:43 ` [PATCH 1/2] arm: Keep --gc-sections with LTO Josef Schlehofer
2026-10-13  7:43 ` [PATCH 2/2] Makefile: Set LTO_ENABLE before including config.mk Josef Schlehofer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.