diff --git a/cmake/bintools/oneApi/target.cmake b/cmake/bintools/oneApi/target.cmake new file mode 100644 index 00000000000..3abe5e813e0 --- /dev/null +++ b/cmake/bintools/oneApi/target.cmake @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: Apache-2.0 + +if(DEFINED TOOLCHAIN_HOME) + set(find_program_clang_args PATHS ${TOOLCHAIN_HOME} ${ONEAPI_PYTHON_PATH} NO_DEFAULT_PATH) + set(find_program_binutils_args PATHS ${TOOLCHAIN_HOME} ) +endif() + +find_program(CMAKE_AR llvm-ar ${find_program_clang_args} ) +find_program(CMAKE_NM llvm-nm ${find_program_clang_args} ) +find_program(CMAKE_OBJDUMP llvm-objdump ${find_program_clang_args} ) +find_program(CMAKE_RANLIB llvm-ranlib ${find_program_clang_args} ) +find_program(CMAKE_OBJCOPY llvm-objcopy ${find_program_binutils_args}) +find_program(CMAKE_READELF readelf ${find_program_binutils_args}) +find_program(CMAKE_STRIP llvm-strip ${find_program_binutils_args}) + +find_program(CMAKE_GDB gdb-oneapi) + +# Use the gnu binutil abstraction +include(${ZEPHYR_BASE}/cmake/bintools/llvm/target_bintools.cmake) + diff --git a/cmake/compiler/icx/compiler_flags.cmake b/cmake/compiler/icx/compiler_flags.cmake new file mode 100644 index 00000000000..5476c6603fc --- /dev/null +++ b/cmake/compiler/icx/compiler_flags.cmake @@ -0,0 +1,2 @@ + +include(${ZEPHYR_BASE}/cmake/compiler/clang/compiler_flags.cmake) diff --git a/cmake/compiler/icx/generic.cmake b/cmake/compiler/icx/generic.cmake new file mode 100644 index 00000000000..47c4bf17b2d --- /dev/null +++ b/cmake/compiler/icx/generic.cmake @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 + +if(DEFINED TOOLCHAIN_HOME) + set(find_program_icx_args PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH) +endif() + +find_program(CMAKE_C_COMPILER icx ${find_program_icx_args}) diff --git a/cmake/compiler/icx/target.cmake b/cmake/compiler/icx/target.cmake new file mode 100644 index 00000000000..9b0b5567717 --- /dev/null +++ b/cmake/compiler/icx/target.cmake @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Configuration for host installed oneApi +# + +set(NOSTDINC "") + +# Note that NOSYSDEF_CFLAG may be an empty string, and +# set_ifndef() does not work with empty string. +if(NOT DEFINED NOSYSDEF_CFLAG) + set(NOSYSDEF_CFLAG -undef) +endif() + +if(DEFINED TOOLCHAIN_HOME) + set(find_program_icx_args PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH) +endif() + +find_program(CMAKE_C_COMPILER icx ${find_program_icx_args}) +find_program(CMAKE_CXX_COMPILER clang++ ${find_program_icx_args}) + +include(${ZEPHYR_BASE}/cmake/gcc-m-cpu.cmake) + +foreach(file_name include/stddef.h) + execute_process( + COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name} + OUTPUT_VARIABLE _OUTPUT + RESULT_VARIABLE result + ) + if(result) + message(FATAL_ERROR "Failed to find required headers.") + endif() + get_filename_component(_OUTPUT "${_OUTPUT}" DIRECTORY) + string(REGEX REPLACE "\n" "" _OUTPUT "${_OUTPUT}") + + list(APPEND NOSTDINC ${_OUTPUT}) +endforeach() + +foreach(isystem_include_dir ${NOSTDINC}) + list(APPEND isystem_include_flags -isystem ${isystem_include_dir}) +endforeach() + +if(CONFIG_64BIT) + string(APPEND TOOLCHAIN_C_FLAGS "-m64") +else() + string(APPEND TOOLCHAIN_C_FLAGS "-m32") +endif() + + +# This libgcc code is partially duplicated in compiler/*/target.cmake +execute_process( + COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name + OUTPUT_VARIABLE LIBGCC_FILE_NAME + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + +get_filename_component(LIBGCC_DIR ${LIBGCC_FILE_NAME} DIRECTORY) + +list(APPEND LIB_INCLUDE_DIR "-L\"${LIBGCC_DIR}\"") +if(LIBGCC_DIR) + list(APPEND TOOLCHAIN_LIBS gcc) +endif() + +set(CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags}) +string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") + +# Load toolchain_cc-family macros +macro(toolchain_cc_nostdinc) + zephyr_compile_options( -nostdinc) +endmacro() diff --git a/cmake/linker/lld/target.cmake b/cmake/linker/lld/target.cmake index ec6aa208c02..a4d0b2f915d 100644 --- a/cmake/linker/lld/target.cmake +++ b/cmake/linker/lld/target.cmake @@ -20,8 +20,8 @@ macro(configure_linker_script linker_script_gen linker_pass_define) else() # TODO: How would the linker script dependencies work for non-linker # script generators. - message(STATUS "Warning; this generator is not well supported. The - Linker script may not be regenerated when it should.") + message(WARNING "This generator is not well supported. The + Linker script may not be regenerated when it should.") set(linker_script_dep "") endif() diff --git a/cmake/toolchain/oneApi/generic.cmake b/cmake/toolchain/oneApi/generic.cmake new file mode 100644 index 00000000000..99d119f8347 --- /dev/null +++ b/cmake/toolchain/oneApi/generic.cmake @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: Apache-2.0 + +if($ENV{ONEAPI_ROOT}) + set_ifndef(ONEAPI_TOOLCHAIN_PATH "$ENV{ONEAPI_ROOT}") +else() + set_ifndef(ONEAPI_TOOLCHAIN_PATH "$ENV{ONEAPI_TOOLCHAIN_PATH}") +endif() + +if(ONEAPI_TOOLCHAIN_PATH) + set(TOOLCHAIN_HOME ${ONEAPI_TOOLCHAIN_PATH}/compiler/latest/linux/bin/) + set(ONEAPI_PYTHON_PATH ${ONEAPI_TOOLCHAIN_PATH}/intelpython/latest/bin) +endif() + +set(ONEAPI_TOOLCHAIN_PATH ${ONEAPI_TOOLCHAIN_PATH} CACHE PATH "oneApi install directory") + +set(COMPILER icx) +set(LINKER lld) +set(BINTOOLS oneApi) + +if(CONFIG_64BIT) + set(triple x86_64-pc-none-elf) +else() + set(triple i686-pc-none-elf) +endif() + +set(CMAKE_C_COMPILER_TARGET ${triple}) +set(CMAKE_ASM_COMPILER_TARGET ${triple}) +set(CMAKE_CXX_COMPILER_TARGET ${triple}) + +message(STATUS "Found toolchain: host (clang/ld)") diff --git a/cmake/toolchain/oneApi/target.cmake b/cmake/toolchain/oneApi/target.cmake new file mode 100644 index 00000000000..b970dc3e7d8 --- /dev/null +++ b/cmake/toolchain/oneApi/target.cmake @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Intentionally left blank.