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 <govindraj.raja@arm.com>
This commit is contained in:
Govindraj Raja 2023-05-30 16:52:15 -05:00
parent e09b8aa5a5
commit d4089fb8d8
4 changed files with 22 additions and 29 deletions
Makefile
docs/design
make_helpers
plat/qemu/qemu

View file

@ -217,18 +217,16 @@ endif #(FEAT_RME)
################################################################################ ################################################################################
ifeq (${ARM_ARCH_MAJOR},7) ifeq (${ARM_ARCH_MAJOR},7)
target32-directive = -target arm-none-eabi target32-directive = -target arm-none-eabi
# Will set march32-directive from platform configuration # Will set march-directive from platform configuration
else else
target32-directive = -target armv8a-none-eabi target32-directive = -target armv8a-none-eabi
# Set the compiler's target architecture profile based on # Set the compiler's target architecture profile based on
# ARM_ARCH_MAJOR ARM_ARCH_MINOR options # ARM_ARCH_MAJOR ARM_ARCH_MINOR options
ifeq (${ARM_ARCH_MINOR},0) ifeq (${ARM_ARCH_MINOR},0)
march32-directive = -march=armv${ARM_ARCH_MAJOR}-a march-directive = -march=armv${ARM_ARCH_MAJOR}-a
march64-directive = -march=armv${ARM_ARCH_MAJOR}-a
else else
march32-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a march-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
march64-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
endif #(ARM_ARCH_MINOR) endif #(ARM_ARCH_MINOR)
endif #(ARM_ARCH_MAJOR) endif #(ARM_ARCH_MAJOR)
@ -273,24 +271,20 @@ endif #(SUPPORT_STACK_MEMTAG)
# Set the compiler's architecture feature modifiers # Set the compiler's architecture feature modifiers
ifneq ($(arch-features), none) ifneq ($(arch-features), none)
# Strip "none+" from arch-features # Strip "none+" from arch-features
arch-features := $(subst none+,,$(arch-features)) arch-features := $(subst none+,,$(arch-features))
ifeq ($(ARCH), aarch32) march-directive := $(march-directive)+$(arch-features)
march32-directive := $(march32-directive)+$(arch-features)
else
march64-directive := $(march64-directive)+$(arch-features)
endif
# Print features # Print features
$(info Arm Architecture Features specified: $(subst +, ,$(arch-features))) $(info Arm Architecture Features specified: $(subst +, ,$(arch-features)))
endif #(arch-features) endif #(arch-features)
ifneq ($(findstring clang,$(notdir $(CC))),) ifneq ($(findstring clang,$(notdir $(CC))),)
ifneq ($(findstring armclang,$(notdir $(CC))),) ifneq ($(findstring armclang,$(notdir $(CC))),)
TF_CFLAGS_aarch32 := -target arm-arm-none-eabi $(march32-directive) TF_CFLAGS_aarch32 := -target arm-arm-none-eabi $(march-directive)
TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi $(march64-directive) TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi $(march-directive)
LD := $(LINKER) LD := $(LINKER)
else else
TF_CFLAGS_aarch32 = $(target32-directive) $(march32-directive) TF_CFLAGS_aarch32 = $(target32-directive) $(march-directive)
TF_CFLAGS_aarch64 := -target aarch64-elf $(march64-directive) TF_CFLAGS_aarch64 := -target aarch64-elf $(march-directive)
LD := $(shell $(CC) --print-prog-name ld.lld) LD := $(shell $(CC) --print-prog-name ld.lld)
AR := $(shell $(CC) --print-prog-name llvm-ar) AR := $(shell $(CC) --print-prog-name llvm-ar)
@ -302,8 +296,8 @@ ifneq ($(findstring clang,$(notdir $(CC))),)
PP := $(CC) -E $(TF_CFLAGS_$(ARCH)) PP := $(CC) -E $(TF_CFLAGS_$(ARCH))
AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH)) AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
else ifneq ($(findstring gcc,$(notdir $(CC))),) else ifneq ($(findstring gcc,$(notdir $(CC))),)
TF_CFLAGS_aarch32 = $(march32-directive) TF_CFLAGS_aarch32 = $(march-directive)
TF_CFLAGS_aarch64 = $(march64-directive) TF_CFLAGS_aarch64 = $(march-directive)
ifeq ($(ENABLE_LTO),1) ifeq ($(ENABLE_LTO),1)
# Enable LTO only for aarch64 # Enable LTO only for aarch64
ifeq (${ARCH},aarch64) ifeq (${ARCH},aarch64)
@ -314,8 +308,8 @@ else ifneq ($(findstring gcc,$(notdir $(CC))),)
endif endif
LD = $(LINKER) LD = $(LINKER)
else else
TF_CFLAGS_aarch32 = $(march32-directive) TF_CFLAGS_aarch32 = $(march-directive)
TF_CFLAGS_aarch64 = $(march64-directive) TF_CFLAGS_aarch64 = $(march-directive)
LD = $(LINKER) LD = $(LINKER)
endif #(clang) endif #(clang)
@ -355,8 +349,7 @@ ifneq (${BP_OPTION},none)
TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION} TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
endif #(BP_OPTION) endif #(BP_OPTION)
ASFLAGS_aarch32 = $(march32-directive) ASFLAGS += $(march-directive)
ASFLAGS_aarch64 = $(march64-directive)
############################################################################## ##############################################################################
# WARNINGS Configuration # WARNINGS Configuration
@ -444,7 +437,7 @@ endif #(E)
################################################################################ ################################################################################
CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \ CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
$(ERRORS) $(WARNINGS) $(ERRORS) $(WARNINGS)
ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \ ASFLAGS += $(CPPFLAGS) \
-ffreestanding -Wa,--fatal-warnings -ffreestanding -Wa,--fatal-warnings
TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \ TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
-ffunction-sections -fdata-sections \ -ffunction-sections -fdata-sections \

