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-none-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() 28elseif("${ARCH}" STREQUAL "arm64") 29 set(triple aarch64-none-elf) 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() 36elseif("${ARCH}" STREQUAL "riscv") 37 if(CONFIG_64BIT) 38 set(triple riscv64-unknown-elf) 39 else() 40 set(triple riscv32-unknown-elf) 41 endif() 42endif() 43 44if(DEFINED triple) 45 set(CMAKE_C_COMPILER_TARGET ${triple}) 46 set(CMAKE_ASM_COMPILER_TARGET ${triple}) 47 set(CMAKE_CXX_COMPILER_TARGET ${triple}) 48 49 unset(triple) 50endif() 51 52if(CONFIG_LIBGCC_RTLIB) 53 set(runtime_lib "libgcc") 54elseif(CONFIG_COMPILER_RT_RTLIB) 55 set(runtime_lib "compiler_rt") 56endif() 57 58list(APPEND TOOLCHAIN_C_FLAGS --config 59 ${ZEPHYR_BASE}/cmake/toolchain/llvm/clang_${runtime_lib}.cfg) 60list(APPEND TOOLCHAIN_LD_FLAGS --config 61 ${ZEPHYR_BASE}/cmake/toolchain/llvm/clang_${runtime_lib}.cfg) 62