[PATCH 6/6] RFC: arm: Enable LTO by default

Tom Rini trini at konsulko.com
Thu Mar 9 17:22:12 CET 2023


At this point, we have had wide enough testing of LTO on ARM platforms
that we hope to have covered all of the issues that linking in manner
exposes in terms of run-time failures. Note that on 32bit ARM we must
use our private libgcc in order to ensure that we do not have a size
mismatch over wchar_t, and we're missing some thumb1 assembly functions
for LTO to be usable in that case. Enable this by default, on ARM.

Signed-off-by: Tom Rini <trini at konsulko.com>
---
This is not yet ready to go. As noted in this[0] thread there's some
issues with weak functions. In addition, platforms such as
socfpga_n5x_vab (and _atf) have their SPL grow and meesc_dataflash grows
itself. This seems to be in part due to how the
sha1_process_one/sha256_process_one abstractions interact with LTO.
There might be more issues like this, but it's harder to spot just due
to how LTO will essentially inline a large number of functions.

Further, my pine64_plus fails to boot with LTO and loops on:
U-Boot SPL 2023.04-rc3-00196-gbe79da84c30b-dirty (Mar 08 2023 - 16:10:56 -0500)
DRAM: 1024 MiB
Trying to boot from MMC1
Trying to boot from MMC1 (repeats)

So this very much isn't ready for everyone, just yet.

[0]: https://lore.kernel.org/u-boot/783cfab5-feb0-1148-f4be-125195275c98@gmx.de/
---
 Kconfig                    | 2 ++
 configs/qemu_arm_defconfig | 1 +
 2 files changed, 3 insertions(+)

diff --git a/Kconfig b/Kconfig
index a75cce7e28fb..14693a92c1b3 100644
--- a/Kconfig
+++ b/Kconfig
@@ -121,6 +121,8 @@ config ARCH_SUPPORTS_LTO
 config LTO
 	bool "Enable Link Time Optimizations"
 	depends on ARCH_SUPPORTS_LTO
+	select USE_PRIVATE_LIBGCC if ARM && !ARM64
+	default y if ARM && !(SYS_THUMB_BUILD || SPL_SYS_THUMB_BUILD)
 	help
 	  This option enables Link Time Optimization (LTO), a mechanism which
 	  allows the compiler to optimize between different compilation units.
diff --git a/configs/qemu_arm_defconfig b/configs/qemu_arm_defconfig
index aa6bf931b5fd..820f78e76311 100644
--- a/configs/qemu_arm_defconfig
+++ b/configs/qemu_arm_defconfig
@@ -16,6 +16,7 @@ CONFIG_SYS_LOAD_ADDR=0x40200000
 CONFIG_ENV_ADDR=0x4000000
 CONFIG_DEBUG_UART=y
 CONFIG_AHCI=y
+# CONFIG_LTO is not set
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
-- 
2.34.1



More information about the U-Boot mailing list