arch/arm: add support for armclang compiler(AC6)

Reference:
https://developer.arm.com/Tools%20and%20Software/Arm%20Compiler%20for%20Embedded

Signed-off-by: chao an <anchao@xiaomi.com>
Signed-off-by: sheyunhu <sheyunhu@xiaomi.com>
This commit is contained in:
chao an 2022-09-15 22:16:36 +08:00 committed by Xiang Xiao
parent 54aa91f02b
commit 7dbaa4f4c4
8 changed files with 168 additions and 20 deletions

View File

@ -42,6 +42,10 @@ config ARM_TOOLCHAIN_CLANG
bool "Generic Clang toolchain"
select ARCH_TOOLCHAIN_CLANG
config ARM_TOOLCHAIN_ARMCLANG
bool "ARM Compiler Clang toolchain"
select ARCH_TOOLCHAIN_CLANG
endchoice
choice

View File

@ -85,37 +85,45 @@ UOBJS = $(UAOBJS) $(UCOBJS)
KBIN = libkarch$(LIBEXT)
BIN = libarch$(LIBEXT)
LDFLAGS += $(addprefix -T,$(call CONVERT_PATH,$(ARCHSCRIPT))) $(EXTRALINKCMDS)
# Override in Make.defs if linker is not 'ld'
ifeq ($(LD),$(CC))
LDSTARTGROUP ?= -Wl,--start-group
LDENDGROUP ?= -Wl,--end-group
LDFLAGS := $(addprefix -Xlinker ,$(LDFLAGS))
LDFLAGS += $(CFLAGS)
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),)
ifeq ($(LD),$(CC))
LDSTARTGROUP ?= -Wl,--start-group
LDENDGROUP ?= -Wl,--end-group
LDFLAGS := $(addprefix -Xlinker ,$(LDFLAGS))
LDFLAGS += $(CFLAGS)
else
LDSTARTGROUP ?= --start-group
LDENDGROUP ?= --end-group
endif
LIBPATH_OPT = -L
SCRIPT_OPT = -T
else
LDSTARTGROUP ?= --start-group
LDENDGROUP ?= --end-group
LIBPATH_OPT = --userlibpath
EXTRA_LIBS += arm_vectors.o
SCRIPT_OPT = --scatter=
endif
LDFLAGS += $(addprefix $(SCRIPT_OPT),$(call CONVERT_PATH,$(ARCHSCRIPT))) $(EXTRALINKCMDS)
LIBPATHS += $(LIBPATH_OPT) $(call CONVERT_PATH,$(TOPDIR)$(DELIM)staging)
BOARDMAKE = $(if $(wildcard board$(DELIM)Makefile),y,)
LIBPATHS += -L $(call CONVERT_PATH,$(TOPDIR)$(DELIM)staging)
ifeq ($(BOARDMAKE),y)
LIBPATHS += -L $(call CONVERT_PATH,$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board)
LIBPATHS += $(LIBPATH_OPT) $(call CONVERT_PATH,$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board)
endif
LDLIBS = $(patsubst %.a,%,$(patsubst lib%,-l%,$(LINKLIBS)))
LDLIBS = $(patsubst %.a,%,$(patsubst lib%,--library=%,$(LINKLIBS)))
ifeq ($(BOARDMAKE),y)
LDLIBS += -lboard
LDLIBS += --library=board
endif
VPATH += chip
VPATH += common
VPATH += $(ARCH_SUBDIR)
ifeq ($(CONFIG_ARCH_TOOLCHAIN_IAR),y)
ifeq ($(CONFIG_ARM_TOOLCHAIN_IAR),y)
VPATH += common$(DELIM)iar
else # ifeq ($(CONFIG_ARCH_TOOLCHAIN_GNU),y)
VPATH += common$(DELIM)gnu

View File

@ -27,6 +27,8 @@ TOOLCHAIN_MFLOAT := -mfloat-abi=soft
ifeq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y)
TOOLCHAIN_MARCH := --config armv6m_soft_nofp_nosys
else ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y)
LDFLAGS += --cpu=Cortex-M0
endif
include $(TOPDIR)/arch/arm/src/common/Toolchain.defs

View File

@ -61,4 +61,26 @@ else
ARCHCPUFLAGS += -mfloat-abi=soft
endif
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y)
ifeq ($(CONFIG_ARCH_CORTEXA5),y)
LDCPUFLAGS = Cortex-A5
else ifeq ($(CONFIG_ARCH_CORTEXA7),y)
LDCPUFLAGS = Cortex-A7
else ifeq ($(CONFIG_ARCH_CORTEXA8),y)
LDCPUFLAGS = Cortex-A8
else ifeq ($(CONFIG_ARCH_CORTEXA9),y)
LDCPUFLAGS = Cortex-A9
endif
ifeq ($(CONFIG_ARCH_FPU),)
LDFLAGS += --cpu=$(LDCPUFLAGS).no_neon.no_vfp
else ifeq ($(CONFIG_ARM_NEON),)
LDFLAGS += --cpu=$(LDCPUFLAGS).no_neon
else
LDFLAGS += --cpu=$(LDCPUFLAGS)
endif
endif
include $(TOPDIR)/arch/arm/src/common/Toolchain.defs

