Revert r354244 "[DAGCombiner] Eliminate dead stores to stack."
[llvm-complete.git] / runtimes / CMakeLists.txt
blobf0ffa431aa0b744b0b05857f927ea91b9b0d721e
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
11 file(GLOB entries *)
12 foreach(entry ${entries})
13   if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt)
14     list(APPEND runtimes ${entry})
15   endif()
16 endforeach()
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})
24 endif()
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})
29   else()
30     message(FATAL_ERROR "LLVM_ENABLE_RUNTIMES requests ${proj} but directory not found: ${proj_dir}")
31   endif()
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}")
35 endforeach()
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)
42       return()
43     endif()
44   endforeach()
45 endfunction()
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})
53   endfunction()
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
59   # CMake module path.
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"
64   )
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)
71   if(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})
75     endif()
76   endif()
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.
81   include(LLVMConfig)
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})
90   set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
92   if(APPLE)
93     set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
94   endif()
96   include(CheckLibraryExists)
97   include(CheckCCompilerFlag)
99   # We don't have libc++ (yet).
100   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
102   # Avoid checking whether the compiler is working.
103   set(LLVM_COMPILER_CHECKED ON)
105   # Enable warnings, otherwise -w gets added to the cflags by HandleLLVMOptions
106   # resulting in unjustified successes by check_cxx_compiler_flag.
107   set(LLVM_ENABLE_WARNINGS ON)
109   # Handle common options used by all runtimes.
110   include(AddLLVM)
111   include(HandleLLVMOptions)
112   include(FindPythonInterp)
114   # Remove the -nostdlib++ option we've added earlier.
115   string(REPLACE "-nostdlib++" "" CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
117   # This can be used to detect whether we're in the runtimes build.
118   set(RUNTIMES_BUILD ON)
120   foreach(entry ${runtimes})
121     get_filename_component(projName ${entry} NAME)
123     # TODO: Clean this up as part of an interface standardization
124     string(REPLACE "-" "_" canon_name ${projName})
125     string(TOUPPER ${canon_name} canon_name)
127     if(LLVM_RUNTIMES_LIBDIR_SUFFIX)
128       set(${canon_name}_LIBDIR_SUFFIX "${LLVM_RUNTIMES_LIBDIR_SUFFIX}" CACHE STRING "" FORCE)
129     endif()
131     # Setting a variable to let sub-projects detect which other projects
132     # will be included under here.
133     set(HAVE_${canon_name} ON)
134   endforeach()
136   # We do this in two loops so that HAVE_* is set for each runtime before the
137   # other runtimes are added.
138   foreach(entry ${runtimes})
139     get_filename_component(projName ${entry} NAME)
141     # Between each sub-project we want to cache and clear the LIT properties
142     set_property(GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
143     set_property(GLOBAL PROPERTY LLVM_LIT_PARAMS)
144     set_property(GLOBAL PROPERTY LLVM_LIT_DEPENDS)
145     set_property(GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
147     add_subdirectory(${entry} ${projName})
149     get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
150     get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS)
151     get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS)
152     get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
154     list(APPEND RUNTIMES_LIT_TESTSUITES ${LLVM_LIT_TESTSUITES})
155     list(APPEND RUNTIMES_LIT_PARAMS ${LLVM_LIT_PARAMS})
156     list(APPEND RUNTIMES_LIT_DEPENDS ${LLVM_LIT_DEPENDS})
157     list(APPEND RUNTIMES_LIT_EXTRA_ARGS ${LLVM_LIT_EXTRA_ARGS})
158   endforeach()
160   if(LLVM_INCLUDE_TESTS)
161     # Add a global check rule now that all subdirectories have been traversed
162     # and we know the total set of lit testsuites.
164     add_lit_target(check-runtimes
165       "Running all regression tests"
166       ${RUNTIMES_LIT_TESTSUITES}
167       PARAMS ${RUNTIMES_LIT_PARAMS}
168       DEPENDS ${RUNTIMES_LIT_DEPENDS}
169       ARGS ${RUNTIMES_LIT_EXTRA_ARGS}
170       )
171     add_custom_target(runtimes-test-depends DEPENDS ${RUNTIMES_LIT_DEPENDS})
172   endif()
174   get_property(SUB_COMPONENTS GLOBAL PROPERTY SUB_COMPONENTS)
175   if(SUB_COMPONENTS)
176     list(REMOVE_DUPLICATES SUB_COMPONENTS)
177     foreach(component ${SUB_COMPONENTS})
178       if(NOT TARGET ${component})
179         message(SEND_ERROR "Missing target for runtime component ${component}!")
180         continue()
181       endif()
183       if(TARGET check-${component})
184         list(APPEND SUB_CHECK_TARGETS check-${component})
185       endif()
187       if(TARGET install-${component})
188         list(APPEND SUB_INSTALL_TARGETS install-${component})
189       endif()
190       if(TARGET install-${component}-stripped)
191         list(APPEND SUB_INSTALL_TARGETS install-${component}-stripped)
192       endif()
193     endforeach()
195     if(LLVM_RUNTIMES_TARGET)
196       configure_file(
197         ${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
198         ${LLVM_BINARY_DIR}/runtimes/${LLVM_RUNTIMES_TARGET}/Components.cmake)
199     else()
200       configure_file(
201         ${CMAKE_CURRENT_SOURCE_DIR}/Components.cmake.in
202         ${LLVM_BINARY_DIR}/runtimes/Components.cmake)
203     endif()
204   endif()
206 else() # if this is included from LLVM's CMake
207   include(LLVMExternalProjectUtils)
209   if(NOT LLVM_BUILD_RUNTIMES)
210     set(EXTRA_ARGS EXCLUDE_FROM_ALL)
211   endif()
213   function(builtin_default_target compiler_rt_path)
214     llvm_ExternalProject_Add(builtins
215                              ${compiler_rt_path}/lib/builtins
216                              CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
217                                         -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
218                                         -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TRIPLE}
219                                         -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
220                                         -DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE}
221                                         -DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE}
222                                         -DCMAKE_C_COMPILER_WORKS=ON
223                                         -DCMAKE_ASM_COMPILER_WORKS=ON
224                              PASSTHROUGH_PREFIXES COMPILER_RT
225                              USE_TOOLCHAIN
226                              ${EXTRA_ARGS})
227   endfunction()
229   function(builtin_register_target compiler_rt_path target)
230     string(REPLACE "-" ";" builtin_target_list ${target})
231     foreach(item ${builtin_target_list})
232       string(TOLOWER "${item}" item_lower)
233       if(item_lower MATCHES "darwin")
234         message(FATAL_ERROR "LLVM_BUILTIN_TARGETS isn't implemented for Darwin platform!")
235       endif()
236     endforeach()
238     get_cmake_property(variableNames VARIABLES)
239     foreach(variableName ${variableNames})
240       if(variableName MATCHES "^BUILTINS_${target}")
241         string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName})
242         list(APPEND ${target}_extra_args "-D${new_name}=${${variableName}}")
243       endif()
244     endforeach()
246     llvm_ExternalProject_Add(builtins-${target}
247                              ${compiler_rt_path}/lib/builtins
248                              CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
249                                         -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
250                                         -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
251                                         -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
252                                         -DCMAKE_C_COMPILER_TARGET=${target}
253                                         -DCMAKE_ASM_COMPILER_TARGET=${target}
254                                         -DCMAKE_C_COMPILER_WORKS=ON
255                                         -DCMAKE_ASM_COMPILER_WORKS=ON
256                                         -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
257                                         ${${target}_extra_args}
258                              TOOLCHAIN_TOOLS clang lld llvm-ar llvm-ranlib llvm-nm llvm-objcopy llvm-objdump llvm-strip
259                              USE_TOOLCHAIN
260                              ${EXTRA_ARGS})
261   endfunction()
263   # If compiler-rt is present we need to build the builtin libraries first. This
264   # is required because the other runtimes need the builtin libraries present
265   # before the just-built compiler can pass the configuration tests.
266   get_compiler_rt_path(compiler_rt_path)
267   if(compiler_rt_path)
268     if(NOT LLVM_BUILTIN_TARGETS)
269       builtin_default_target(${compiler_rt_path})
270     else()
271       if("default" IN_LIST LLVM_BUILTIN_TARGETS)
272         builtin_default_target(${compiler_rt_path})
273         list(REMOVE_ITEM LLVM_BUILTIN_TARGETS "default")
274       else()
275         add_custom_target(builtins)
276         add_custom_target(install-builtins)
277         add_custom_target(install-builtins-stripped)
278       endif()
280       foreach(target ${LLVM_BUILTIN_TARGETS})
281         builtin_register_target(${compiler_rt_path} ${target})
283         add_dependencies(builtins builtins-${target})
284         add_dependencies(install-builtins install-builtins-${target})
285         add_dependencies(install-builtins-stripped install-builtins-${target}-stripped)
286       endforeach()
287     endif()
288     set(deps builtins)
289     # We don't need to depend on the builtins if we're building instrumented
290     # because the next stage will use the same compiler used to build this stage.
291     if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
292       add_dependencies(clang-bootstrap-deps builtins)
293     endif()
294   endif()
296   # We create a list the names of all the runtime projects in all uppercase and
297   # with dashes turned to underscores. This gives us the CMake variable prefixes
298   # for all variables that will apply to runtimes.
299   foreach(entry ${runtimes})
300     get_filename_component(projName ${entry} NAME)
301     string(REPLACE "-" "_" canon_name ${projName})
302     string(TOUPPER ${canon_name} canon_name)
303     list(APPEND prefixes ${canon_name})
305     string(FIND ${projName} "lib" LIB_IDX)
306     if(LIB_IDX EQUAL 0)
307       string(SUBSTRING ${projName} 3 -1 projName)
308     endif()
309     list(APPEND runtime_names ${projName})
310   endforeach()
312   function(runtime_default_target)
313     cmake_parse_arguments(ARG "" "" "DEPS;PREFIXES" ${ARGN})
315     include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL)
316     set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/Components.cmake)
318     foreach(runtime_name ${runtime_names})
319       list(APPEND extra_targets
320         ${runtime_name}
321         install-${runtime_name}
322         install-${runtime_name}-stripped)
323       if(LLVM_INCLUDE_TESTS)
324         list(APPEND test_targets check-${runtime_name})
325       endif()
326     endforeach()
327     foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
328       if(NOT ${component} IN_LIST SUB_COMPONENTS)
329         list(APPEND extra_targets ${component} install-${component} install-${component}-stripped)
330       endif()
331     endforeach()
333     if(LLVM_INCLUDE_TESTS)
334       list(APPEND test_targets runtimes-test-depends check-runtimes)
335     endif()
337     llvm_ExternalProject_Add(runtimes
338                              ${CMAKE_CURRENT_SOURCE_DIR}
339                              DEPENDS ${ARG_DEPS}
340                              # Builtins were built separately above
341                              CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
342                                         -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
343                                         -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}
344                                         -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_TRIPLE}
345                                         -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
346                                         -DCMAKE_C_COMPILER_TARGET=${TARGET_TRIPLE}
347                                         -DCMAKE_CXX_COMPILER_TARGET=${TARGET_TRIPLE}
348                                         -DCMAKE_ASM_COMPILER_TARGET=${TARGET_TRIPLE}
349                                         -DCMAKE_C_COMPILER_WORKS=ON
350                                         -DCMAKE_CXX_COMPILER_WORKS=ON
351                                         -DCMAKE_ASM_COMPILER_WORKS=ON
352                              PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
353                                                   ${ARG_PREFIXES}
354                              EXTRA_TARGETS ${extra_targets}
355                                            ${test_targets}
356                                            ${SUB_COMPONENTS}
357                                            ${SUB_CHECK_TARGETS}
358                                            ${SUB_INSTALL_TARGETS}
359                              USE_TOOLCHAIN
360                              ${EXTRA_ARGS})
361   endfunction()
363   # runtime_register_target(target)
364   #   Utility function to register external runtime target.
365   function(runtime_register_target name target)
366     cmake_parse_arguments(ARG "" "" "DEPS" ${ARGN})
367     include(${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake OPTIONAL)
368     set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake)
370     set(${name}_deps ${ARG_DEPS})
371     if(NOT name STREQUAL target)
372       list(APPEND ${name}_deps runtimes-${target})
373     endif()
375     foreach(runtime_name ${runtime_names})
376       set(${runtime_name}-${name} ${runtime_name})
377       set(install-${runtime_name}-${name} install-${runtime_name})
378       set(install-${runtime_name}-${name}-stripped install-${runtime_name}-stripped)
379       list(APPEND ${name}_extra_targets ${runtime_name}-${name} install-${runtime_name}-${name} install-${runtime_name}-${name}-stripped)
380       if(LLVM_INCLUDE_TESTS)
381         set(check-${runtime_name}-${name} check-${runtime_name} )
382         list(APPEND ${name}_test_targets check-${runtime_name}-${name})
383       endif()
384     endforeach()
386     foreach(target_name IN LISTS SUB_COMPONENTS SUB_INSTALL_TARGETS)
387       set(${target_name}-${name} ${target_name})
388       list(APPEND ${name}_extra_targets ${target_name}-${name})
389     endforeach()
391     foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
392       set(${component}-${name} ${component})
393       set(install-${component}-${name} ${component})
394       list(APPEND ${name}_extra_targets ${component}-${name} install-${component}-${name})
395     endforeach()
397     if(LLVM_INCLUDE_TESTS)
398       set(runtimes-test-depends-${name} runtimes-test-depends)
399       set(check-runtimes-${name} check-runtimes)
400       list(APPEND ${name}_test_targets runtimes-test-depends-${name} check-runtimes-${name})
401       foreach(target_name IN LISTS SUB_CHECK_TARGETS)
402         set(${target_name}-${name} ${target_name})
403         list(APPEND ${name}_test_targets ${target_name}-${name})
404         list(APPEND test_targets ${target_name}-${name})
405       endforeach()
406       set(test_targets "${test_targets}" PARENT_SCOPE)
407     endif()
409     get_cmake_property(variableNames VARIABLES)
410     foreach(variableName ${variableNames})
411       if(variableName MATCHES "^RUNTIMES_${name}")
412         string(REPLACE "RUNTIMES_${name}_" "" new_name ${variableName})
413         list(APPEND ${name}_extra_args "-D${new_name}=${${variableName}}")
414       elseif(variableName MATCHES "^RUNTIMES_${target}")
415         string(REPLACE "RUNTIMES_${target}_" "" new_name ${variableName})
416         list(APPEND ${name}_extra_args "-D${new_name}=${${variableName}}")
417       endif()
418     endforeach()
420     llvm_ExternalProject_Add(runtimes-${name}
421                              ${CMAKE_CURRENT_SOURCE_DIR}
422                              DEPENDS ${${name}_deps}
423                              # Builtins were built separately above
424                              CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
425                                         -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
426                                         -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}
427                                         -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
428                                         -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
429                                         -DCMAKE_C_COMPILER_TARGET=${target}
430                                         -DCMAKE_CXX_COMPILER_TARGET=${target}
431                                         -DCMAKE_ASM_COMPILER_TARGET=${target}
432                                         -DCMAKE_C_COMPILER_WORKS=ON
433                                         -DCMAKE_CXX_COMPILER_WORKS=ON
434                                         -DCMAKE_ASM_COMPILER_WORKS=ON
435                                         -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
436                                         -DLLVM_RUNTIMES_TARGET=${name}
437                                         ${${name}_extra_args}
438                              PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
439                              TOOLCHAIN_TOOLS clang lld llvm-ar llvm-ranlib llvm-nm llvm-objcopy llvm-objdump llvm-strip
440                              EXTRA_TARGETS ${${name}_extra_targets}
441                                            ${${name}_test_targets}
442                              USE_TOOLCHAIN
443                              ${EXTRA_ARGS})
444   endfunction()
446   if(runtimes)
447     # Create a runtimes target that uses this file as its top-level CMake file.
448     # The runtimes target is a configuration of all the runtime libraries
449     # together in a single CMake invocaiton.
450     if(NOT LLVM_RUNTIME_TARGETS)
451       runtime_default_target(
452         DEPS ${deps}
453         PREFIXES ${prefixes}
454         )
455     else()
456       if("default" IN_LIST LLVM_RUNTIME_TARGETS)
457         runtime_default_target(
458           DEPS ${deps}
459           PREFIXES ${prefixes})
460         list(REMOVE_ITEM LLVM_RUNTIME_TARGETS "default")
461       else()
462         add_custom_target(runtimes)
463         add_custom_target(runtimes-configure)
464         add_custom_target(install-runtimes)
465         add_custom_target(install-runtimes-stripped)
466         if(LLVM_INCLUDE_TESTS)
467           add_custom_target(check-runtimes)
468           add_custom_target(runtimes-test-depends)
469           set(test_targets "")
470         endif()
471         if(LLVM_RUNTIME_DISTRIBUTION_COMPONENTS)
472           foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
473             add_custom_target(${component})
474             add_custom_target(install-${component})
475           endforeach()
476         endif()
477       endif()
479       foreach(name ${LLVM_RUNTIME_TARGETS})
480         runtime_register_target(${name} ${name}
481           DEPS ${deps}
482           )
484         add_dependencies(runtimes runtimes-${name})
485         add_dependencies(runtimes-configure runtimes-${name}-configure)
486         add_dependencies(install-runtimes install-runtimes-${name})
487         add_dependencies(install-runtimes-stripped install-runtimes-${name}-stripped)
488         if(LLVM_INCLUDE_TESTS)
489           add_dependencies(check-runtimes check-runtimes-${name})
490           add_dependencies(runtimes-test-depends runtimes-test-depends-${name})
491         endif()
492       endforeach()
494       foreach(sanitizer ${LLVM_RUNTIME_SANITIZERS})
495         if (sanitizer STREQUAL "Address")
496           set(sanitizer_name "asan")
497         elseif (sanitizer STREQUAL "Memory")
498           set(sanitizer_name "msan")
499         elseif (sanitizer STREQUAL "Thread")
500           set(sanitizer_name "tsan")
501         elseif (sanitizer STREQUAL "Undefined")
502           set(sanitizer_name "ubsan")
503         else()
504           message(FATAL_ERROR "Unsupported value of LLVM_RUNTIME_TARGET_SANITIZERS: ${sanitizers}")
505         endif()
506         foreach(name ${LLVM_RUNTIME_SANITIZER_${sanitizer}_TARGETS})
507           runtime_register_target(${name}-${sanitizer_name} ${name}
508             DEPS runtimes-${name}
509             CMAKE_ARGS -DLLVM_USE_SANITIZER=${sanitizer}
510                        -DLLVM_RUNTIMES_PREFIX=${name}/
511                        -DLLVM_RUNTIMES_LIBDIR_SUFFIX=/${sanitizer_name}
512             )
513           add_dependencies(runtimes runtimes-${name}-${sanitizer_name})
514           add_dependencies(runtimes-configure runtimes-${name}-${sanitizer_name}-configure)
515           add_dependencies(install-runtimes install-runtimes-${name}-${sanitizer_name})
516           add_dependencies(install-runtimes-stripped install-runtimes-${name}-${sanitizer_name}-stripped)
517         endforeach()
518       endforeach()
519     endif()
521     # TODO: This is a hack needed because the libcxx headers are copied into the
522     # build directory during configuration. Without that step the clang in the
523     # build directory cannot find the C++ headers in certain configurations.
524     # I need to build a mechanism for runtime projects to provide CMake code
525     # that executes at LLVM configuration time to handle this case.
526     if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
527       add_dependencies(clang-bootstrap-deps runtimes-configure)
528     endif()
530     if(LLVM_INCLUDE_TESTS)
531       set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_DEPENDS runtimes-test-depends)
532       set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-runtimes)
534       set(RUNTIMES_TEST_DEPENDS
535           FileCheck
536           count
537           llvm-nm
538           llvm-objdump
539           llvm-xray
540           not
541           obj2yaml
542           sancov
543           sanstats
544         )
545       foreach(target ${test_targets} ${SUB_CHECK_TARGETS})
546         add_dependencies(${target} ${RUNTIMES_TEST_DEPENDS})
547       endforeach()
548     endif()
549   endif()
550 endif()