diff --git a/arch/arm/src/armv6-m/Toolchain.defs b/arch/arm/src/armv6-m/Toolchain.defs index ab43bed307..2a105f9168 100644 --- a/arch/arm/src/armv6-m/Toolchain.defs +++ b/arch/arm/src/armv6-m/Toolchain.defs @@ -30,7 +30,7 @@ LLVM_CPUTYPE := cortex-m0 # Clang Configuration files ifeq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y) - TOOLCHAIN_MARCH := --config armv6m_soft_nofp_nosys + TOOLCHAIN_CLANG_CONFIG = --config armv6m_soft_nofp else ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y) LDFLAGS += --cpu=Cortex-M0 endif diff --git a/arch/arm/src/armv7-m/Toolchain.defs b/arch/arm/src/armv7-m/Toolchain.defs index d5a5a151b9..bee4b56803 100644 --- a/arch/arm/src/armv7-m/Toolchain.defs +++ b/arch/arm/src/armv7-m/Toolchain.defs @@ -72,18 +72,18 @@ ifeq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y) ifeq ($(CONFIG_ARCH_CORTEXM4),y) ifeq ($(CONFIG_ARCH_FPU),y) - TOOLCHAIN_MARCH += --config armv7em_hard_fpv4_sp_d16_nosys + TOOLCHAIN_CLANG_CONFIG = --config armv7em_hard_fpv4_sp_d16 else - TOOLCHAIN_MARCH += --config armv7em_soft_nofp_nosys + TOOLCHAIN_CLANG_CONFIG = --config armv7em_soft_nofp endif else ifeq ($(CONFIG_ARCH_CORTEXM7),y) ifeq ($(CONFIG_ARCH_FPU),y) - TOOLCHAIN_MARCH += --config armv7em_hard_fpv5_d16_nosys + TOOLCHAIN_CLANG_CONFIG = --config armv7em_hard_fpv5_d16 else - TOOLCHAIN_MARCH += --config armv7em_soft_nofp_nosys + TOOLCHAIN_CLANG_CONFIG = --config armv7em_soft_nofp endif else # ifeq ($(CONFIG_ARCH_CORTEXM3),y) - TOOLCHAIN_MARCH += --config armv7m_soft_nofp_nosys + TOOLCHAIN_CLANG_CONFIG = --config armv7m_soft_nofp endif else ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y) diff --git a/arch/arm/src/armv8-m/Toolchain.defs b/arch/arm/src/armv8-m/Toolchain.defs index 7a4d92d777..79bc8c6985 100644 --- a/arch/arm/src/armv8-m/Toolchain.defs +++ b/arch/arm/src/armv8-m/Toolchain.defs @@ -109,30 +109,30 @@ endif ifeq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y) ifeq ($(CONFIG_ARCH_CORTEXM23),y) - TOOLCHAIN_MARCH += --config armv8m.main_soft_nofp_nosys + TOOLCHAIN_CLANG_CONFIG = --config armv8m.main_soft_nofp else ifeq ($(CONFIG_ARCH_CORTEXM33),y) ifeq ($(CONFIG_ARCH_FPU),y) - TOOLCHAIN_MARCH += --config armv8m.main_hard_fp_nosys + TOOLCHAIN_CLANG_CONFIG = --config armv8m.main_hard_fp else - TOOLCHAIN_MARCH += --config armv8m.main_soft_nofp_nosys + TOOLCHAIN_CLANG_CONFIG = --config armv8m.main_soft_nofp endif else ifeq ($(CONFIG_ARCH_CORTEXM35P),y) ifeq ($(CONFIG_ARCH_FPU),y) - TOOLCHAIN_MARCH += --config armv8m.main_hard_fp_nosys + TOOLCHAIN_CLANG_CONFIG = --config armv8m.main_hard_fp else - TOOLCHAIN_MARCH += --config armv8m.main_soft_nofp_nosys + TOOLCHAIN_CLANG_CONFIG = --config armv8m.main_soft_nofp endif else ifeq ($(CONFIG_ARCH_CORTEXM55),y) ifeq ($(CONFIG_ARCH_FPU),y) - TOOLCHAIN_MARCH += --config armv8.1m.main_hard_fp_nosys + TOOLCHAIN_CLANG_CONFIG = --config armv8.1m.main_hard_fp else - TOOLCHAIN_MARCH += --config armv8.1m.main_soft_nofp_nomve_nosys + TOOLCHAIN_CLANG_CONFIG = --config armv8.1m.main_soft_nofp_nomve endif else ifeq ($(CONFIG_ARCH_CORTEXM85),y) ifeq ($(CONFIG_ARCH_FPU),y) - TOOLCHAIN_MARCH += --config armv8.1m.main_hard_fp + TOOLCHAIN_CLANG_CONFIG = --config armv8.1m.main_hard_fp else - TOOLCHAIN_MARCH += --config armv8.1m.main_soft_nofp_nomve + TOOLCHAIN_CLANG_CONFIG = --config armv8.1m.main_soft_nofp_nomve endif endif diff --git a/arch/arm/src/cmake/Toolchain.cmake b/arch/arm/src/cmake/Toolchain.cmake index f61e266349..3d3de23681 100644 --- a/arch/arm/src/cmake/Toolchain.cmake +++ b/arch/arm/src/cmake/Toolchain.cmake @@ -89,15 +89,13 @@ endif() # override the ARCHIVE command -set(CMAKE_C_ARCHIVE_CREATE " rcs -o ") -set(CMAKE_CXX_ARCHIVE_CREATE - " rcs -o ") -set(CMAKE_ASM_ARCHIVE_CREATE - " rcs -o ") +set(CMAKE_C_ARCHIVE_CREATE " rcs ") +set(CMAKE_CXX_ARCHIVE_CREATE " rcs ") +set(CMAKE_ASM_ARCHIVE_CREATE " rcs ") # Architecture flags -add_link_options(--entry=__start) +add_link_options(-Wl,--entry=__start) add_link_options(-nostdlib) add_compile_options(-fno-common) add_compile_options(-Wall -Wshadow -Wundef) @@ -200,13 +198,13 @@ endif() if(NOT EXISTS_FLAGS) set(CMAKE_ASM_FLAGS - "${CMAKE_ASM_FLAGS}${ARCHCFLAGS}" + "${CMAKE_ASM_FLAGS} ${ARCHCFLAGS}" CACHE STRING "" FORCE) set(CMAKE_C_FLAGS - "${CMAKE_C_FLAGS}${ARCHCFLAGS}" + "${CMAKE_C_FLAGS} ${ARCHCFLAGS}" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS}${ARCHCXXFLAGS}" + "${CMAKE_CXX_FLAGS} ${ARCHCXXFLAGS}" CACHE STRING "" FORCE) endif() diff --git a/arch/arm/src/cmake/armv7-m.cmake b/arch/arm/src/cmake/armv7-m.cmake index 3d6706fd0a..74dcd06fd2 100644 --- a/arch/arm/src/cmake/armv7-m.cmake +++ b/arch/arm/src/cmake/armv7-m.cmake @@ -55,18 +55,18 @@ if(CONFIG_ARCH_TOOLCHAIN_CLANG) if(CONFIG_ARCH_CORTEXM4) if(CONFIG_ARCH_FPU) - string(APPEND ARCHFLAGS "--config armv7em_hard_fpv4_sp_d16_nosys") + string(APPEND ARCHFLAGS "--config armv7em_hard_fpv4_sp_d16.cfg") else() - string(APPEND ARCHFLAGS "--config armv7em_soft_nofp_nosys") + string(APPEND ARCHFLAGS "--config armv7em_soft_nofp.cfg") endif() elseif(CONFIG_ARCH_CORTEXM7) if(CONFIG_ARCH_FPU) - string(APPEND ARCHFLAGS "--config armv7em_hard_fpv5_d16_nosys") + string(APPEND ARCHFLAGS "--config armv7em_hard_fpv5.cfg") else() - string(APPEND ARCHFLAGS "--config armv7em_soft_nofp_nosys") + string(APPEND ARCHFLAGS "--config armv7em_soft_nofp.cfg") endif() else() - string(APPEND ARCHFLAGS "--config armv7em_soft_nofp_nosys") + string(APPEND ARCHFLAGS "--config armv7em_soft_nofp.cfg") endif() if(NOT "${CMAKE_C_FLAGS}" STREQUAL "" AND NOT "${ARCHFLAGS}" STREQUAL "") @@ -75,13 +75,13 @@ if(CONFIG_ARCH_TOOLCHAIN_CLANG) if(NOT EXISTS_FLAGS) set(CMAKE_ASM_FLAGS - "${CMAKE_ASM_FLAGS}${ARCHFLAGS}" + "${CMAKE_ASM_FLAGS} ${ARCHFLAGS}" CACHE STRING "" FORCE) set(CMAKE_C_FLAGS - "${CMAKE_C_FLAGS}${ARCHFLAGS}" + "${CMAKE_C_FLAGS} ${ARCHFLAGS}" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS}${ARCHFLAGS}" + "${CMAKE_CXX_FLAGS} ${ARCHFLAGS}" CACHE STRING "" FORCE) endif() endif() diff --git a/arch/arm/src/cmake/platform.cmake b/arch/arm/src/cmake/platform.cmake index e013f1c764..7463745b74 100644 --- a/arch/arm/src/cmake/platform.cmake +++ b/arch/arm/src/cmake/platform.cmake @@ -102,4 +102,5 @@ endif() set_property(GLOBAL APPEND PROPERTY NUTTX_EXTRA_LIBRARIES ${EXTRA_LIB}) -set(PREPROCES ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} -E -P -x c) +separate_arguments(CMAKE_C_FLAG_ARGS NATIVE_COMMAND ${CMAKE_C_FLAGS}) +set(PREPROCES ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} -E -P -x c) diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index af15fc3074..98868391fd 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -164,6 +164,18 @@ ifeq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y) ARCHOPTIMIZATION += -fno-builtin + ifneq ($(TOOLCHAIN_CLANG_CONFIG),) + ifeq ($(CLANGVER),) + export CLANGVER := $(shell $(CC) --version | grep "clang version" | sed -r "s/.* ([0-9]+\.[0-9]+).*/\1/") + endif + + ifeq ($(CLANGVER),14.0) + TOOLCHAIN_CLANG_CONFIG := $(TOOLCHAIN_CLANG_CONFIG)_nosys + endif + + ARCHCPUFLAGS += $(TOOLCHAIN_CLANG_CONFIG).cfg + endif + # ARM Compiler Clang toolchain else ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y) diff --git a/arch/arm/src/tlsr82/Toolchain.defs b/arch/arm/src/tlsr82/Toolchain.defs index 410eae8aa9..50f730f00f 100644 --- a/arch/arm/src/tlsr82/Toolchain.defs +++ b/arch/arm/src/tlsr82/Toolchain.defs @@ -21,7 +21,7 @@ # Clang Configuration files ifeq ($(CONFIG_ARM_TOOLCHAIN_CLANG),y) - TOOLCHAIN_MARCH := --config armv6m_soft_nofp_nosys + TOOLCHAIN_CLANG_CONFIG = --config armv6m_soft_nofp endif # Generic GNU EABI toolchain