mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[CMake] Support for cross-compilation when build runtimes
When cross-compiling, we cannot use the just built toolchain, instead we need to use the host toolchain which we assume has a support for targeting the selected target platform. We also need to pass the path to the native version of llvm-config to external projects. Differential Revision: https://reviews.llvm.org/D41678 llvm-svn: 322046
This commit is contained in:
parent
ff763aa60e
commit
7f6e32fff6
@ -50,6 +50,8 @@ function(llvm_create_cross_target_internal target_name toolchain buildtype)
|
||||
-DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
|
||||
-DLLVM_TARGETS_TO_BUILD="${targets_to_build_arg}"
|
||||
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="${experimental_targets_to_build_arg}"
|
||||
-DLLVM_DEFAULT_TARGET_TRIPLE="${TARGET_TRIPLE}"
|
||||
-DLLVM_TARGET_ARCH="${LLVM_TARGET_ARCH}"
|
||||
${build_type_flags} ${linker_flag} ${external_clang_dir}
|
||||
WORKING_DIRECTORY ${LLVM_${target_name}_BUILD}
|
||||
DEPENDS CREATE_LLVM_${target_name}
|
||||
|
@ -102,7 +102,7 @@ function(llvm_ExternalProject_Add name source_dir)
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
if(ARG_USE_TOOLCHAIN)
|
||||
if(ARG_USE_TOOLCHAIN AND NOT CMAKE_CROSSCOMPILING)
|
||||
if(CLANG_IN_TOOLCHAIN)
|
||||
set(compiler_args -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
|
||||
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
|
||||
@ -136,6 +136,16 @@ function(llvm_ExternalProject_Add name source_dir)
|
||||
set(sysroot_arg -DCMAKE_SYSROOT=${CMAKE_SYSROOT})
|
||||
endif()
|
||||
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
set(compiler_args -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_AR=${CMAKE_AR}
|
||||
-DCMAKE_RANLIB=${CMAKE_RANLIB})
|
||||
set(llvm_config_path "${LLVM_NATIVE_BUILD}/bin/llvm-config")
|
||||
else()
|
||||
set(llvm_config_path "$<TARGET_FILE:llvm-config>")
|
||||
endif()
|
||||
|
||||
ExternalProject_Add(${name}
|
||||
DEPENDS ${ARG_DEPENDS} llvm-config
|
||||
${name}-clobber
|
||||
@ -149,7 +159,7 @@ function(llvm_ExternalProject_Add name source_dir)
|
||||
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
|
||||
${sysroot_arg}
|
||||
-DLLVM_BINARY_DIR=${PROJECT_BINARY_DIR}
|
||||
-DLLVM_CONFIG_PATH=$<TARGET_FILE:llvm-config>
|
||||
-DLLVM_CONFIG_PATH=${llvm_config_path}
|
||||
-DLLVM_ENABLE_WERROR=${LLVM_ENABLE_WERROR}
|
||||
-DLLVM_HOST_TRIPLE=${LLVM_HOST_TRIPLE}
|
||||
-DLLVM_HAVE_LINK_VERSION_SCRIPT=${LLVM_HAVE_LINK_VERSION_SCRIPT}
|
||||
|
@ -354,6 +354,9 @@ else() # if this is included from LLVM's CMake
|
||||
CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
|
||||
-DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
|
||||
-DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}
|
||||
-DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE}
|
||||
-DCMAKE_CXX_COMPILER_TARGET=${TARGET_TRIPLE}
|
||||
-DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE}
|
||||
-DCMAKE_C_COMPILER_WORKS=ON
|
||||
-DCMAKE_CXX_COMPILER_WORKS=ON
|
||||
-DCMAKE_ASM_COMPILER_WORKS=ON
|
||||
|
Loading…
Reference in New Issue
Block a user