[PATCH] D26652: [CMake] Multi-target builtins build
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 14 16:51:17 PST 2016
phosek created this revision.
phosek added a reviewer: beanz.
phosek added a subscriber: llvm-commits.
phosek set the repository for this revision to rL LLVM.
Herald added a subscriber: mgorny.
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>.
Repository:
rL LLVM
https://reviews.llvm.org/D26652
Files:
cmake/modules/LLVMExternalProjectUtils.cmake
runtimes/CMakeLists.txt
Index: runtimes/CMakeLists.txt
===================================================================
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -139,12 +139,40 @@
# 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.
Index: cmake/modules/LLVMExternalProjectUtils.cmake
===================================================================
--- cmake/modules/LLVMExternalProjectUtils.cmake
+++ cmake/modules/LLVMExternalProjectUtils.cmake
@@ -28,7 +28,7 @@
# CMAKE_ARGS arguments...
# Optional cmake arguments to pass when configuring the project
# TOOLCHAIN_TOOLS targets...
-# Targets for toolchain tools (defaults to clang;lld)
+# Targets for toolchain tools (defaults to clang;lld;llvm-ar)
# DEPENDS targets...
# Targets that this project depends on
# EXTRA_TARGETS targets...
@@ -44,7 +44,7 @@
${ARGN})
canonicalize_tool_name(${name} nameCanon)
if(NOT ARG_TOOLCHAIN_TOOLS)
- set(ARG_TOOLCHAIN_TOOLS clang lld)
+ set(ARG_TOOLCHAIN_TOOLS clang lld llvm-ar)
endif()
foreach(tool ${ARG_TOOLCHAIN_TOOLS})
if(TARGET ${tool})
@@ -71,6 +71,11 @@
set(CLANG_IN_TOOLCHAIN On)
endif()
+ list(FIND TOOLCHAIN_TOOLS llvm-ar FOUND_ARCHIVER)
+ if(FOUND_ARCHIVER GREATER -1)
+ set(ARCHIVER_IN_TOOLCHAIN On)
+ endif()
+
if(RUNTIME_LIBRARIES AND CLANG_IN_TOOLCHAIN)
list(APPEND TOOLCHAIN_BINS ${RUNTIME_LIBRARIES})
endif()
@@ -104,6 +109,9 @@
set(compiler_args -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
endif()
+ if(ARCHIVER_IN_TOOLCHAIN)
+ list(APPEND compiler_args -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
+ endif()
list(APPEND ARG_DEPENDS ${TOOLCHAIN_TOOLS})
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26652.77919.patch
Type: text/x-patch
Size: 4614 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161115/1754f279/attachment.bin>
More information about the llvm-commits
mailing list