xref: /openbsd/gnu/llvm/llvm/runtimes/CMakeLists.txt (revision d415bd75)
1# TODO: This file assumes the Clang toolchain so it'd be better if it lived in
2# Clang, except there already is clang/runtime directory which contains
3# similar although simpler functionality. We should figure out how to merge
4# the two files.
5
6set(COMMON_CMAKE_ARGS "-DHAVE_LLVM_LIT=ON")
7foreach(proj ${LLVM_ENABLE_RUNTIMES})
8  set(proj_dir "${CMAKE_CURRENT_SOURCE_DIR}/../../${proj}")
9  if(IS_DIRECTORY ${proj_dir} AND EXISTS ${proj_dir}/CMakeLists.txt)
10    list(APPEND runtimes ${proj_dir})
11  else()
12    message(FATAL_ERROR "LLVM_ENABLE_RUNTIMES requests ${proj} but directory not found: ${proj_dir}")
13  endif()
14  string(TOUPPER "${proj}" canon_name)
15  STRING(REGEX REPLACE "-" "_" canon_name ${canon_name})
16  set(LLVM_EXTERNAL_${canon_name}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../${proj}")
17endforeach()
18
19function(get_compiler_rt_path path)
20  foreach(entry ${runtimes})
21    get_filename_component(projName ${entry} NAME)
22    if("${projName}" MATCHES "compiler-rt")
23      set(${path} ${entry} PARENT_SCOPE)
24      return()
25    endif()
26  endforeach()
27endfunction()
28
29include(LLVMExternalProjectUtils)
30
31if(NOT LLVM_BUILD_RUNTIMES)
32  set(EXTRA_ARGS EXCLUDE_FROM_ALL)
33endif()
34
35function(check_apple_target triple builtin_or_runtime)
36  set(error "\
37compiler-rt for Darwin builds for all platforms and architectures using a \
38single configuration. Specify only a single darwin triple (e.g. x86_64-apple-darwin) \
39in your targets list (and not a triple for a specific platform such as macos). \
40You can use variables such as COMPILER_RT_ENABLE_IOS and DARWIN_ios_ARCHS to \
41control the specific platforms and architectures to build.")
42
43  set(seen_property ${builtin_or_runtime}_darwin_triple_seen)
44  string(REPLACE "-" ";" triple_components ${triple})
45  foreach(component ${triple_components})
46    string(TOLOWER "${component}" component_lower)
47    if(component_lower MATCHES "^darwin")
48      get_property(darwin_triple_seen GLOBAL PROPERTY ${seen_property})
49      if(darwin_triple_seen)
50        message(FATAL_ERROR "${error}")
51      endif()
52      set_property(GLOBAL PROPERTY ${seen_property} YES)
53      if(NOT RUNTIMES_BUILD_ALLOW_DARWIN)
54        message(FATAL_ERROR "\
55${error} Set RUNTIMES_BUILD_ALLOW_DARWIN to allow a single darwin triple.")
56      endif()
57    elseif(component_lower MATCHES "^ios|^macos|^tvos|^watchos")
58      message(FATAL_ERROR "${error}")
59    endif()
60  endforeach()
61endfunction()
62
63function(builtin_default_target compiler_rt_path)
64  cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
65
66  set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON)
67  # AIX should fold 32-bit & 64-bit arch libraries into a single archive.
68  if (LLVM_TARGET_TRIPLE MATCHES "aix")
69    set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF)
70  endif()
71
72  llvm_ExternalProject_Add(builtins
73                           ${compiler_rt_path}/lib/builtins
74                           DEPENDS ${ARG_DEPENDS}
75                           CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
76                                      -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
77                                      -DLLVM_DEFAULT_TARGET_TRIPLE=${LLVM_TARGET_TRIPLE}
78                                      -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
79                                      -DCMAKE_C_COMPILER_WORKS=ON
80                                      -DCMAKE_ASM_COMPILER_WORKS=ON
81                                      ${COMMON_CMAKE_ARGS}
82                                      ${BUILTINS_CMAKE_ARGS}
83                           PASSTHROUGH_PREFIXES COMPILER_RT
84                                                DARWIN
85                                                SANITIZER
86                           USE_TOOLCHAIN
87                           TARGET_TRIPLE ${LLVM_TARGET_TRIPLE}
88                           ${EXTRA_ARGS})
89endfunction()
90
91function(builtin_register_target compiler_rt_path target)
92  cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
93
94  check_apple_target(${target} builtin)
95
96  get_cmake_property(variableNames VARIABLES)
97  foreach(variableName ${variableNames})
98    string(FIND "${variableName}" "BUILTINS_${target}" out)
99    if("${out}" EQUAL 0)
100      string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName})
101      string(REPLACE ";" "|" new_value "${${variableName}}")
102      list(APPEND ${target}_extra_args "-D${new_name}=${new_value}")
103    endif()
104  endforeach()
105
106  llvm_ExternalProject_Add(builtins-${target}
107                           ${compiler_rt_path}/lib/builtins
108                           DEPENDS ${ARG_DEPENDS}
109                           CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
110                                      -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
111                                      -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
112                                      -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
113                                      -DCMAKE_C_COMPILER_WORKS=ON
114                                      -DCMAKE_ASM_COMPILER_WORKS=ON
115                                      -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
116                                      ${COMMON_CMAKE_ARGS}
117                                      ${${target}_extra_args}
118                           USE_TOOLCHAIN
119                           TARGET_TRIPLE ${target}
120                           ${EXTRA_ARGS})
121endfunction()
122
123# If compiler-rt is present we need to build the builtin libraries first. This
124# is required because the other runtimes need the builtin libraries present
125# before the just-built compiler can pass the configuration tests.
126get_compiler_rt_path(compiler_rt_path)
127if(compiler_rt_path)
128  if(NOT LLVM_BUILTIN_TARGETS)
129    builtin_default_target(${compiler_rt_path}
130      DEPENDS clang-resource-headers)
131  else()
132    if("default" IN_LIST LLVM_BUILTIN_TARGETS)
133      builtin_default_target(${compiler_rt_path}
134        DEPENDS clang-resource-headers)
135      list(REMOVE_ITEM LLVM_BUILTIN_TARGETS "default")
136    else()
137      add_custom_target(builtins)
138      add_custom_target(install-builtins)
139      add_custom_target(install-builtins-stripped)
140    endif()
141
142    foreach(target ${LLVM_BUILTIN_TARGETS})
143      builtin_register_target(${compiler_rt_path} ${target}
144        DEPENDS clang-resource-headers)
145
146      add_dependencies(builtins builtins-${target})
147      add_dependencies(install-builtins install-builtins-${target})
148      add_dependencies(install-builtins-stripped install-builtins-${target}-stripped)
149    endforeach()
150  endif()
151  set(builtins_dep builtins)
152  # We don't need to depend on the builtins if we're building instrumented
153  # because the next stage will use the same compiler used to build this stage.
154  if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
155    add_dependencies(clang-bootstrap-deps builtins)
156  endif()
157endif()
158
159# Create a list with the names of all the runtime projects in all uppercase and
160# with dashes turned to underscores. This gives us the CMake variable `prefixes`
161# for all variables that will apply to runtimes.
162foreach(entry ${runtimes})
163  get_filename_component(projName ${entry} NAME)
164  if(projName STREQUAL "libc")
165    # For now, we will use the name "llvmlibc" for the libc project as it is
166    # not a full libc yet. Also, if we leave it as is, the "lib" prefix gets
167    # stripped below and the targets endup having the name "c", "check-c" etc.
168    set(projName "llvmlibc")
169  endif()
170  string(REPLACE "-" "_" canon_name ${projName})
171  string(TOUPPER ${canon_name} canon_name)
172  list(APPEND prefixes ${canon_name})
173  if (${canon_name} STREQUAL "OPENMP")
174    list(APPEND prefixes "LIBOMP" "LIBOMPTARGET")
175  endif()
176  # Many compiler-rt options start with SANITIZER_ and DARWIN_ rather than
177  # COMPILER_RT_, so when compiler-rt is enabled, consider both.
178  if(canon_name STREQUAL "COMPILER_RT")
179    list(APPEND prefixes SANITIZER DARWIN)
180  endif()
181  if(canon_name STREQUAL "LLVMLIBC")
182    list(APPEND prefixes "LLVM_LIBC")
183    list(APPEND prefixes "LIBC_")
184  endif()
185
186  string(FIND ${projName} "lib" LIB_IDX)
187  if(LIB_IDX EQUAL 0)
188    string(SUBSTRING ${projName} 3 -1 projName)
189  endif()
190  list(APPEND runtime_names ${projName})
191endforeach()
192
193function(runtime_default_target)
194  cmake_parse_arguments(ARG "" "" "DEPENDS;PREFIXES" ${ARGN})
195
196  include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL)
197  set(SUB_CHECK_TARGETS ${SUB_CHECK_TARGETS} PARENT_SCOPE)
198  set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/Components.cmake)
199
200  foreach(runtime_name ${runtime_names})
201    list(APPEND extra_targets
202      ${runtime_name}
203      install-${runtime_name}
204      install-${runtime_name}-stripped)
205    if(LLVM_INCLUDE_TESTS)
206      list(APPEND test_targets check-${runtime_name})
207    endif()
208  endforeach()
209  foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
210    if(NOT ${component} IN_LIST SUB_COMPONENTS)
211      list(APPEND extra_targets install-${component} install-${component}-stripped)
212    endif()
213  endforeach()
214
215  if(LLVM_INCLUDE_TESTS)
216    set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_TESTSUITES "@${LLVM_BINARY_DIR}/runtimes/runtimes-bins/lit.tests")
217    list(APPEND test_targets runtimes-test-depends check-runtimes)
218  endif()
219
220  set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON)
221  # AIX should fold 32-bit & 64-bit arch libraries into a single archive.
222  if (LLVM_TARGET_TRIPLE MATCHES "aix")
223    set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF)
224  endif()
225
226  llvm_ExternalProject_Add(runtimes
227                           ${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
228                           DEPENDS ${ARG_DEPENDS}
229                           # Builtins were built separately above
230                           CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
231                                      -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
232                                      -DLLVM_DEFAULT_TARGET_TRIPLE=${LLVM_TARGET_TRIPLE}
233                                      -DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
234                                      -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
235                                      -DLLVM_BUILD_TOOLS=${LLVM_BUILD_TOOLS}
236                                      -DCMAKE_C_COMPILER_WORKS=ON
237                                      -DCMAKE_CXX_COMPILER_WORKS=ON
238                                      -DCMAKE_ASM_COMPILER_WORKS=ON
239                                      ${COMMON_CMAKE_ARGS}
240                                      ${RUNTIMES_CMAKE_ARGS}
241                           PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
242                                                LLVM_USE_LINKER
243                                                ${ARG_PREFIXES}
244                           EXTRA_TARGETS ${extra_targets}
245                                         ${test_targets}
246                                         ${SUB_COMPONENTS}
247                                         ${SUB_CHECK_TARGETS}
248                                         ${SUB_INSTALL_TARGETS}
249                           USE_TOOLCHAIN
250                           TARGET_TRIPLE ${LLVM_TARGET_TRIPLE}
251                           ${EXTRA_ARGS})
252endfunction()
253
254# runtime_register_target(target)
255#   Utility function to register external runtime target.
256function(runtime_register_target name target)
257  cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS" ${ARGN})
258  include(${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake OPTIONAL)
259  set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${name}/Components.cmake)
260
261  check_apple_target(${target} runtime)
262
263  set(${name}_deps ${ARG_DEPENDS})
264  if(NOT name STREQUAL target)
265    list(APPEND ${name}_deps runtimes-${target})
266  endif()
267
268  foreach(runtime_name ${runtime_names})
269    set(${runtime_name}-${name} ${runtime_name})
270    set(install-${runtime_name}-${name} install-${runtime_name})
271    set(install-${runtime_name}-${name}-stripped install-${runtime_name}-stripped)
272    list(APPEND ${name}_extra_targets ${runtime_name}-${name} install-${runtime_name}-${name} install-${runtime_name}-${name}-stripped)
273    if(LLVM_INCLUDE_TESTS)
274      set(check-${runtime_name}-${name} check-${runtime_name} )
275      list(APPEND ${name}_test_targets check-${runtime_name}-${name})
276    endif()
277  endforeach()
278
279  foreach(target_name IN LISTS SUB_COMPONENTS)
280    set(${target_name}-${name} ${target_name})
281    list(APPEND ${name}_extra_targets ${target_name}-${name})
282  endforeach()
283
284  foreach(target_name IN LISTS SUB_INSTALL_TARGETS)
285    set(${target_name}-${name} ${target_name})
286    set(${target_name}-${name}-stripped ${target_name}-stripped)
287    list(APPEND ${name}_extra_targets ${target_name}-${name} ${target_name}-${name}-stripped)
288  endforeach()
289
290  foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
291    if(NOT component IN_LIST SUB_COMPONENTS)
292      set(${component}-${name} ${component})
293      set(install-${component}-${name} install-${component})
294      set(install-${component}-${name}-stripped install-${component}-stripped)
295      list(APPEND ${name}_extra_targets ${component}-${name} install-${component}-${name} install-${component}-${name}-stripped)
296    endif()
297  endforeach()
298
299  if(LLVM_INCLUDE_TESTS)
300    set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_TESTSUITES "@${LLVM_BINARY_DIR}/runtimes/runtimes-${name}-bins/lit.tests")
301    set(runtimes-test-depends-${name} runtimes-test-depends)
302    set(check-runtimes-${name} check-runtimes)
303    list(APPEND ${name}_test_targets runtimes-test-depends-${name} check-runtimes-${name})
304    list(APPEND test_targets ${${name}_test_targets})
305
306    set(component_check_targets)
307    foreach(component IN LISTS LLVM_RUNTIME_DISTRIBUTION_COMPONENTS)
308      if(NOT "check-${component}" IN_LIST SUB_CHECK_TARGETS)
309        list(APPEND component_check_targets "check-${component}")
310      endif()
311    endforeach()
312
313    foreach(target_name IN LISTS SUB_CHECK_TARGETS component_check_targets)
314      set(${target_name}-${name} ${target_name})
315      list(APPEND ${name}_test_targets ${target_name}-${name})
316      list(APPEND test_targets ${target_name}-${name})
317    endforeach()
318    set(test_targets "${test_targets}" PARENT_SCOPE)
319  endif()
320
321  set(${name}_extra_args ${ARG_CMAKE_ARGS})
322  get_cmake_property(variableNames VARIABLES)
323  foreach(variableName ${variableNames})
324    string(FIND "${variableName}" "RUNTIMES_${target}_" out)
325    if("${out}" EQUAL 0)
326      string(REPLACE "RUNTIMES_${target}_" "" new_name ${variableName})
327      string(REPLACE ";" "|" new_value "${${variableName}}")
328      list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
329    endif()
330  endforeach()
331  if(NOT "${name}" STREQUAL "${target}")
332    foreach(variableName ${variableNames})
333      string(FIND "${variableName}" "RUNTIMES_${name}_" out)
334      if("${out}" EQUAL 0)
335        string(REPLACE "RUNTIMES_${name}_" "" new_name ${variableName})
336        string(REPLACE ";" "|" new_value "${${variableName}}")
337        list(APPEND ${name}_extra_args "-D${new_name}=${new_value}")
338      endif()
339    endforeach()
340  endif()
341
342  if(NOT RUNTIMES_${name}_LLVM_ENABLE_RUNTIMES AND NOT RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES)
343    string(REPLACE ";" "|" LLVM_ENABLE_RUNTIMES_PASSTHROUGH "${LLVM_ENABLE_RUNTIMES}")
344    list(APPEND ${name}_extra_args -DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES_PASSTHROUGH})
345  endif()
346
347  if(NOT RUNTIMES_${name}_LLVM_USE_LINKER AND NOT RUNTIMES_${target}_LLVM_USE_LINKER)
348    list(APPEND ${name}_extra_args -DLLVM_USE_LINKER=${LLVM_USE_LINKER})
349  endif()
350
351  llvm_ExternalProject_Add(runtimes-${name}
352                           ${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
353                           DEPENDS ${${name}_deps}
354                           # Builtins were built separately above
355                           CMAKE_ARGS -DCOMPILER_RT_BUILD_BUILTINS=Off
356                                      -DLLVM_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
357                                      -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
358                                      -DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
359                                      -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
360                                      -DCMAKE_C_COMPILER_WORKS=ON
361                                      -DCMAKE_CXX_COMPILER_WORKS=ON
362                                      -DCMAKE_ASM_COMPILER_WORKS=ON
363                                      -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
364                                      -DLLVM_RUNTIMES_TARGET=${name}
365                                      ${COMMON_CMAKE_ARGS}
366                                      ${${name}_extra_args}
367                           EXTRA_TARGETS ${${name}_extra_targets}
368                                         ${${name}_test_targets}
369                           USE_TOOLCHAIN
370                           TARGET_TRIPLE ${target}
371                           ${EXTRA_ARGS})
372endfunction()
373
374if(runtimes)
375  # Create a runtimes target that uses this file as its top-level CMake file.
376  # The runtimes target is a configuration of all the runtime libraries
377  # together in a single CMake invocation.
378  set(extra_deps "")
379  if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
380    if(TARGET opt)
381      list(APPEND extra_deps opt)
382    endif()
383    if(TARGET llvm-link)
384      list(APPEND extra_deps llvm-link)
385    endif()
386  endif()
387  if(NOT LLVM_RUNTIME_TARGETS)
388    runtime_default_target(
389      DEPENDS ${builtins_dep} ${extra_deps}
390      PREFIXES ${prefixes})
391    set(test_targets check-runtimes)
392  else()
393    if("default" IN_LIST LLVM_RUNTIME_TARGETS)
394      runtime_default_target(
395        DEPENDS ${builtins_dep} ${extra_deps}
396        PREFIXES ${prefixes})
397      list(REMOVE_ITEM LLVM_RUNTIME_TARGETS "default")
398    else()
399      add_custom_target(runtimes)
400      add_custom_target(runtimes-configure)
401      add_custom_target(install-runtimes)
402      add_custom_target(install-runtimes-stripped)
403      if(LLVM_INCLUDE_TESTS)
404        add_custom_target(check-runtimes)
405        add_custom_target(runtimes-test-depends)
406        set(test_targets "")
407      endif()
408      foreach(runtime_name ${runtime_names})
409        add_custom_target(${runtime_name})
410        add_custom_target(install-${runtime_name})
411        add_custom_target(install-${runtime_name}-stripped)
412      endforeach()
413      if(LLVM_RUNTIME_DISTRIBUTION_COMPONENTS)
414        foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
415          add_custom_target(${component})
416          add_custom_target(install-${component})
417          add_custom_target(install-${component}-stripped)
418        endforeach()
419      endif()
420    endif()
421
422    foreach(name ${LLVM_RUNTIME_TARGETS})
423      if(builtins_dep)
424        if (LLVM_BUILTIN_TARGETS)
425          set(builtins_dep_name "${builtins_dep}-${name}")
426        else()
427          set(builtins_dep_name ${builtins_dep})
428        endif()
429      endif()
430      runtime_register_target(${name} ${name}
431        DEPENDS ${builtins_dep_name})
432
433      add_dependencies(runtimes runtimes-${name})
434      add_dependencies(runtimes-configure runtimes-${name}-configure)
435      add_dependencies(install-runtimes install-runtimes-${name})
436      add_dependencies(install-runtimes-stripped install-runtimes-${name}-stripped)
437      if(LLVM_INCLUDE_TESTS)
438        add_dependencies(check-runtimes check-runtimes-${name})
439        add_dependencies(runtimes-test-depends runtimes-test-depends-${name})
440      endif()
441      foreach(runtime_name ${runtime_names})
442        add_dependencies(${runtime_name} ${runtime_name}-${name})
443        add_dependencies(install-${runtime_name} install-${runtime_name}-${name})
444        add_dependencies(install-${runtime_name}-stripped install-${runtime_name}-${name}-stripped)
445      endforeach()
446      foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
447        add_dependencies(${component} ${component}-${name})
448        add_dependencies(install-${component} install-${component}-${name})
449        add_dependencies(install-${component}-stripped install-${component}-${name}-stripped)
450      endforeach()
451    endforeach()
452
453    foreach(multilib ${LLVM_RUNTIME_MULTILIBS})
454      foreach(name ${LLVM_RUNTIME_MULTILIB_${multilib}_TARGETS})
455        runtime_register_target(${name}+${multilib} ${name}
456          DEPENDS runtimes-${name}
457          CMAKE_ARGS -DLLVM_RUNTIMES_PREFIX=${name}/
458                     -DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib})
459        add_dependencies(runtimes runtimes-${name}+${multilib})
460        add_dependencies(runtimes-configure runtimes-${name}+${multilib}-configure)
461        add_dependencies(install-runtimes install-runtimes-${name}+${multilib})
462        add_dependencies(install-runtimes-stripped install-runtimes-${name}+${multilib}-stripped)
463        foreach(runtime_name ${runtime_names})
464          add_dependencies(${runtime_name} ${runtime_name}-${name}+${multilib})
465          add_dependencies(install-${runtime_name} install-${runtime_name}-${name}+${multilib})
466          add_dependencies(install-${runtime_name}-stripped install-${runtime_name}-${name}+${multilib}-stripped)
467        endforeach()
468        foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
469          add_dependencies(${component} ${component}-${name}+${multilib})
470          add_dependencies(install-${component} install-${component}-${name}+${multilib})
471          add_dependencies(install-${component}-stripped install-${component}-${name}+${multilib}-stripped)
472        endforeach()
473      endforeach()
474    endforeach()
475  endif()
476
477  if(NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
478    # TODO: This is a hack needed because the libcxx headers are copied into the
479    # build directory during configuration. Without that step the clang in the
480    # build directory cannot find the C++ headers in certain configurations.
481    # I need to build a mechanism for runtime projects to provide CMake code
482    # that executes at LLVM configuration time to handle this case.
483    add_dependencies(clang-bootstrap-deps runtimes-configure)
484    # We need to add the runtimes as a dependency because compiler-rt can be
485    # built as part of runtimes and we need the profile runtime for PGO
486    add_dependencies(clang-bootstrap-deps runtimes)
487  endif()
488
489  if(LLVM_INCLUDE_TESTS)
490    set_property(GLOBAL APPEND PROPERTY LLVM_ALL_ADDITIONAL_TEST_DEPENDS runtimes-test-depends)
491
492    set(RUNTIMES_TEST_DEPENDS
493        FileCheck
494        count
495        llvm-cov
496        llvm-nm
497        llvm-objdump
498        llvm-profdata
499        llvm-xray
500        not
501        obj2yaml
502        sancov
503        sanstats
504        llvm_gtest_main
505        llvm_gtest
506      )
507    foreach(target ${test_targets} ${SUB_CHECK_TARGETS})
508      add_dependencies(${target} ${RUNTIMES_TEST_DEPENDS})
509    endforeach()
510
511    set_property(GLOBAL APPEND PROPERTY LLVM_ALL_ADDITIONAL_TEST_TARGETS runtimes ${RUNTIMES_TEST_DEPENDS})
512  endif()
513endif()
514