Makefile: Pass -static to the LTO link
PATCH v2 1/1 Makefile: Pass -static to the LTO link
The LTO link runs through the compiler driver. On a toolchain configured with --enable-default-pie, such as Debian's GCC, the driver adds -pie, and links that are not PIE without LTO, such as the SPLs, then get dynamic sections. With Debian's GCC 14.2, imx6dl_mamoj and phycore-rk3288 then exceed their SPL size limits, and turris_omnia its u-boot-with-spl.kwb limit.
Pass -static to the U-Boot and the xPL LTO link, which keeps the driver from adding -pie. ARM passes -pie for U-Boot proper explicitly, so U-Boot proper of the ARM LTO boards does not change. With this patch, all three boards build.
---
Changes in v2:
- send it on its own, outside the mpc85xx LTO series
- rebase on main, with -static next to -nostdlib -nostartfiles
- give the ARM boards that fail on main as the reason
The failures on main, with Debian's GCC 14.2:
imx6dl_mamoj: ld: region `.sram' overflowed by 1016 bytes
phycore-rk3288: Error: SPL image is too large (size 0x8800 than 0x8000)
turris_omnia: u-boot-with-spl.kwb exceeds file size limit:
limit: 0xf0000 bytes
actual: 0xf1200 bytesWith this patch, the SPLs of 16 ARM LTO defconfigs shrink and sandbox does not change. The mpc85xx LTO series needs it as well: without it, turris_1x_nor with LTO does not link with Debian's GCC.
v1: https://lore.kernel.org/u-boot/[email protected]/
--- Makefile | 2 +- scripts/Makefile.xpl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
Makefile +1 -1
@@ -2096,7 +2096,7 @@ ifeq ($(LTO_ENABLE),y) quiet_cmd_u-boot__ ?= LTO $@ cmd_u-boot__ ?= \ touch $(u-boot-main) ; \ - $(CC) -nostdlib -nostartfiles \ + $(CC) -nostdlib -nostartfiles -static \ $(LTO_FINAL_LDFLAGS) $(c_flags) \ $(KBUILD_LDFLAGS:%=-Wl,%) $(LDFLAGS_u-boot:%=-Wl,%) -o $@ \ -T u-boot.lds $(u-boot-init) \
scripts/Makefile.xpl +2 -1
@@ -513,7 +513,8 @@ quiet_cmd_u-boot-spl ?= LTO $@ ( \ cd $(obj) && \ touch $(patsubst $(obj)/%,%,$(u-boot-spl-main)) && \ - $(CC) -nostdlib -nostartfiles $(LTO_FINAL_LDFLAGS) $(c_flags) \ + $(CC) -nostdlib -nostartfiles -static \ + $(LTO_FINAL_LDFLAGS) $(c_flags) \ $(KBUILD_LDFLAGS:%=-Wl,%) $(LDFLAGS_$(@F):%=-Wl,%) \ $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \ -Wl,--whole-archive \
base-commit: 5e3b01c8466dbe45cd6a06299f8f4c7e8c1c2363
Signature · 1 line
2.54.0 (Apple Git-157)
Quoted 8 lines · Josef Schlehofer
The LTO link runs through the compiler driver. On a toolchain configured with --enable-default-pie, such as Debian's GCC, the driver adds -pie, and links that are not PIE without LTO, such as the SPLs, then get dynamic sections. With Debian's GCC 14.2,
imx6dl_mamojand phycore-rk3288 then exceed their SPL size limits, andturris_omniaits u-boot-with-spl.kwb limit.[...]
Applied to u-boot/main, thanks!
[1/1] Makefile: Pass -static to the LTO link
commit: 343472c493b0d2b6177d469dce12ca451c0da352
Signature · 1 line
Tom