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