This series allows LTO on mpc85xx and enables it for the CZ.NIC Turris 1.x. The Turris NOR image is limited to 768 KiB. LTO, together with dropping NVMe and SCSI from the NOR build, makes room for the ubi command and the BCH ECC code required by the NAND.
The series depends on two generic LTO fixes sent separately, as requested in the v1 review [1]: - "Makefile: Pass -static to the LTO link" [2], which fixes the LTO link with default-PIE toolchains such as Debian's GCC. - "Makefile: Set LTO_ENABLE before including config.mk" (2/2 of [3]), which makes patch 7 effective. The series consists of: 1-2. PowerPC global data: - Drop an unused SPL copy of gd. - Make the global data pointer LTO-safe. 3-5. PowerPC private libgcc: - Add GCC's out-of-line register save and restore routines from Linux. - Add 64-bit division routines. - Select the private libgcc for mpc85xx LTO builds, as the LTO link puts it inside --whole-archive, where a toolchain libgcc does not link. 6-9. mpc85xx LTO support: - Discard the LTO keep-syms section and its fixups. - Drop -ffunction-sections and -fdata-sections with LTO, as ARM does. - Allow CONFIG_LTO=y on mpc85xx. - Pass the make jobserver to xPL links, as GCC 12's lto-wrapper requires. 10-14. Turris 1.x: - Enable LTO. - Select the BCH ECC code required by the NAND. - Make the NVMe and SCSI boot targets conditional. - Add the ubi command to the NOR build. - Put the OTP MAC addresses and serial number into the kernel device tree also after the environment has been reset. Since v2026.10, main's turris_1x_sdcard u-boot.bin has grown from 1046491 to 1049419 bytes, exceeding the 1 MiB that its SPL loads from the card. The build does not catch this. Patch 10 brings the image back below the limit. Patch 11 fixes a separate problem: without it, NAND probing hits BUG(). With Debian's GCC 14.2 and the two generic fixes, turris_1x_nor's u-boot-nodtb.bin shrinks from 757336 to 752000 bytes while gaining LTO, BCH ECC and the ubi command and dropping NVMe and SCSI. The turris_1x_sdcard u-boot.bin shrinks from 1049419 to 997059 bytes. All 83 PowerPC defconfigs build, and all 71 mpc85xx defconfigs link with CONFIG_LTO=y. No .discard* section or zero fixup entry remains. test.py on qemu-ppce500 gives the same results as on main, with and without LTO. The single failing timing test also fails on main. With the kernel.org GCC 14.2 used by CI, both Turris LTO builds fit. With Debian's GCC 12.2 and make 4.3, the Turris SD card SPL links at -j8 only with patch 9. Boot-tested on a Turris 1.1 from NOR and SD card. The NOR build also booted OpenWrt from a kernel in a UBI volume on NAND. Linux received the OTP MAC addresses and serial number even after "env default -a". With the SD card build, ethaddr and serial# values set in the environment were preserved. Other boards were build-tested only. Changes in v2: - Based on main. - Replace "Makefile: Link a toolchain libgcc outside --whole-archive with LTO" with patches 3-5, which make the private libgcc work for mpc85xx LTO builds. - Add patch 7 to drop -ffunction-sections and -fdata-sections with LTO. - Send "Makefile: Skip undefined symbols in keep-syms-lto.c" [4] and "Makefile: Pass -static to the LTO link" separately. - Explain in patch 10 that the SD card image already exceeds 1 MiB without BCH ECC. - Shorten the commit messages of patches 6 and 9. - Keep Marek Mojík's Reviewed-by from v1. His Tested-by is not carried over because the images have changed. [1] https://lore.kernel.org/u-boot/20261012190720.GF3722450@bill-the-cat/ [2] https://lore.kernel.org/u-boot/[email protected]/ [3] https://lore.kernel.org/u-boot/[email protected]/ [4] https://lore.kernel.org/u-boot/[email protected]/ v1: https://lore.kernel.org/u-boot/[email protected]/ Josef Schlehofer (14): board: nxp: p1_p2_rdb_pc, p1010rdb: Drop unused SPL gd copy powerpc: Make the global data pointer LTO safe powerpc: lib: Add GPR save and restore routines to the private libgcc powerpc: lib: Add 64-bit division to the private libgcc powerpc: mpc85xx: Use the private libgcc with LTO powerpc: mpc85xx: Discard LTO keep-syms sections powerpc: Drop -ffunction-sections and -fdata-sections with LTO powerpc: mpc85xx: Allow LTO xpl: Pass the make jobserver to the xPL link configs: turris_1x: Enable LTO mtd: rawnand: fsl_elbc: Select NAND_ECC_BCH board: CZ.NIC: turris_1x: Make NVMe and SCSI boot targets conditional configs: turris_1x_nor: Enable CMD_UBI, drop NVMe and SCSI board: CZ.NIC: turris_1x: Fix up MACs and serial number from OTP arch/powerpc/Kconfig | 2 + arch/powerpc/config.mk | 8 +- arch/powerpc/cpu/mpc83xx/cpu_init.c | 3 +- arch/powerpc/cpu/mpc83xx/spl_minimal.c | 3 +- arch/powerpc/cpu/mpc85xx/cpu_init_early.c | 3 +- arch/powerpc/cpu/mpc85xx/u-boot-spl.lds | 11 +- arch/powerpc/cpu/mpc85xx/u-boot.lds | 11 +- arch/powerpc/include/asm/global_data.h | 30 +++ arch/powerpc/lib/Makefile | 5 +- arch/powerpc/lib/crtsavres.S | 213 ++++++++++++++++++++++ arch/powerpc/lib/gd.c | 14 ++ arch/powerpc/lib/udivdi3.c | 82 +++++++++ board/CZ.NIC/turris_1x/turris_1x.c | 20 ++ board/nxp/p1010rdb/spl.c | 9 +- board/nxp/p1010rdb/spl_minimal.c | 2 +- board/nxp/p1_p2_rdb_pc/p1_p2_rdb_pc.c | 3 + board/nxp/p1_p2_rdb_pc/spl.c | 9 +- board/nxp/p1_p2_rdb_pc/spl_minimal.c | 2 +- board/nxp/t102xrdb/spl.c | 4 +- board/nxp/t104xrdb/spl.c | 4 +- board/nxp/t208xqds/spl.c | 4 +- board/nxp/t208xrdb/spl.c | 4 +- board/nxp/t4rdb/spl.c | 4 +- common/board_r.c | 2 +- common/init/board_init.c | 9 +- common/spl/spl.c | 4 +- configs/kmcoge5ne_defconfig | 1 - configs/turris_1x_nor_defconfig | 10 +- configs/turris_1x_sdcard_defconfig | 2 +- doc/build/gcc.rst | 6 +- drivers/mtd/nand/raw/Kconfig | 2 + include/configs/turris_1x.h | 20 +- scripts/Makefile.xpl | 2 +- 33 files changed, 446 insertions(+), 62 deletions(-) create mode 100644 arch/powerpc/lib/crtsavres.S create mode 100644 arch/powerpc/lib/gd.c create mode 100644 arch/powerpc/lib/udivdi3.c base-commit: 5e3b01c8466dbe45cd6a06299f8f4c7e8c1c2363 prerequisite-patch-id: dd05ac311e66ce2e58bee21495f7a8ec9deb09f8 prerequisite-patch-id: 272fe84ac4b6e21b07a782eeb57a58a4953afa1c -- 2.54.0 (Apple Git-157)
