arch/arm/toolchain: add greenhills toolchain config

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
This commit is contained in:
guoshichao 2024-06-27 21:32:47 +08:00 committed by Xiang Xiao
parent dd8b630b0d
commit 67f0b5131b
3 changed files with 73 additions and 20 deletions

View File

@ -133,7 +133,7 @@ else
endif
ARCHSCRIPT := $(call CONVERT_PATH,$(ARCHSCRIPT))
LDFLAGS += $(addprefix $(SCRIPT_OPT),$(addsuffix .tmp,$(ARCHSCRIPT))) $(EXTRALINKCMDS)
LDFLAGS += $(SCRIPT_OPT) $(addsuffix .tmp,$(ARCHSCRIPT)) $(EXTRALINKCMDS)
LIBPATHS += $(LIBPATH_OPT) $(call CONVERT_PATH,$(TOPDIR)$(DELIM)staging)
BOARDMAKE = $(if $(wildcard board$(DELIM)Makefile),y,)
@ -199,7 +199,7 @@ define LINK_ALLSYMS_KASAN
$(Q) $(TOPDIR)/tools/kasan_global.py -e $(NUTTX) -o kasan_globals.tmp
$(Q) $(call COMPILE, kasan_globals.tmp, kasan_globals$(OBJEXT) -fno-sanitize=kernel-address, -x c)
$(Q) $(call DELFILE, kasan_globals.tmp))
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
$(Q) $(LD) $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
-o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \
$(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP)
endef
@ -210,7 +210,7 @@ $(addsuffix .tmp,$(ARCHSCRIPT)): $(ARCHSCRIPT)
nuttx$(EXEEXT): $(HEAD_OBJ) board$(DELIM)libboard$(LIBEXT) $(addsuffix .tmp,$(ARCHSCRIPT))
$(Q) echo "LD: nuttx"
ifeq ($(CONFIG_ALLSYMS)$(CONFIG_MM_KASAN_GLOBAL),)
$(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
$(Q) $(LD) $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \
-o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \
$(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP)
else

View File

@ -30,14 +30,25 @@ ifeq ($(CONFIG_ARCH_CORTEXM4),y)
endif
else ifeq ($(CONFIG_ARCH_CORTEXM7),y)
TOOLCHAIN_ARM7EM := y
TOOLCHAIN_MTUNE := -mtune=cortex-m7
TOOLCHAIN_MARCH := -march=armv7e-m
LLVM_CPUTYPE := cortex-m7
ifeq ($(CONFIG_ARCH_FPU),y)
ifeq ($(CONFIG_ARCH_DPFPU),y)
TOOLCHAIN_MFLOAT := -mfpu=fpv5-d16
else
TOOLCHAIN_MFLOAT := -mfpu=fpv5-sp-d16
ifeq ($(CONFIG_ARM_TOOLCHAIN_GHS),y)
TOOLCHAIN_MTUNE := -cpu=cortexm7
ifeq ($(CONFIG_ARCH_FPU),y)
ifeq ($(CONFIG_ARCH_DPFPU),y)
TOOLCHAIN_MFLOAT := -fpu=vfpv3
else
TOOLCHAIN_MFLOAT := -fpu=vfpv3_d16
endif
endif
else
TOOLCHAIN_MTUNE := -mtune=cortex-m7
TOOLCHAIN_MARCH := -march=armv7e-m
LLVM_CPUTYPE := cortex-m7
ifeq ($(CONFIG_ARCH_FPU),y)
ifeq ($(CONFIG_ARCH_DPFPU),y)
TOOLCHAIN_MFLOAT := -mfpu=fpv5-d16
else
TOOLCHAIN_MFLOAT := -mfpu=fpv5-sp-d16
endif
endif
endif
else # ifeq ($(CONFIG_ARCH_CORTEXM3),y)
@ -50,14 +61,26 @@ endif
ifeq ($(CONFIG_ARCH_FPU),y)
LLVM_ABITYPE := eabihf
ifeq ($(CONFIG_ARM_FPU_ABI_SOFT),y)
TOOLCHAIN_MFLOAT += -mfloat-abi=softfp
ifeq ($(CONFIG_ARM_TOOLCHAIN_GHS),y)
ifeq ($(CONFIG_ARM_FPU_ABI_SOFT),y)
TOOLCHAIN_MFLOAT += -fsoft
else
TOOLCHAIN_MFLOAT += -fhard
endif
else
TOOLCHAIN_MFLOAT += -mfloat-abi=hard
ifeq ($(CONFIG_ARM_FPU_ABI_SOFT),y)
TOOLCHAIN_MFLOAT += -mfloat-abi=softfp
else
TOOLCHAIN_MFLOAT += -mfloat-abi=hard
endif
endif
else
LLVM_ABITYPE := eabi
TOOLCHAIN_MFLOAT += -mfloat-abi=soft
LLVM_ABITYPE := eabi
ifeq ($(CONFIG_ARM_TOOLCHAIN_GHS),)
TOOLCHAIN_MFLOAT += -mfloat-abi=soft
else
TOOLCHAIN_MFLOAT += -fsoft
endif
endif
ifeq ($(CONFIG_ARCH_CORTEXM3),y)

View File

@ -247,6 +247,18 @@ else ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y)
LDFLAGS += --diag_suppress=6329
else ifeq ($(CONFIG_ARM_TOOLCHAIN_GHS),y)
CC = ccarm
CXX = cxarm
CPP = ccarm -E
LD = cxarm
STRIP = gstrip
AR = cxarm
NM = gnm
OBJCOPY = objcopy
GMEMFILE = gmemfile
OBJDUMP = gdump
# Default toolchain
else
@ -360,7 +372,9 @@ endif
# Debug link map
ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),)
ifeq ($(CONFIG_ARM_TOOLCHAIN_GHS),y)
LDFLAGS += -map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map)
else 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
@ -369,9 +383,13 @@ ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y)
LDFLAGS += --debug
ifeq ($(CONFIG_ARM_TOOLCHAIN_GHS),)
ARCHOPTIMIZATION += -g
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y)
LDFLAGS += --debug
endif
else
ARCHOPTIMIZATION += -G -gdwarf-2
endif
endif
@ -384,6 +402,18 @@ ifeq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
# then go ahead and try "--print-file-name"
COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB))))
endif
else ifeq ($(CONFIG_ARCH_TOOLCHAIN_GHS),y)
GHS_ROOT_PATH = $(shell which $(CC) | awk -F '/[^/]*$$' '{print $$1}')
COMPILER_RT_LIB := -l$(GHS_ROOT_PATH)/lib/thumb2/libarch
ifeq ($(CONFIG_ARCH_FPU),y)
ifeq ($(CONFIG_ARM_FPU_ABI_SOFT),y)
COMPILER_RT_LIB += -l$(GHS_ROOT_PATH)/lib/thumb2/libind_sf
else
COMPILER_RT_LIB += -l$(GHS_ROOT_PATH)/lib/thumb2/libind_fp
endif
else
COMPILER_RT_LIB += -l$(GHS_ROOT_PATH)/lib/thumb2/libind_sf
endif
endif
EXTRA_LIBS += $(COMPILER_RT_LIB)