From fa402f38b2c326f33d0989450ca62c1002d7d062 Mon Sep 17 00:00:00 2001 From: Chris Kay <chris.kay@arm.com> Date: Tue, 20 Feb 2024 16:19:54 +0000 Subject: [PATCH] build: allow platform makefiles to configure `ENABLE_LTO` This change introduces a lazily-evaluated condition on `ENABLE_LTO` to the `LTO_CFLAGS` variable as opposed to evaluating the condition eagerly. This concludes a recent request on the mailing list: https://lists.trustedfirmware.org/archives/list/tf-a@lists.trustedfirmware.org/thread/EU3XR4VB3RP2NQB372QPZ4VRP57ANNLC/ Change-Id: Ie1f73352eb51fb2ceb2385232336312216ef87fc Signed-off-by: Chris Kay <chris.kay@arm.com> --- Makefile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 603c8d9bd..ef570b2f6 100644 --- a/Makefile +++ b/Makefile @@ -155,11 +155,9 @@ ifneq ($(filter %-clang,$($(ARCH)-cc-id)),) endif else ifeq ($($(ARCH)-cc-id),gnu-gcc) - ifeq ($(ENABLE_LTO),1) - # Enable LTO only for aarch64 - ifeq (${ARCH},aarch64) - LTO_CFLAGS = -flto - endif + # Enable LTO only for aarch64 + ifeq (${ARCH},aarch64) + LTO_CFLAGS = $(if $(filter-out 0,$(ENABLE_LTO)),-flto) endif endif #(clang)