RFC: arm: Enable LTO by default
At this point, we have had wide enough testing of LTO on ARM platforms
that we should 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@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.
[0]: https://lore.kernel.org/u-boot/783cfab5-feb0-1148-f4be-125195275c98@gmx.de/
diff --git a/Kconfig b/Kconfig
index a75cce7..14693a9 100644
--- a/Kconfig
+++ b/Kconfig
@@ -121,6 +121,8 @@
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 aa6bf93..820f78e 100644
--- a/configs/qemu_arm_defconfig
+++ b/configs/qemu_arm_defconfig
@@ -16,6 +16,7 @@
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