View File

@ -75,6 +75,28 @@ ifeq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y)
TOOLCHAIN_MARCH += --config armv7m_soft_nofp_nosys
endif
else ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y)
ifeq ($(CONFIG_ARCH_CORTEXM4),y)
ifeq ($(CONFIG_ARCH_FPU),y)
LDFLAGS += --cpu=Cortex-M4
else
LDFLAGS += --cpu=Cortex-M4.no_fp
endif
else ifeq ($(CONFIG_ARCH_CORTEXM7),y)
ifeq ($(CONFIG_ARCH_FPU),y)
ifeq ($(CONFIG_ARCH_DPFPU),y)
LDFLAGS += --cpu=Cortex-M7
else
LDFLAGS += --cpu=Cortex-M7.fp.sp
endif
else
LDFLAGS += --cpu=Cortex-M7.no_fp
endif
else # ifeq ($(CONFIG_ARCH_CORTEXM3),y)
LDFLAGS += --cpu=Cortex-M3
endif
endif
ifeq ($(CONFIG_ARMV7M_STACKCHECK),y)

View File

@ -37,4 +37,24 @@ else
ARCHCPUFLAGS += -mfloat-abi=soft
endif
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y)
ifeq ($(CONFIG_ARCH_CORTEXR4),y)
LDFLAGS += --cpu=Cortex-R4
else ifeq ($(CONFIG_ARCH_CORTEXR5),y)
ifeq ($(CONFIG_ARCH_FPU),y)
LDFLAGS += --cpu=Cortex-R5
else
LDFLAGS += --cpu=Cortex-R5.no_vfp
endif
else ifeq ($(CONFIG_ARCH_CORTEXR7),y)
ifeq ($(CONFIG_ARCH_FPU),y)
LDFLAGS += --cpu=Cortex-R7
else
LDFLAGS += --cpu=Cortex-R7.no_vfp
endif
endif
endif
include $(TOPDIR)/arch/arm/src/common/Toolchain.defs

View File

@ -84,6 +84,38 @@ ifeq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y)
endif
endif
else ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y)
ifeq ($(CONFIG_ARCH_CORTEXM23),y)
LDFLAGS += --cpu=Cortex-M23
else ifeq ($(CONFIG_ARCH_CORTEXM33),y)
ifeq ($(CONFIG_ARCH_FPU),y)
LDFLAGS += --cpu=Cortex-M33
else
LDFLAGS += --cpu=Cortex-M33.no_fp
endif
else ifeq ($(CONFIG_ARCH_CORTEXM35P),y)
ifeq ($(CONFIG_ARCH_FPU),y)
LDFLAGS += --cpu=Cortex-M35P
else
LDFLAGS += --cpu=Cortex-M35P.no_fp
endif
else ifeq ($(CONFIG_ARCH_CORTEXM55),y)
ifeq ($(CONFIG_ARM_HAVE_MVE),y)
ifeq ($(CONFIG_ARCH_FPU),y)
LDFLAGS += --cpu=Cortex-M55
else
LDFLAGS += --cpu=Cortex-M55.no_fp
endif
else
ifeq ($(CONFIG_ARCH_FPU),y)
LDFLAGS += --cpu=Cortex-M55.no_mve
else
LDFLAGS += --cpu=Cortex-M55.no_mve.no_fp
endif
endif
endif
endif
ifeq ($(CONFIG_ARMV8M_STACKCHECK),y)

View File

@ -131,6 +131,32 @@ ifeq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y)
ARCHOPTIMIZATION += -fno-builtin
# ARM Compiler Clang toolchain
else ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y)
CC = armclang
CXX = armclang
CPP = armclang -E -P -x c
LD = armlink
STRIP = llvm-strip --strip-unneeded
AR = armar -rcs
NM = llvm-nm
OBJCOPY = llvm-objcopy
OBJDUMP = llvm-objdump
# Since the no_builtin attribute is not fully supported on Clang
# disable the built-in functions, refer:
# https://github.com/apache/incubator-nuttx/pull/5971
ARCHOPTIMIZATION += -fno-builtin
ARCHOPTIMIZATION += --target=arm-arm-none-eabi
# Suppress license warning
ARCHCPUFLAGS += -Wno-license-management
LDFLAGS += --diag_suppress=9931
# Default toolchain
else
@ -174,23 +200,35 @@ endif
ARCHOPTIMIZATION += -fno-common -Wall -Wshadow -Wundef
ARCHOPTIMIZATION += -nostdlib
LDFLAGS += -nostdlib
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),)
LDFLAGS += -nostdlib
endif
# Optimization of unused sections
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
LDFLAGS += --gc-sections
ARCHOPTIMIZATION += -ffunction-sections -fdata-sections
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),)
ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y)
LDFLAGS += --gc-sections
ARCHOPTIMIZATION += -ffunction-sections -fdata-sections
endif
endif
# Debug link map
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),)
LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
else
LDFLAGS += --strict --map --xref --symbols --info=unused --info=veneers
LDFLAGS += --info=summarysizes --info=summarystack
endif
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y)
LDFLAGS += --debug
endif
endif
# Add the builtin library