From d4089fb8d885573a1bca437e036474bf188b54f2 Mon Sep 17 00:00:00 2001 From: Govindraj Raja Date: Tue, 30 May 2023 16:52:15 -0500 Subject: [PATCH] refactor(build): merge march32/64 directives Both march32-directive and march64-directive eventually generate the same march option that will passed to compiler. Merge this two separate directives to a common one as march-directive. Change-Id: I220d2b782eb3b54e13ffd5b6a581d0e6da68756a Signed-off-by: Govindraj Raja --- Makefile | 37 +++++++++++++-------------------- docs/design/firmware-design.rst | 4 ++-- make_helpers/armv7-a-cpus.mk | 8 +++---- plat/qemu/qemu/platform.mk | 2 +- 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 03f93201a..8d3ffe110 100644 --- a/Makefile +++ b/Makefile @@ -217,18 +217,16 @@ endif #(FEAT_RME) ################################################################################ ifeq (${ARM_ARCH_MAJOR},7) target32-directive = -target arm-none-eabi -# Will set march32-directive from platform configuration +# Will set march-directive from platform configuration else target32-directive = -target armv8a-none-eabi # Set the compiler's target architecture profile based on # ARM_ARCH_MAJOR ARM_ARCH_MINOR options ifeq (${ARM_ARCH_MINOR},0) - march32-directive = -march=armv${ARM_ARCH_MAJOR}-a - march64-directive = -march=armv${ARM_ARCH_MAJOR}-a + march-directive = -march=armv${ARM_ARCH_MAJOR}-a else - march32-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a - march64-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a + march-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a endif #(ARM_ARCH_MINOR) endif #(ARM_ARCH_MAJOR) @@ -273,24 +271,20 @@ endif #(SUPPORT_STACK_MEMTAG) # Set the compiler's architecture feature modifiers ifneq ($(arch-features), none) # Strip "none+" from arch-features - arch-features := $(subst none+,,$(arch-features)) - ifeq ($(ARCH), aarch32) - march32-directive := $(march32-directive)+$(arch-features) - else - march64-directive := $(march64-directive)+$(arch-features) - endif + arch-features := $(subst none+,,$(arch-features)) + march-directive := $(march-directive)+$(arch-features) # Print features $(info Arm Architecture Features specified: $(subst +, ,$(arch-features))) endif #(arch-features) ifneq ($(findstring clang,$(notdir $(CC))),) ifneq ($(findstring armclang,$(notdir $(CC))),) - TF_CFLAGS_aarch32 := -target arm-arm-none-eabi $(march32-directive) - TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi $(march64-directive) + TF_CFLAGS_aarch32 := -target arm-arm-none-eabi $(march-directive) + TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi $(march-directive) LD := $(LINKER) else - TF_CFLAGS_aarch32 = $(target32-directive) $(march32-directive) - TF_CFLAGS_aarch64 := -target aarch64-elf $(march64-directive) + TF_CFLAGS_aarch32 = $(target32-directive) $(march-directive) + TF_CFLAGS_aarch64 := -target aarch64-elf $(march-directive) LD := $(shell $(CC) --print-prog-name ld.lld) AR := $(shell $(CC) --print-prog-name llvm-ar) @@ -302,8 +296,8 @@ ifneq ($(findstring clang,$(notdir $(CC))),) PP := $(CC) -E $(TF_CFLAGS_$(ARCH)) AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) else ifneq ($(findstring gcc,$(notdir $(CC))),) - TF_CFLAGS_aarch32 = $(march32-directive) - TF_CFLAGS_aarch64 = $(march64-directive) + TF_CFLAGS_aarch32 = $(march-directive) + TF_CFLAGS_aarch64 = $(march-directive) ifeq ($(ENABLE_LTO),1) # Enable LTO only for aarch64 ifeq (${ARCH},aarch64) @@ -314,8 +308,8 @@ else ifneq ($(findstring gcc,$(notdir $(CC))),) endif LD = $(LINKER) else - TF_CFLAGS_aarch32 = $(march32-directive) - TF_CFLAGS_aarch64 = $(march64-directive) + TF_CFLAGS_aarch32 = $(march-directive) + TF_CFLAGS_aarch64 = $(march-directive) LD = $(LINKER) endif #(clang) @@ -355,8 +349,7 @@ ifneq (${BP_OPTION},none) TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION} endif #(BP_OPTION) -ASFLAGS_aarch32 = $(march32-directive) -ASFLAGS_aarch64 = $(march64-directive) +ASFLAGS += $(march-directive) ############################################################################## # WARNINGS Configuration @@ -444,7 +437,7 @@ endif #(E) ################################################################################ CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ $(ERRORS) $(WARNINGS) -ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \ +ASFLAGS += $(CPPFLAGS) \ -ffreestanding -Wa,--fatal-warnings TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ -ffunction-sections -fdata-sections \ diff --git a/docs/design/firmware-design.rst b/docs/design/firmware-design.rst index 131cca135..3d648c4ef 100644 --- a/docs/design/firmware-design.rst +++ b/docs/design/firmware-design.rst @@ -2733,12 +2733,12 @@ Directive ``ARM_CORTEX_A`` and ``ARM_WITH_NEON`` are used to set the toolchain target architecture directive. Platform may choose to not define straight the toolchain target architecture -directive by defining ``MARCH32_DIRECTIVE``. +directive by defining ``MARCH_DIRECTIVE``. I.e: .. code:: make - MARCH32_DIRECTIVE := -mach=armv7-a + MARCH_DIRECTIVE := -mach=armv7-a Code Structure -------------- diff --git a/make_helpers/armv7-a-cpus.mk b/make_helpers/armv7-a-cpus.mk index eec85cc1e..a8e9d5078 100644 --- a/make_helpers/armv7-a-cpus.mk +++ b/make_helpers/armv7-a-cpus.mk @@ -15,9 +15,9 @@ endif # armClang requires -march=armv7-a for all ARMv7 Cortex-A. To comply with # all, just drop -march and supply only -mcpu. -# Platform can override march32-directive through MARCH32_DIRECTIVE -ifdef MARCH32_DIRECTIVE -march32-directive := $(MARCH32_DIRECTIVE) +# Platform can override march-directive through MARCH_DIRECTIVE +ifdef MARCH_DIRECTIVE +march-directive := $(MARCH_DIRECTIVE) else march32-set-${ARM_CORTEX_A5} := -mcpu=cortex-a5 march32-set-${ARM_CORTEX_A7} := -mcpu=cortex-a7 @@ -29,7 +29,7 @@ march32-neon-$(ARM_WITH_NEON) := -mfpu=neon # default to -march=armv7-a as target directive march32-set-yes ?= -march=armv7-a -march32-directive := ${march32-set-yes} ${march32-neon-yes} +march-directive := ${march32-set-yes} ${march32-neon-yes} endif # Platform may override these extension support directives: diff --git a/plat/qemu/qemu/platform.mk b/plat/qemu/qemu/platform.mk index 7a1dccd0c..56c96a174 100644 --- a/plat/qemu/qemu/platform.mk +++ b/plat/qemu/qemu/platform.mk @@ -12,7 +12,7 @@ ifeq (${ARM_ARCH_MAJOR},7) # Qemu Cortex-A15 model does not implement the virtualization extension. # For this reason, we cannot set ARM_CORTEX_A15=yes and must define all # the ARMv7 build directives. -MARCH32_DIRECTIVE := -mcpu=cortex-a15 +MARCH_DIRECTIVE := -mcpu=cortex-a15 $(eval $(call add_define,ARMV7_SUPPORTS_LARGE_PAGE_ADDRESSING)) $(eval $(call add_define,ARMV7_SUPPORTS_GENERIC_TIMER)) $(eval $(call add_define,ARMV7_SUPPORTS_VFP))