Commit a55014d09b29 ("Makefile: Allow LTO to be disabled for a build")
made the condition in arch/arm/config.mk that leaves out
-ffunction-sections -fdata-sections with LTO test LTO_ENABLE. The top
Makefile, however, sets LTO_ENABLE only after it has included config.mk,
which reads arch/$(ARCH)/config.mk, so for U-Boot proper the condition
has seen an empty LTO_ENABLE since then. The xPL builds are not
affected, as scripts/Makefile.xpl adds these flags for them anyway.

Set LTO_ENABLE before config.mk is included. After the previous
patches, this leaves the flags out only for U-Boot proper of the
32-bit LTO boards without SKIP_RELOCATE_CODE.

Fixes: a55014d09b29 ("Makefile: Allow LTO to be disabled for a build")
Signed-off-by: Josef Schlehofer <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Marek BehĂșn <[email protected]>
---
 Makefile | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 6303a0cca6a..547053d7bab 100644
--- a/Makefile
+++ b/Makefile
@@ -819,6 +819,13 @@ u-boot.cfg spl/u-boot.cfg tpl/u-boot.cfg vpl/u-boot.cfg:
 -include include/autoconf.mk
 -include include/autoconf.mk.dep
 
+export LTO_ENABLE
+
+# This is y if LTO is enabled for this build. See NO_LTO=1 to disable LTO
+ifeq ($(NO_LTO),)
+LTO_ENABLE=$(if $(CONFIG_LTO),y)
+endif
+
 # We want to include arch/$(ARCH)/config.mk only when include/config/auto.conf
 # is up-to-date. When we switch to a different board configuration, old CONFIG
 # macros are still remaining in include/config/auto.conf. Without the following
@@ -858,13 +865,6 @@ export CFLAGS_EFI  # Compiler flags to add when building 
EFI app
 export CFLAGS_NON_EFI  # Compiler flags to remove when building EFI app
 export EFI_TARGET      # binutils target if EFI is natively supported
 
-export LTO_ENABLE
-
-# This is y if LTO is enabled for this build. See NO_LTO=1 to disable LTO
-ifeq ($(NO_LTO),)
-LTO_ENABLE=$(if $(CONFIG_LTO),y)
-endif
-
 # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
 # that (or fail if absent).  Otherwise, search for a linker script in a
 # standard location.
-- 
2.54.0 (Apple Git-157)

Reply via email to