View file

@ -2733,12 +2733,12 @@ Directive ``ARM_CORTEX_A<x>`` and ``ARM_WITH_NEON`` are used to set
the toolchain target architecture directive. the toolchain target architecture directive.
Platform may choose to not define straight the toolchain target architecture Platform may choose to not define straight the toolchain target architecture
directive by defining ``MARCH32_DIRECTIVE``. directive by defining ``MARCH_DIRECTIVE``.
I.e: I.e:
.. code:: make .. code:: make
MARCH32_DIRECTIVE := -mach=armv7-a MARCH_DIRECTIVE := -mach=armv7-a
Code Structure Code Structure
-------------- --------------

View file

@ -15,9 +15,9 @@ endif
# armClang requires -march=armv7-a for all ARMv7 Cortex-A. To comply with # armClang requires -march=armv7-a for all ARMv7 Cortex-A. To comply with
# all, just drop -march and supply only -mcpu. # all, just drop -march and supply only -mcpu.
# Platform can override march32-directive through MARCH32_DIRECTIVE # Platform can override march-directive through MARCH_DIRECTIVE
ifdef MARCH32_DIRECTIVE ifdef MARCH_DIRECTIVE
march32-directive := $(MARCH32_DIRECTIVE) march-directive := $(MARCH_DIRECTIVE)
else else
march32-set-${ARM_CORTEX_A5} := -mcpu=cortex-a5 march32-set-${ARM_CORTEX_A5} := -mcpu=cortex-a5
march32-set-${ARM_CORTEX_A7} := -mcpu=cortex-a7 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 # default to -march=armv7-a as target directive
march32-set-yes ?= -march=armv7-a march32-set-yes ?= -march=armv7-a
march32-directive := ${march32-set-yes} ${march32-neon-yes} march-directive := ${march32-set-yes} ${march32-neon-yes}
endif endif
# Platform may override these extension support directives: # Platform may override these extension support directives:

View file

@ -12,7 +12,7 @@ ifeq (${ARM_ARCH_MAJOR},7)
# Qemu Cortex-A15 model does not implement the virtualization extension. # Qemu Cortex-A15 model does not implement the virtualization extension.
# For this reason, we cannot set ARM_CORTEX_A15=yes and must define all # For this reason, we cannot set ARM_CORTEX_A15=yes and must define all
# the ARMv7 build directives. # 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_LARGE_PAGE_ADDRESSING))
$(eval $(call add_define,ARMV7_SUPPORTS_GENERIC_TIMER)) $(eval $(call add_define,ARMV7_SUPPORTS_GENERIC_TIMER))
$(eval $(call add_define,ARMV7_SUPPORTS_VFP)) $(eval $(call add_define,ARMV7_SUPPORTS_VFP))