llvm.org GIT mirror llvm / f5a4b47
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322046 91177308-0d34-0410-b5e6-96231b3b80d8 Petr Hosek 2 years ago
3 changed file(s) with 17 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
4949 -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
5050 -DLLVM_TARGETS_TO_BUILD="${targets_to_build_arg}"
5151 -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="${experimental_targets_to_build_arg}"
52 -DLLVM_DEFAULT_TARGET_TRIPLE="${TARGET_TRIPLE}"
53 -DLLVM_TARGET_ARCH="${LLVM_TARGET_ARCH}"
5254 ${build_type_flags} ${linker_flag} ${external_clang_dir}
5355 WORKING_DIRECTORY ${LLVM_${target_name}_BUILD}
5456 DEPENDS CREATE_LLVM_${target_name}
101101 endforeach()
102102 endforeach()
103103
104 if(ARG_USE_TOOLCHAIN)
104 if(ARG_USE_TOOLCHAIN AND NOT CMAKE_CROSSCOMPILING)
105105 if(CLANG_IN_TOOLCHAIN)
106106 set(compiler_args -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
107107 -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
133133
134134 if(CMAKE_SYSROOT)
135135 set(sysroot_arg -DCMAKE_SYSROOT=${CMAKE_SYSROOT})
136 endif()
137
138 if(CMAKE_CROSSCOMPILING)
139 set(compiler_args -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
140 -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
141 -DCMAKE_AR=${CMAKE_AR}
142 -DCMAKE_RANLIB=${CMAKE_RANLIB})
143 set(llvm_config_path "${LLVM_NATIVE_BUILD}/bin/llvm-config")
144 else()
145 set(llvm_config_path "$")
136146 endif()
137147
138148 ExternalProject_Add(${name}
148158 -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
149159 ${sysroot_arg}
150160 -DLLVM_BINARY_DIR=${PROJECT_BINARY_DIR}
151 -DLLVM_CONFIG_PATH=$
161 -DLLVM_CONFIG_PATH=${llvm_config_path}
152162 -DLLVM_ENABLE_WERROR=${LLVM_ENABLE_WERROR}
153163 -DLLVM_HOST_TRIPLE=${LLVM_HOST_TRIPLE}
154164 -DLLVM_HAVE_LINK_VERSION_SCRIPT=${LLVM_HAVE_LINK_VERSION_SCRIPT}
353353 CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
354354 -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
355355 -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}
356 -DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE}
357 -DCMAKE_CXX_COMPILER_TARGET=${TARGET_TRIPLE}
358 -DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE}
356359 -DCMAKE_C_COMPILER_WORKS=ON
357360 -DCMAKE_CXX_COMPILER_WORKS=ON
358361 -DCMAKE_ASM_COMPILER_WORKS=ON