refactor(build): simplify ENABLE_LTO checking
We do not support LTO with AArch32. The standard way to enforce this is
by having a rule to fail the build when this happens. There are no
AArch32 platforms which (incorrectly) try to enable LTO, so add this
rule. The benefit is that we no longer have to check the ENABLE_LTO with
ARCH whenever it is used.
Change-Id: Ic4086a1f5122269bda1d75bd4474b98fde35b5af
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
diff --git a/Makefile b/Makefile
index e0b7acc..e5ebad5 100644
--- a/Makefile
+++ b/Makefile
@@ -148,9 +148,7 @@
else ifeq ($($(ARCH)-cc-id),gnu-gcc)
# Enable LTO only for aarch64
- ifeq (${ARCH},aarch64)
- LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto)
- endif
+ LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto)
endif #(clang)
# Process Debug flag
@@ -312,10 +310,8 @@
TF_LDFLAGS += -Wl,--build-id=none
ifeq ($(ENABLE_LTO),1)
- ifeq (${ARCH},aarch64)
- TF_LDFLAGS += -flto -fuse-linker-plugin
- TF_LDFLAGS += -flto-partition=one
- endif
+ TF_LDFLAGS += -flto -fuse-linker-plugin
+ TF_LDFLAGS += -flto-partition=one
endif #(ENABLE_LTO)
# GCC automatically adds fix-cortex-a53-843419 flag when used to link
diff --git a/make_helpers/constraints.mk b/make_helpers/constraints.mk
index 9e2e221..594d77b 100644
--- a/make_helpers/constraints.mk
+++ b/make_helpers/constraints.mk
@@ -236,6 +236,9 @@
# Ensure that no Aarch64-only features are enabled in Aarch32 build
ifeq (${ARCH},aarch32)
+ ifneq (${ENABLE_LTO},0)
+ $(error "ENABLE_LTO is not supported with ARCH=aarch32")
+ endif
# SME/SVE only supported on AArch64
ifneq (${ENABLE_SME_FOR_NS},0)