arm/clang: enhance compatibility of clang compiler

The naming of the clang configuration file has changed after version 14
This commit will enable the compatibility with clang-14/15/16/17

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-08-09 12:19:33 +08:00 committed by Xiang Xiao
parent fa676f264f
commit fc354a1446
8 changed files with 45 additions and 34 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -89,15 +89,13 @@ endif()
# override the ARCHIVE command
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> rcs -o <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_CREATE
"<CMAKE_AR> rcs -o <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_ASM_ARCHIVE_CREATE
"<CMAKE_AR> rcs -o <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> rcs <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> rcs <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_ASM_ARCHIVE_CREATE "<CMAKE_AR> rcs <TARGET> <LINK_FLAGS> <OBJECTS>")
# 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()

View File

@ -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()

View File

@ -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)

View File

@ -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)

View File

@ -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