diff --git a/Makefile b/Makefile index 6bbca3bfd..960befc2d 100644 --- a/Makefile +++ b/Makefile @@ -256,10 +256,12 @@ WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \ -Wlogical-op # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523 -TF_CFLAGS += $(call cc_option, --param=min-pagesize=0) +TF_CFLAGS_MIN_PAGE_SIZE := $(call cc_option, --param=min-pagesize=0) +TF_CFLAGS += $(TF_CFLAGS_MIN_PAGE_SIZE) ifeq ($(HARDEN_SLS), 1) - TF_CFLAGS_aarch64 += $(call cc_option, -mharden-sls=all) + TF_CFLAGS_MHARDEN_SLS := $(call cc_option, -mharden-sls=all) + TF_CFLAGS_aarch64 += $(TF_CFLAGS_MHARDEN_SLS) endif else diff --git a/make_helpers/build_macros.mk b/make_helpers/build_macros.mk index b6e64219f..d454efd90 100644 --- a/make_helpers/build_macros.mk +++ b/make_helpers/build_macros.mk @@ -96,6 +96,10 @@ ld_option = $(shell $($(ARCH)-ld) $(1) -Wl,--version >/dev/null 2>&1 || $($(ARCH # Convenience function to check for a given compiler option. A call to # $(call cc_option, --no-XYZ) will return --no-XYZ if supported by the compiler +# NOTE: consider assigning to an immediately expanded temporary variable before +# assigning. This is because variables like TF_CFLAGS are recursively expanded +# and assigning this directly will cause it to be expanded every time the +# variable is used, potentially thrashing multicore performance. define cc_option $(shell if $($(ARCH)-cc) $(1) -c -x c /dev/null -o /dev/null >/dev/null 2>&1; then echo $(1); fi ) endef