diff options
author | zelalem-aweke <zelalem.aweke@arm.com> | 2019-11-12 16:20:17 -0600 |
---|---|---|
committer | zelalem-aweke <zelalem.aweke@arm.com> | 2019-12-02 09:23:43 -0600 |
commit | edbce9aad48fe71a6fed0df8d56eebb61e44632e (patch) | |
tree | 9e8f17d1c9df4e040c3847b42911e4d5bc0bc554 /make_helpers/build_macros.mk | |
parent | 76f25eb52b10d56b8b54fc63d748c15e428e409a (diff) | |
download | arm-trusted-firmware-edbce9aad48fe71a6fed0df8d56eebb61e44632e.tar.gz |
Enable Link Time Optimization in GCC
This patch enables LTO for TF-A when compiled with GCC.
LTO is disabled by default and is enabled by
ENABLE_LTO=1 build option.
LTO is enabled only for aarch64 as there seem to be
a bug in the aarch32 compiler when LTO is enabled.
The changes in the makefiles include:
- Adding -flto and associated flags to enable LTO.
- Using gcc as a wrapper at link time instead of ld.
This is recommended when using LTO as gcc internally
takes care of invoking the necessary plugins for LTO.
- Adding switches to pass options to ld.
- Adding a flag to disable fix for erratum cortex-a53-843419
unless explicitly enabled. This is needed because GCC
seem to automatically add the erratum fix when used
as a wrapper for LD.
Additionally, this patch updates the TF-A user guide with
the new build option.
Signed-off-by: zelalem-aweke <zelalem.aweke@arm.com>
Change-Id: I1188c11974da98434b7dc9344e058cd1eacf5468
Diffstat (limited to 'make_helpers/build_macros.mk')
-rw-r--r-- | make_helpers/build_macros.mk | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/make_helpers/build_macros.mk b/make_helpers/build_macros.mk index b89d87ea6..47f3ebd86 100644 --- a/make_helpers/build_macros.mk +++ b/make_helpers/build_macros.mk @@ -236,7 +236,7 @@ $(eval BL_CFLAGS := $(BL$(call uppercase,$(3))_CFLAGS)) $(OBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | bl$(3)_dirs $$(ECHO) " CC $$<" - $$(Q)$$(CC) $$(TF_CFLAGS) $$(CFLAGS) $(BL_CFLAGS) -D$(IMAGE) $(MAKE_DEP) -c $$< -o $$@ + $$(Q)$$(CC) $$(LTO_CFLAGS) $$(TF_CFLAGS) $$(CFLAGS) $(BL_CFLAGS) -D$(IMAGE) $(MAKE_DEP) -c $$< -o $$@ -include $(DEP) @@ -433,6 +433,10 @@ ifneq ($(findstring armlink,$(notdir $(LD))),) --map --list="$(MAPFILE)" --scatter=${PLAT_DIR}/scat/bl${1}.scat \ $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS) \ $(BUILD_DIR)/build_message.o $(OBJS) +else ifneq ($(findstring gcc,$(notdir $(LD))),) + $$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) -Wl,-Map=$(MAPFILE) \ + -Wl,-T$(LINKERFILE) $(BUILD_DIR)/build_message.o \ + $(OBJS) $(LDPATHS) $(LIBWRAPPER) $(LDLIBS) $(BL_LIBS) else $$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) -Map=$(MAPFILE) \ --script $(LINKERFILE) $(BUILD_DIR)/build_message.o \ |