summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2018-11-16 04:46:48 +0000
committerPetr Hosek <phosek@chromium.org>2018-11-16 04:46:48 +0000
commita4f48c45b868a806d62b4d42925ca64b9899cd20 (patch)
tree9f09ec6aff7357a979e455b698e86736e2caec58 /CMakeLists.txt
parentc5ae3d10742f6fbf03d2cea84c528e8547d9bfe3 (diff)
downloadclang-a4f48c45b868a806d62b4d42925ca64b9899cd20.tar.gz
[CMake] Support cross-compiling with multi-stage builds
When using multi-stage builds, we would like support cross-compilation. Example is 2-stage build when the first stage is compiled for host while the second stage is compiled for the target. Normally, the second stage would be also used for compiling runtimes, but that's not possible when cross-compiling, so we use the first stage compiler instead. However, we still want to use the second stage paths. To do so, we set the -resource-dir of the first stage compiler to point to the resource directory of the second stage. We also need compiler tools that support the target architecture. These tools are not guaranteed to be present on the host, but in case of multi-stage build, we can build these tools in the first stage. Differential Revision: https://reviews.llvm.org/D54461 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347025 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt33
1 files changed, 30 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0a38688066..1482b17abc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -599,8 +599,8 @@ if (CLANG_ENABLE_BOOTSTRAP)
if(NOT BOOTSTRAP_LLVM_ENABLE_LLD AND LLVM_BINUTILS_INCDIR)
add_dependencies(clang-bootstrap-deps LLVMgold)
endif()
- set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
- set(LTO_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
+ set(${CLANG_STAGE}_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
+ set(${CLANG_STAGE}_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
endif()
endif()
@@ -666,6 +666,26 @@ if (CLANG_ENABLE_BOOTSTRAP)
-DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${C_COMPILER}
-DCMAKE_ASM_COMPILER_ID=Clang)
+ if(BOOTSTRAP_CMAKE_SYSTEM_NAME)
+ set(${CLANG_STAGE}_CONFIG -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config)
+ set(${CLANG_STAGE}_TABLEGEN
+ -DLLVM_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-tblgen
+ -DCLANG_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-tblgen)
+ if(BOOTSTRAP_CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ if(BOOTSTRAP_LLVM_ENABLE_LLD)
+ set(${CLANG_STAGE}_LINKER -DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/ld.lld)
+ endif()
+ if(NOT BOOTSTRAP_LLVM_ENABLE_LTO)
+ add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib)
+ set(${CLANG_STAGE}_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
+ set(${CLANG_STAGE}_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
+ endif()
+ add_dependencies(clang-bootstrap-deps llvm-objcopy llvm-strip)
+ set(${CLANG_STAGE}_OBJCOPY -DCMAKE_OBJCOPY=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-objcopy)
+ set(${CLANG_STAGE}_STRIP -DCMAKE_STRIP=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-strip)
+ endif()
+ endif()
+
if(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED)
add_dependencies(clang-bootstrap-deps llvm-profdata)
set(PGO_OPT -DLLVM_PROFDATA=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-profdata)
@@ -734,7 +754,14 @@ if (CLANG_ENABLE_BOOTSTRAP)
${PASSTHROUGH_VARIABLES}
-DCLANG_STAGE=${NEXT_CLANG_STAGE}
${COMPILER_OPTIONS}
- ${LTO_LIBRARY} ${LTO_AR} ${LTO_RANLIB} ${verbose} ${PGO_OPT}
+ ${${CLANG_STAGE}_CONFIG}
+ ${${CLANG_STAGE}_TABLEGEN}
+ ${LTO_LIBRARY} ${verbose} ${PGO_OPT}
+ ${${CLANG_STAGE}_LINKER}
+ ${${CLANG_STAGE}_AR}
+ ${${CLANG_STAGE}_RANLIB}
+ ${${CLANG_STAGE}_OBJCOPY}
+ ${${CLANG_STAGE}_STRIP}
INSTALL_COMMAND ""
STEP_TARGETS configure build
USES_TERMINAL_CONFIGURE 1