llvm.org GIT mirror llvm / a923c5a
[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 Petr Hosek 3 years ago
2 changed file(s) with 43 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
4444 canonicalize_tool_name(${name} nameCanon)
4545 if(NOT ARG_TOOLCHAIN_TOOLS)
4646 set(ARG_TOOLCHAIN_TOOLS clang lld)
47 if(NOT APPLE AND NOT WIN32)
48 list(APPEND ARG_TOOLCHAIN_TOOLS llvm-ar llvm-ranlib)
49 endif()
4750 endif()
4851 foreach(tool ${ARG_TOOLCHAIN_TOOLS})
4952 if(TARGET ${tool})
102105 if(CLANG_IN_TOOLCHAIN)
103106 set(compiler_args -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
104107 -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
108 endif()
109 if(llvm-ar IN_LIST TOOLCHAIN_TOOLS)
110 list(APPEND compiler_args -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
111 endif()
112 if(llvm-ranlib IN_LIST TOOLCHAIN_TOOLS)
113 list(APPEND compiler_args -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib)
105114 endif()
106115 list(APPEND ARG_DEPENDS ${TOOLCHAIN_TOOLS})
107116 endif()
138138 # is required because the other runtimes need the builtin libraries present
139139 # before the just-built compiler can pass the configuration tests.
140140 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/compiler-rt)
141 llvm_ExternalProject_Add(builtins
142 ${CMAKE_CURRENT_SOURCE_DIR}/compiler-rt/lib/builtins
143 CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
144 -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
145 PASSTHROUGH_PREFIXES COMPILER_RT
146 USE_TOOLCHAIN)
141 if(APPLE OR NOT LLVM_BUILTIN_TARGETS)
142 llvm_ExternalProject_Add(builtins
143 ${CMAKE_CURRENT_SOURCE_DIR}/compiler-rt/lib/builtins
144 CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
145 -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
146 -DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE}
147 -DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE}
148 PASSTHROUGH_PREFIXES COMPILER_RT
149 USE_TOOLCHAIN)
150 else()
151 get_cmake_property(variableNames VARIABLES)
152 add_custom_target(builtins)
153 foreach(target ${LLVM_BUILTIN_TARGETS})
154 foreach(variableName ${variableNames})
155 if(variableName MATCHES "^BUILTINS_${target}")
156 string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName})
157 list(APPEND ${target}_extra_args "-D${new_name}=${${variableName}}")
158 endif()
159 endforeach()
160 llvm_ExternalProject_Add(builtins-${target}
161 ${CMAKE_CURRENT_SOURCE_DIR}/compiler-rt/lib/builtins
162 CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
163 -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
164 -DCMAKE_C_COMPILER_TARGET=${target}
165 -DCMAKE_ASM_COMPILER_TARGET=${target}
166 -DCMAKE_C_COMPILER_WORKS=On
167 -DCMAKE_ASM_COMPILER_WORKS=On
168 -DCOMPILER_RT_DEFAULT_TARGET_ONLY=On
169 ${${target}_extra_args}
170 PASSTHROUGH_PREFIXES COMPILER_RT
171 USE_TOOLCHAIN)
172 add_dependencies(builtins builtins-${target})
173 endforeach()
174 endif()
147175 set(deps builtins)
148176 # We don't need to depend on the builtins if we're building instrumented
149177 # because the next stage will use the same compiler used to build this stage.