zephyr/cmake/bintools/oneApi/target.cmake
Kumar Gala 2d12766e78 toolchain: oneApi: Fix support and update for 2023.0.0 release
The oneApi support has bit rotten since it was first introduced.  Update
the support to function with the latest 2023.0.0 release and add a
check to only support that version or newer for now.  Versions before
2021.2.0 have linker script failures.

Various fixes made:
* In the 2023.0.0 release, various binaries are in a llvm-bin path so
  add support to search in that path.  This replaces the python search
  path that much older versions needed.
* newlib isn't supported with oneApi so set TOOLCHAIN_HAS_NEWLIB to
  OFF to match that.
* 2023.0.0 doesn't back llvm-nm, so use binutils version.  This
  is expected to be fixed in 2023.1.0 release so add a check to
  handle either case.
* Update compiler flag check based on clang to also support
  CMAKE_C_COMPILER_ID of "IntelLLVM" as that is how the oneApi toolchain
  reports itself.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-02-23 14:30:03 -05:00

30 lines
1.2 KiB
CMake

# SPDX-License-Identifier: Apache-2.0
if(DEFINED TOOLCHAIN_HOME)
set(find_program_clang_args PATHS ${TOOLCHAIN_HOME} ${ONEAPI_LLVM_BIN_PATH} NO_DEFAULT_PATH)
set(find_program_binutils_args PATHS ${TOOLCHAIN_HOME} )
endif()
find_package(oneApi 2023.0.0 REQUIRED)
find_program(CMAKE_AR llvm-ar ${find_program_clang_args} )
if(ONEAPI_VERSION VERSION_LESS_EQUAL "2023.0.0")
find_program(CMAKE_NM nm ${find_program_binutils_args} )
else()
find_program(CMAKE_NM llvm-nm ${find_program_clang_args} )
endif()
# In OneApi installation directory on Windows, there is no llvm-objdump
# binary, so would better use objdump from system environment both
# on Linux and Windows.
find_program(CMAKE_OBJDUMP objdump ${find_program_binutils_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)