When LTO is enabled, omit -ffunction-sections and -fdata-sections, as ARM does. This affects U-Boot proper only, as scripts/Makefile.xpl adds both flags for xPL builds anyway.
The change takes effect only once LTO_ENABLE is set before arch/$(ARCH)/config.mk is included. Keep --gc-sections: it drops the .eh_frame sections, which the linker scripts do not place. Signed-off-by: Josef Schlehofer <[email protected]> Cc: Tom Rini <[email protected]> Cc: Marek BehĂșn <[email protected]> --- Changes in v2: - new patch Depends on "Makefile: Set LTO_ENABLE before including config.mk" and follows "arm: Keep --gc-sections with LTO": https://lore.kernel.org/u-boot/[email protected]/ With Debian's GCC 14.2, U-Boot proper of the 71 mpc85xx LTO builds changes by -5302 to +5588 bytes of text and data, and 69 of them shrink. SPL/TPL sizes and builds without LTO are unchanged. --- arch/powerpc/config.mk | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/config.mk b/arch/powerpc/config.mk index 32e86d84a12..557d9360e3b 100644 --- a/arch/powerpc/config.mk +++ b/arch/powerpc/config.mk @@ -3,10 +3,14 @@ # (C) Copyright 2000-2010 # Wolfgang Denk, DENX Software Engineering, [email protected]. +# Keep --gc-sections with LTO: it drops the .eh_frame sections, which the +# linker scripts do not place. LDFLAGS_FINAL += --gc-sections LDFLAGS_FINAL += --bss-plt -PLATFORM_RELFLAGS += -fpic -mrelocatable -ffunction-sections \ --fdata-sections -mcall-linux +PLATFORM_RELFLAGS += -fpic -mrelocatable -mcall-linux +ifneq ($(LTO_ENABLE),y) +PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections +endif PF_CPPFLAGS_POWERPC := $(call cc-option,-fno-ira-hoist-pressure,) $(call cc-option,-Xassembler --fatal-warnings,) PLATFORM_CPPFLAGS += -D__powerpc__ -ffixed-r2 -m32 $(PF_CPPFLAGS_POWERPC) -- 2.54.0 (Apple Git-157)
