clang: Provide --target option when determining path to runtime library
Clang/LLVM is natively a cross-compiler, so one set of applications can compile code to all supported targets. The default target can be changed using '--target' option. CMake supports this type of compilers. To change compiling target, one should set CMAKE_C_COMPILER_TARGET accorgindly. The '--target' option has impact on the path to clang-rt library returned by compiler when run with '--print-libgcc-file-name' option. Without specifying target, Clang will return path to runtime library of the host target (e.g. x86_64-pc-linux-gnu). Signed-off-by: Patryk Duda <pdk@semihalf.com>
This commit is contained in:
parent
624fcbaa5c
commit
3a97fe256c
1 changed files with 6 additions and 1 deletions
|
@ -32,6 +32,10 @@ if(NOT "${ARCH}" STREQUAL "posix")
|
|||
include(${ZEPHYR_BASE}/cmake/compiler/clang/target_arm.cmake)
|
||||
endif()
|
||||
|
||||
if(DEFINED CMAKE_C_COMPILER_TARGET)
|
||||
set(clang_target_flag "--target=${CMAKE_C_COMPILER_TARGET}")
|
||||
endif()
|
||||
|
||||
foreach(file_name include/stddef.h)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
|
||||
|
@ -57,7 +61,8 @@ if(NOT "${ARCH}" STREQUAL "posix")
|
|||
|
||||
# This libgcc code is partially duplicated in compiler/*/target.cmake
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name
|
||||
COMMAND ${CMAKE_C_COMPILER} ${clang_target_flag} ${TOOLCHAIN_C_FLAGS}
|
||||
--print-libgcc-file-name
|
||||
OUTPUT_VARIABLE RTLIB_FILE_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue