As requested in the mpc85xx LTO review [1], this sets LTO_ENABLE before arch/arm/config.mk is read, so that 32-bit ARM LTO builds of U-Boot proper leave out -ffunction-sections -fdata-sections.
v1 broke the K3 R5 link [2]. Patch 1 fixes the dangling reference in arch/arm/lib/cache-cp15.c that the missing -ffunction-sections exposed. Patch 2 keeps both flags on ARM64, where U-Boot proper would otherwise grow on 104 of 105 boards, by up to 30240 bytes on i.MX8M. Patch 3 keeps them with SKIP_RELOCATE_CODE, whose data relocation does not expect section anchors. Patch 4 keeps --gc-sections, without which 32-bit U-Boot proper would be 2080 to 10832 bytes larger. Build-tested on all 208 ARM LTO boards in the U-Boot CI container. Patches 1 to 4 change no image. Patch 5 shrinks u-boot-nodtb.bin of the 102 32-bit boards by 896 to 4464 bytes. No other image changes, and NO_LTO=1 builds stay the same. Boot-tested on a Turris Omnia, one of these 32-bit boards, loaded into RAM with kwboot. SPL and U-Boot print the same boot log as on main apart from the version, and the mmc, sf, i2c, usb and wdt commands give the same output. Changes in v2: - Add patch 1 for the K3 R5 link failure, patch 2 for ARM64 and patch 3 for SKIP_RELOCATE_CODE. - Test all 208 LTO boards instead of the 30 with CONFIG_LTO=y, and move the size figures from the patch notes to this cover letter. [1] https://lore.kernel.org/u-boot/20261012190720.GF3722450@bill-the-cat/ [2] https://lore.kernel.org/u-boot/20261020212819.GK720525@bill-the-cat/ v1: https://lore.kernel.org/u-boot/[email protected]/ Josef Schlehofer (5): arm: cache-cp15: Do not reference the MMU helper without an MMU arm: Keep -ffunction-sections -fdata-sections with LTO on ARM64 arm: Keep the section flags with LTO and SKIP_RELOCATE_CODE arm: Keep --gc-sections with LTO Makefile: Set LTO_ENABLE before including config.mk Makefile | 14 +++++++------- arch/arm/config.mk | 4 +--- arch/arm/lib/cache-cp15.c | 2 ++ 3 files changed, 10 insertions(+), 10 deletions(-) -- 2.54.0 (Apple Git-157)
