diff --git a/arch/arm/src/Makefile b/arch/arm/src/Makefile index 2c3326f642..2c7630f07c 100644 --- a/arch/arm/src/Makefile +++ b/arch/arm/src/Makefile @@ -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 diff --git a/arch/arm/src/armv7-m/Toolchain.defs b/arch/arm/src/armv7-m/Toolchain.defs index 86c7a666a3..039ad179f7 100644 --- a/arch/arm/src/armv7-m/Toolchain.defs +++ b/arch/arm/src/armv7-m/Toolchain.defs @@ -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) diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index 432ec8ab3b..24e2f6df8f 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -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)