zephyr/cmake/compiler/clang/target_arm.cmake
Patryk Duda f16c4324a7 clang: Don't specify FP16 format
Support for 16 bit floats is enabled by default in Clang [1].
The ARM alternative format is not supported, so __fp16 always uses
IEEE 754-2008 format [2].

[1] https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/ARM/ARMAsmPrinter.cpp#L750-L755
[2] https://clang.llvm.org/docs/LanguageExtensions.html#half-precision-floating-point

Fixes: #55562

Signed-off-by: Patryk Duda <pdk@semihalf.com>
2023-08-01 11:24:07 +02:00

39 lines
1.1 KiB
CMake

# 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})