diff --git a/arch/arm/core/aarch32/Kconfig b/arch/arm/core/aarch32/Kconfig index 6e26d0bb8ae..a14bcd0cb62 100644 --- a/arch/arm/core/aarch32/Kconfig +++ b/arch/arm/core/aarch32/Kconfig @@ -312,6 +312,8 @@ config FP16_ALT so that this format can represent normalized values in the range of 2^(-14) to 131008. + Please note that Clang doesn't support the ARM alternative format. + endchoice rsource "cortex_m/Kconfig" diff --git a/cmake/compiler/clang/target.cmake b/cmake/compiler/clang/target.cmake index 536c0209ee1..85bfb807e8f 100644 --- a/cmake/compiler/clang/target.cmake +++ b/cmake/compiler/clang/target.cmake @@ -29,7 +29,7 @@ if(NOT "${ARCH}" STREQUAL "posix") -fshort-enums ) - include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_arm.cmake) + include(${ZEPHYR_BASE}/cmake/compiler/clang/target_arm.cmake) endif() foreach(file_name include/stddef.h) diff --git a/cmake/compiler/clang/target_arm.cmake b/cmake/compiler/clang/target_arm.cmake new file mode 100644 index 00000000000..53a68cfb162 --- /dev/null +++ b/cmake/compiler/clang/target_arm.cmake @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: Apache-2.0 + +set(ARM_C_FLAGS) + +list(APPEND ARM_C_FLAGS -mcpu=${GCC_M_CPU}) + +if(CONFIG_COMPILER_ISA_THUMB2) + list(APPEND ARM_C_FLAGS -mthumb) +endif() + +list(APPEND ARM_C_FLAGS -mabi=aapcs) + +if(CONFIG_FPU) + list(APPEND ARM_C_FLAGS -mfpu=${GCC_M_FPU}) + + if(CONFIG_DCLS AND NOT CONFIG_FP_HARDABI) + # If the processor is equipped with VFP and configured in DCLS topology, + # the FP "hard" ABI must be used in order to facilitate the FP register + # initialisation and synchronisation. + set(FORCE_FP_HARDABI TRUE) + endif() + + if (CONFIG_FP_HARDABI OR FORCE_FP_HARDABI) + list(APPEND ARM_C_FLAGS -mfloat-abi=hard) + elseif(CONFIG_FP_SOFTABI) + list(APPEND ARM_C_FLAGS -mfloat-abi=softfp) + endif() +endif() + +if(CONFIG_FP16) + # Clang only supports IEEE 754-2008 format for __fp16. It's enabled by + # default, so no need to do anything when CONFIG_FP16_IEEE is selected. + if(CONFIG_FP16_ALT) + message(FATAL_ERROR "Clang doesn't support ARM alternative format for FP16") + endif() +endif() +list(APPEND TOOLCHAIN_C_FLAGS ${ARM_C_FLAGS}) +list(APPEND TOOLCHAIN_LD_FLAGS NO_SPLIT ${ARM_C_FLAGS})