1 # This file handles building LLVM runtime sub-projects.
3 # Runtimes are different from tools or other drop-in projects because runtimes
4 # should be built with the LLVM toolchain from the build directory. This file is
5 # a first step to formalizing runtime build interfaces.
7 # In the current state this file only works with compiler-rt, other runtimes
8 # will work as the runtime build interface standardizes.
10 # Find all subdirectories containing CMake projects
12 foreach(entry ${entries})
13 if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt)
14 list(APPEND runtimes ${entry})
18 # Side-by-side subprojects layout.
19 set(LLVM_ALL_RUNTIMES "libcxx;libcxxabi;libunwind;compiler-rt")
20 set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
21 "Semicolon-separated list of runtimes to build (${LLVM_ALL_RUNTIMES}), or \"all\".")
22 if(LLVM_ENABLE_RUNTIMES STREQUAL "all" )
23 set(LLVM_ENABLE_RUNTIMES ${LLVM_ALL_RUNTIMES})
25 foreach(proj ${LLVM_ENABLE_RUNTIMES})
26 set(proj_dir "${CMAKE_CURRENT_SOURCE_DIR}/../../${proj}")
27 if(IS_DIRECTORY ${proj_dir} AND EXISTS ${proj_dir}/CMakeLists.txt)
28 list(APPEND runtimes ${proj_dir})
30 message(FATAL_ERROR "LLVM_ENABLE_RUNTIMES requests ${proj} but directory not found: ${proj_dir}")
32 string(TOUPPER "${proj}" canon_name)
33 STRING(REGEX REPLACE "-" "_" canon_name ${canon_name})
34 set(LLVM_EXTERNAL_${canon_name}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../${proj}")
37 function(get_compiler_rt_path path)
38 foreach(entry ${runtimes})
39 get_filename_component(projName ${entry} NAME)
40 if("${projName}" MATCHES "compiler-rt")
41 set(${path} ${entry} PARENT_SCOPE)
47 # If this file is acting as a top-level CMake invocation, this code path is
48 # triggered by the external project call for the runtimes target below.
49 if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
51 function(runtime_register_component name)
52 set_property(GLOBAL APPEND PROPERTY SUB_COMPONENTS ${name})
55 cmake_minimum_required(VERSION 3.4.3)
56 project(Runtimes C CXX ASM)
58 # Add the root project's CMake modules, and the LLVM build's modules to the
60 list(INSERT CMAKE_MODULE_PATH 0
61 "${CMAKE_CURRENT_SOURCE_DIR}/../cmake"
62 "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules"
63 "${LLVM_LIBRARY_DIR}/cmake/llvm"
66 # Some of the runtimes will conditionally use the compiler-rt sanitizers
67 # to make this work smoothly we ensure that compiler-rt is added first in
68 # the list of sub-projects. This allows other sub-projects to have checks
69 # like `if(TARGET asan)` to enable building with asan.
70 get_compiler_rt_path(compiler_rt_path)
72 list(REMOVE_ITEM runtimes ${compiler_rt_path})
73 if(NOT LLVM_BUILD_COMPILER_RT)
74 list(INSERT runtimes 0 ${compiler_rt_path})
78 # LLVMConfig.cmake contains a bunch of CMake variables from the LLVM build.
79 # This file is installed as part of LLVM distributions, so this can be used
80 # either from a build directory or an installed LLVM.
83 # Setting these variables will allow the sub-build to put their outputs into
84 # the library and bin directories of the top-level build.
85 set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_DIR})
86 set(LLVM_RUNTIME_OUTPUT_INTDIR ${LLVM_TOOLS_BINARY_DIR})
88 # This variable makes sure that e.g. llvm-lit is found.
89 set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR})
92 set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
95 set(SAFE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
96 set(SAFE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
98 include(CheckLibraryExists)
99 include(CheckCCompilerFlag)
101 check_library_exists(c fopen "" LLVM_HAS_C_LIB)
102 check_c_compiler_flag(-nodefaultlibs LLVM_HAS_NODEFAULTLIBS_FLAG)
103 if(LLVM_HAS_NODEFAULTLIBS_FLAG)
104 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
106 list(APPEND CMAKE_REQUIRED_LIBRARIES c)
110 # Avoid checking whether the compiler is working.
111 set(LLVM_COMPILER_CHECKED ON)
112 # Enable warnings, otherwise -w gets added to the cflags by HandleLLVMOptions
113 # resulting in unjustified successes by check_cxx_compiler_flag.
114 set(LLVM_ENABLE_WARNINGS ON)
116 # Handle common options used by all runtimes.
118 include(HandleLLVMOptions)
120 set(CMAKE_REQUIRED_FLAGS ${SAFE_CMAKE_REQUIRED_FLAGS})
121 set(CMAKE_REQUIRED_LIBRARIES ${SAFE_CMAKE_REQUIRED_LIBRARIES})
123 if(NOT LLVM_RUNTIMES_PREFIX)
124 set(LLVM_RUNTIMES_PREFIX "${LLVM_RUNTIMES_TARGET}/")
127 string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
130 foreach(entry ${runtimes})
131 get_filename_component(projName ${entry} NAME)
133 # TODO: Clean this up as part of an interface standardization
134 string(REPLACE "-" "_" canon_name ${projName})
135 string(TOUPPER ${canon_name} canon_name)
136 # The subdirectories need to treat this as standalone builds
137 set(${canon_name}_STANDALONE_BUILD On)
139 # Setting a variable to let sub-projects detect which other projects
140 # will be included under here.
141 set(HAVE_${canon_name} On)
144 set(SAFE_LLVM_BINARY_DIR ${LLVM_BINARY_DIR})
145 set(SAFE_LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
146 set(SAFE_LLVM_RUNTIME_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
148 # We do this in two loops so that HAVE_* is set for each runtime before the
149 # other runtimes are added.
150 foreach(entry ${runtimes})
151 get_filename_component(projName ${entry} NAME)
153 # Between each sub-project we want to cache and clear the LIT properties
154 set_property(GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
155 set_property(GLOBAL PROPERTY LLVM_LIT_PARAMS)
156 set_property(GLOBAL PROPERTY LLVM_LIT_DEPENDS)
157 set_property(GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
159 add_subdirectory(${entry} ${projName})
161 get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
162 get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS)
163 get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS)
164 get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
166 list(APPEND RUNTIMES_LIT_TESTSUITES ${LLVM_LIT_TESTSUITES})
167 list(APPEND RUNTIMES_LIT_PARAMS ${LLVM_LIT_PARAMS})
168 list(APPEND RUNTIMES_LIT_DEPENDS ${LLVM_LIT_DEPENDS})
169 list(APPEND RUNTIMES_LIT_EXTRA_ARGS ${LLVM_LIT_EXTRA_ARGS})
171 if(LLVM_RUNTIMES_TARGET)
172 if(NOT "${projName}" MATCHES "compiler-rt")
173 set(LLVM_BINARY_DIR "${SAFE_LLVM_BINARY_DIR}")
174 set(LLVM_LIBRARY_OUTPUT_INTDIR "${SAFE_LLVM_LIBRARY_OUTPUT_INTDIR}")
175 set(LLVM_RUNTIME_OUTPUT_INTDIR "${SAFE_LLVM_RUNTIME_OUTPUT_INTDIR}")
180 if(LLVM_INCLUDE_TESTS)
181 # Add a global check rule now that all subdirectories have been traversed
182 # and we know the total set of lit testsuites.
184 add_lit_target(check-runtimes
185 "Running all regression tests"
186 ${RUNTIMES_LIT_TESTSUITES}
187 PARAMS ${RUNTIMES_LIT_PARAMS}
188 DEPENDS ${RUNTIMES_LIT_DEPENDS}
189 ARGS ${RUNTIMES_LIT_EXTRA_ARGS}
191 add_custom_target(runtimes-test-depends DEPENDS ${RUNTIMES_LIT_DEPENDS})
194 get_property(SUB_COMPONENTS GLOBAL PROPERTY SUB_COMPONENTS)
196 list(REMOVE_DUPLICATES SUB_COMPONENTS)
197 foreach(component ${SUB_COMPONENTS})
198 if(NOT TARGET ${component})
199 message(SEND_ERROR "Missing target for runtime component ${component}!")
203 if(TARGET check-${component})
204 list(APPEND SUB_CHECK_TARGETS check-${component})
207 if(TARGET install-${component})
208 list(APPEND SUB_INSTALL_TARGETS install-${component})
210 if(TARGET install-${component}-stripped)
211 list(APPEND SUB_INSTALL_TARGETS install-${component}-stripped)
215 if(LLVM_RUNTIMES_TARGET)
217 ${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
218 ${LLVM_BINARY_DIR}/runtimes/${LLVM_RUNTIMES_TARGET}/Components.cmake)
221 ${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
222 ${LLVM_BINARY_DIR}/runtimes/Components.cmake)
226 else() # if this is included from LLVM's CMake
227 include(LLVMExternalProjectUtils)
229 if(NOT LLVM_BUILD_RUNTIMES)
230 set(EXTRA_ARGS EXCLUDE_FROM_ALL)
233 function(builtin_default_target compiler_rt_path)
234 llvm_ExternalProject_Add(builtins
235 ${compiler_rt_path}/lib/builtins
236 CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
237 -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
238 -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TRIPLE}
239 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
240 -DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE}
241 -DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE}
242 -DCMAKE_C_COMPILER_WORKS=ON
243 -DCMAKE_ASM_COMPILER_WORKS=ON
244 PASSTHROUGH_PREFIXES COMPILER_RT
250 function(builtin_register_target compiler_rt_path target)
251 string(REPLACE "-" ";" builtin_target_list ${target})
252 foreach(item ${builtin_target_list})
253 string(TOLOWER "${item}" item_lower)
254 if(item_lower MATCHES "darwin")
255 message(FATAL_ERROR "LLVM_BUILTIN_TARGETS isn't implemented for Darwin platform!")
259 get_cmake_property(variableNames VARIABLES)
260 foreach(variableName ${variableNames})
261 if(variableName MATCHES "^BUILTINS_${target}")
262 string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName})
263 list(APPEND ${target}_extra_args "-D${new_name}=${${variableName}}")
267 llvm_ExternalProject_Add(builtins-${target}
268 ${compiler_rt_path}/lib/builtins
269 CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
270 -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
271 -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
272 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
273 -DCMAKE_C_COMPILER_TARGET=${target}
274 -DCMAKE_ASM_COMPILER_TARGET=${target}
275 -DCMAKE_C_COMPILER_WORKS=ON
276 -DCMAKE_ASM_COMPILER_WORKS=ON
277 -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
278 ${${target}_extra_args}
279 PASSTHROUGH_PREFIXES CLANG_DEFAULT
280 TOOLCHAIN_TOOLS clang lld llvm-ar llvm-ranlib llvm-nm llvm-objcopy llvm-objdump llvm-strip
285 # If compiler-rt is present we need to build the builtin libraries first. This
286 # is required because the other runtimes need the builtin libraries present
287 # before the just-built compiler can pass the configuration tests.
288 get_compiler_rt_path(compiler_rt_path)
290 if(NOT LLVM_BUILTIN_TARGETS)
291 builtin_default_target(${compiler_rt_path})
293 if("default" IN_LIST LLVM_BUILTIN_TARGETS)
294 builtin_default_target(${compiler_rt_path})
295 list(REMOVE_ITEM LLVM_BUILTIN_TARGETS "default")
297 add_custom_target(builtins)
298 add_custom_target(install-builtins)
299 add_custom_target(install-builtins-stripped)
302 foreach(target ${LLVM_BUILTIN_TARGETS})
303 builtin_register_target(${compiler_rt_path} ${target})
305 add_dependencies(builtins builtins-${target})
306 add_dependencies(install-builtins install-builtins-${target})
307 add_dependencies(install-builtins-stripped install-builtins-${target}-stripped)
311 # We don't need to depend on the builtins if we're building instrumented
312 # because the next stage will use the same compiler used to build this stage.
313 if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
314 add_dependencies(clang-bootstrap-deps builtins)
318 # We create a list the names of all the runtime projects in all uppercase and
319 # with dashes turned to underscores. This gives us the CMake variable prefixes
320 # for all variables that will apply to runtimes.
321 foreach(entry ${runtimes})
322 get_filename_component(projName ${entry} NAME)
323 string(REPLACE "-" "_" canon_name ${projName})
324 string(TOUPPER ${canon_name} canon_name)
325 list(APPEND prefixes ${canon_name})
327 string(FIND ${projName} "lib" LIB_IDX)
329 string(SUBSTRING ${projName} 3 -1 projName)
331 list(APPEND runtime_names ${projName})
334 function(runtime_default_target)
335 cmake_parse_arguments(ARG "" "" "DEPS;PREFIXES" ${ARGN})
337 include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL)
338 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/Components.cmake)
340 foreach(runtime_name ${runtime_names})
341 list(APPEND extra_targets
343 install-${runtime_name}
344 install-${runtime_name}-stripped)
345 if(LLVM_INCLUDE_TESTS)
346 list(APPEND test_targets check-${runtime_name})
349 foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
350 if(NOT ${component} IN_LIST SUB_COMPONENTS)
351 list(APPEND extra_targets ${component} install-${component} install-${component}-stripped)
355 if(LLVM_INCLUDE_TESTS)
356 list(APPEND test_targets runtimes-test-depends check-runtimes)
359 llvm_ExternalProject_Add(runtimes
360 ${CMAKE_CURRENT_SOURCE_DIR}
362 # Builtins were built separately above
363 CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
364 -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
365 -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}
366 -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TRIPLE}
367 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
368 -DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE}
369 -DCMAKE_CXX_COMPILER_TARGET=${TARGET_TRIPLE}
370 -DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE}
371 -DCMAKE_C_COMPILER_WORKS=ON
372 -DCMAKE_CXX_COMPILER_WORKS=ON
373 -DCMAKE_ASM_COMPILER_WORKS=ON
374 PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
377 EXTRA_TARGETS ${extra_targets}
381 ${SUB_INSTALL_TARGETS}
386 # runtime_register_target(target)
387 # Utility function to register external runtime target.
388 function(runtime_register_target name target)
389 cmake_parse_arguments(ARG "" "" "DEPS" ${ARGN})
390 include(${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake OPTIONAL)
391 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake)
393 set(${name}_deps ${ARG_DEPS})
394 if(NOT name STREQUAL target)
395 list(APPEND ${name}_deps runtimes-${target})
398 foreach(runtime_name ${runtime_names})
399 set(${runtime_name}-${name} ${runtime_name})
400 set(install-${runtime_name}-${name} install-${runtime_name})
401 set(install-${runtime_name}-${name}-stripped install-${runtime_name}-stripped)
402 list(APPEND ${name}_extra_targets ${runtime_name}-${name} install-${runtime_name}-${name} install-${runtime_name}-${name}-stripped)
403 if(LLVM_INCLUDE_TESTS)
404 set(check-${runtime_name}-${name} check-${runtime_name} )
405 list(APPEND ${name}_test_targets check-${runtime_name}-${name})
409 foreach(target_name IN LISTS SUB_COMPONENTS SUB_INSTALL_TARGETS)
410 set(${target_name}-${name} ${target_name})
411 list(APPEND ${name}_extra_targets ${target_name}-${name})
414 foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
415 if(NOT "${target_name}:${target_name}-${component}" IN_LIST extra_targets)
416 list(APPEND ${name}_extra_targets
417 "${target_name}:${target_name}-${component}"
418 "${target_name}:${target_name}-install-${component}")
422 if(LLVM_INCLUDE_TESTS)
423 set(runtimes-test-depends-${name} runtimes-test-depends)
424 set(check-runtimes-${name} check-runtimes)
425 list(APPEND ${name}_test_targets runtimes-test-depends-${name} check-runtimes-${name})
426 foreach(target_name IN LISTS SUB_CHECK_TARGETS)
427 set(${target_name}-${name} ${target_name})
428 list(APPEND ${name}_test_targets ${target_name}-${name})
429 list(APPEND test_targets ${target_name}-${name})
431 set(test_targets "${test_targets}" PARENT_SCOPE)
434 get_cmake_property(variableNames VARIABLES)
435 foreach(variableName ${variableNames})
436 if(variableName MATCHES "^RUNTIMES_${name}")
437 string(REPLACE "RUNTIMES_${name}_" "" new_name ${variableName})
438 list(APPEND ${name}_extra_args "-D${new_name}=${${variableName}}")
439 elseif(variableName MATCHES "^RUNTIMES_${target}")
440 string(REPLACE "RUNTIMES_${target}_" "" new_name ${variableName})
441 list(APPEND ${name}_extra_args "-D${new_name}=${${variableName}}")
445 llvm_ExternalProject_Add(runtimes-${name}
446 ${CMAKE_CURRENT_SOURCE_DIR}
447 DEPENDS ${${name}_deps}
448 # Builtins were built separately above
449 CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
450 -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
451 -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}
452 -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
453 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
454 -DCMAKE_C_COMPILER_TARGET=${target}
455 -DCMAKE_CXX_COMPILER_TARGET=${target}
456 -DCMAKE_ASM_COMPILER_TARGET=${target}
457 -DCMAKE_C_COMPILER_WORKS=ON
458 -DCMAKE_CXX_COMPILER_WORKS=ON
459 -DCMAKE_ASM_COMPILER_WORKS=ON
460 -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
461 -DLLVM_RUNTIMES_TARGET=${name}
462 ${${name}_extra_args}
463 PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
465 TOOLCHAIN_TOOLS clang lld llvm-ar llvm-ranlib llvm-nm llvm-objcopy llvm-objdump llvm-strip
466 EXTRA_TARGETS ${${name}_extra_targets}
467 ${${name}_test_targets}
473 # Create a runtimes target that uses this file as its top-level CMake file.
474 # The runtimes target is a configuration of all the runtime libraries
475 # together in a single CMake invocaiton.
476 if(NOT LLVM_RUNTIME_TARGETS)
477 runtime_default_target(
482 if("default" IN_LIST LLVM_RUNTIME_TARGETS)
483 runtime_default_target(
485 PREFIXES ${prefixes})
486 list(REMOVE_ITEM LLVM_RUNTIME_TARGETS "default")
488 add_custom_target(runtimes)
489 add_custom_target(runtimes-configure)
490 add_custom_target(install-runtimes)
491 add_custom_target(install-runtimes-stripped)
492 if(LLVM_INCLUDE_TESTS)
493 add_custom_target(check-runtimes)
494 add_custom_target(runtimes-test-depends)
497 if(LLVM_RUNTIME_DISTRIBUTION_COMPONENTS)
498 foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
499 add_custom_target(${component})
500 add_custom_target(install-${component})
505 foreach(name ${LLVM_RUNTIME_TARGETS})
506 runtime_register_target(${name} ${name}
510 add_dependencies(runtimes runtimes-${name})
511 add_dependencies(runtimes-configure runtimes-${name}-configure)
512 add_dependencies(install-runtimes install-runtimes-${name})
513 add_dependencies(install-runtimes-stripped install-runtimes-${name}-stripped)
514 if(LLVM_INCLUDE_TESTS)
515 add_dependencies(check-runtimes check-runtimes-${name})
516 add_dependencies(runtimes-test-depends runtimes-test-depends-${name})
520 foreach(sanitizer ${LLVM_RUNTIME_SANITIZERS})
521 if (sanitizer STREQUAL "Address")
522 set(sanitizer_name "asan")
523 elseif (sanitizer STREQUAL "Memory")
524 set(sanitizer_name "msan")
525 elseif (sanitizer STREQUAL "Thread")
526 set(sanitizer_name "tsan")
527 elseif (sanitizer STREQUAL "Undefined")
528 set(sanitizer_name "ubsan")
530 message(FATAL_ERROR "Unsupported value of LLVM_RUNTIME_TARGET_SANITIZERS: ${sanitizers}")
532 foreach(name ${LLVM_RUNTIME_SANITIZER_${sanitizer}_TARGETS})
533 runtime_register_target(${name}-${sanitizer_name} ${name}
534 DEPS runtimes-${name}
535 CMAKE_ARGS -DLLVM_USE_SANITIZER=${sanitizer}
536 -DLLVM_RUNTIMES_PREFIX=${name}/
537 -DLLVM_RUNTIMES_LIBDIR_SUFFIX=/${sanitizer_name}
539 add_dependencies(runtimes runtimes-${name}-${sanitizer_name})
540 add_dependencies(runtimes-configure runtimes-${name}-${sanitizer_name}-configure)
541 add_dependencies(install-runtimes install-runtimes-${name}-${sanitizer_name})
542 add_dependencies(install-runtimes-stripped install-runtimes-${name}-${sanitizer_name}-stripped)
547 # TODO: This is a hack needed because the libcxx headers are copied into the
548 # build directory during configuration. Without that step the clang in the
549 # build directory cannot find the C++ headers in certain configurations.
550 # I need to build a mechanism for runtime projects to provide CMake code
551 # that executes at LLVM configuration time to handle this case.
552 if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
553 add_dependencies(clang-bootstrap-deps runtimes-configure)
556 if(LLVM_INCLUDE_TESTS)
557 set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_DEPENDS runtimes-test-depends)
558 set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-runtimes)
560 set(RUNTIMES_TEST_DEPENDS
571 foreach(target ${test_targets} ${SUB_CHECK_TARGETS})
572 add_dependencies(${target} ${RUNTIMES_TEST_DEPENDS})