1# SPDX-License-Identifier: Apache-2.0
2
3if(CONFIG_LLVM_USE_LD)
4  set(LINKER ld)
5elseif(CONFIG_LLVM_USE_LLD)
6  set(LINKER lld)
7endif()
8
9if("${ARCH}" STREQUAL "arm")
10  if(DEFINED CONFIG_ARMV8_M_MAINLINE)
11    # ARMv8-M mainline is ARMv7-M with additional features from ARMv8-M.
12    set(triple armv8m.main-none-eabi)
13  elseif(DEFINED CONFIG_ARMV8_M_BASELINE)
14    # ARMv8-M baseline is ARMv6-M with additional features from ARMv8-M.
15    set(triple armv8m.base-none-eabi)
16  elseif(DEFINED CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
17    # ARMV7_M_ARMV8_M_MAINLINE means that ARMv7-M or backward compatible ARMv8-M
18    # processor is used.
19    set(triple armv7m-cros-eabi)
20  elseif(DEFINED CONFIG_ARMV6_M_ARMV8_M_BASELINE)
21    # ARMV6_M_ARMV8_M_BASELINE means that ARMv6-M or ARMv8-M supporting the
22    # Baseline implementation processor is used.
23    set(triple armv6m-none-eabi)
24  else()
25    # Default ARM target supported by all processors.
26    set(triple arm-none-eabi)
27  endif()
28
29  set(CMAKE_EXE_LINKER_FLAGS_INIT "--specs=nosys.specs")
30elseif("${ARCH}" STREQUAL "x86")
31  if(CONFIG_64BIT)
32    set(triple x86_64-pc-none-elf)
33  else()
34    set(triple i686-pc-none-elf)
35  endif()
36endif()
37
38if(DEFINED triple)
39  set(CMAKE_C_COMPILER_TARGET   ${triple})
40  set(CMAKE_ASM_COMPILER_TARGET ${triple})
41  set(CMAKE_CXX_COMPILER_TARGET ${triple})
42
43  unset(triple)
44endif()
45
46if(CONFIG_LIBGCC_RTLIB)
47  set(runtime_lib "libgcc")
48elseif(CONFIG_COMPILER_RT_RTLIB)
49  set(runtime_lib "compiler_rt")
50endif()
51
52list(APPEND TOOLCHAIN_C_FLAGS --config
53	${ZEPHYR_BASE}/cmake/toolchain/llvm/clang_${runtime_lib}.cfg)
54list(APPEND TOOLCHAIN_LD_FLAGS --config
55	${ZEPHYR_BASE}/cmake/toolchain/llvm/clang_${runtime_lib}.cfg)
56