1# find the compilers for C, CPP, assembly 2find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}ccac PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH) 3find_program(CMAKE_CXX_COMPILER ${CROSS_COMPILE}ccac PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH) 4find_program(CMAKE_ASM_COMPILER ${CROSS_COMPILE}ccac PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH) 5# The CMAKE_REQUIRED_FLAGS variable is used by check_c_compiler_flag() 6# (and other commands which end up calling check_c_source_compiles()) 7# to add additional compiler flags used during checking. These flags 8# are unused during "real" builds of Zephyr source files linked into 9# the final executable. 10# 11# Appending onto any existing values lets users specify 12# toolchain-specific flags at generation time. 13list(APPEND CMAKE_REQUIRED_FLAGS 14 -c 15 -HL 16 -Hnosdata 17 -Hnolib 18 -Hnocrt 19 -Hnoentry 20 -Hldopt=-Bbase=0x0 # Set an entry point to avoid a warning 21 -Werror 22 ) 23string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") 24 25set(NOSTDINC ${TOOLCHAIN_HOME}/arc/inc) 26 27# For CMake to be able to test if a compiler flag is supported by the toolchain 28# (check_c_compiler_flag function which we wrap with target_cc_option in extensions.cmake) 29# we rely on default MWDT header locations and don't manually specify headers directories. 30 31# common compile options, no copyright msg, little-endian, no small data, 32# no MWDT stack checking 33list(APPEND TOOLCHAIN_C_FLAGS -Hnocopyr -HL -Hnosdata) 34 35if(CONFIG_ARC) 36 list(APPEND TOOLCHAIN_C_FLAGS -Hoff=Stackcheck_alloca) 37endif() 38 39# The MWDT compiler can replace some code with call to builtin functions. 40# We can't rely on these functions presence if we don't use MWDT libc. 41# NOTE: the option name '-fno-builtin' is misleading a bit - we still can 42# manually call __builtin_** functions even if we specify it. 43if(NOT CONFIG_ARCMWDT_LIBC) 44 list(APPEND TOOLCHAIN_C_FLAGS -fno-builtin) 45endif() 46 47# The MWDT compiler requires different macro definitions for ARC and RISC-V 48# architectures. __MW_ASM_RV_MACRO__ allows to select appropriate compilation branch. 49if(CONFIG_RISCV) 50 list(APPEND TOOLCHAIN_C_FLAGS -D__MW_ASM_RV_MACRO__) 51endif() 52