diff options
author | Petr Hosek <phosek@chromium.org> | 2016-12-12 23:15:10 +0000 |
---|---|---|
committer | Petr Hosek <phosek@chromium.org> | 2016-12-12 23:15:10 +0000 |
commit | a923c5a13421e44c960025d0fcdd39a33eebdd15 (patch) | |
tree | 0df84599a9425be864b20ac47b018ff8bccf3de3 /runtimes/CMakeLists.txt | |
parent | 8b658bc535dce133d3ea626aeb8dd8d32c0fb349 (diff) |
[CMake] Multi-target builtins build
This change enables building builtins for multiple different targets
using LLVM runtimes directory.
To specify the builtin targets to be built, use the LLVM_BUILTIN_TARGETS
variable, where the value is the list of targets. To pass a per target
variable to the builtin build, you can set BUILTINS_<target>_<variable>
where <variable> will be passed to the builtin build for <target>.
Differential Revision: https://reviews.llvm.org/D26652
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289491 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtimes/CMakeLists.txt')
-rw-r--r-- | runtimes/CMakeLists.txt | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt index 3b059062c17..b1a47b55cfc 100644 --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -139,12 +139,40 @@ else() # if this is included from LLVM's CMake # is required because the other runtimes need the builtin libraries present # before the just-built compiler can pass the configuration tests. if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/compiler-rt) - llvm_ExternalProject_Add(builtins - ${CMAKE_CURRENT_SOURCE_DIR}/compiler-rt/lib/builtins - CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR} - -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR} - PASSTHROUGH_PREFIXES COMPILER_RT - USE_TOOLCHAIN) + if(APPLE OR NOT LLVM_BUILTIN_TARGETS) + llvm_ExternalProject_Add(builtins + ${CMAKE_CURRENT_SOURCE_DIR}/compiler-rt/lib/builtins + CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR} + -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR} + -DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE} + -DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE} + PASSTHROUGH_PREFIXES COMPILER_RT + USE_TOOLCHAIN) + else() + get_cmake_property(variableNames VARIABLES) + add_custom_target(builtins) + foreach(target ${LLVM_BUILTIN_TARGETS}) + foreach(variableName ${variableNames}) + if(variableName MATCHES "^BUILTINS_${target}") + string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName}) + list(APPEND ${target}_extra_args "-D${new_name}=${${variableName}}") + endif() + endforeach() + llvm_ExternalProject_Add(builtins-${target} + ${CMAKE_CURRENT_SOURCE_DIR}/compiler-rt/lib/builtins + CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR} + -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR} + -DCMAKE_C_COMPILER_TARGET=${target} + -DCMAKE_ASM_COMPILER_TARGET=${target} + -DCMAKE_C_COMPILER_WORKS=On + -DCMAKE_ASM_COMPILER_WORKS=On + -DCOMPILER_RT_DEFAULT_TARGET_ONLY=On + ${${target}_extra_args} + PASSTHROUGH_PREFIXES COMPILER_RT + USE_TOOLCHAIN) + add_dependencies(builtins builtins-${target}) + endforeach() + endif() set(deps builtins) # We don't need to depend on the builtins if we're building instrumented # because the next stage will use the same compiler used to build this stage. |