@@ -209,12 +209,13 @@ foreach(entry ${runtimes})
209
209
endforeach ()
210
210
211
211
function (runtime_default_target )
212
- cmake_parse_arguments (ARG "" "" "DEPENDS;CMAKE_ARGS;PREFIXES" ${ARGN} )
212
+ cmake_parse_arguments (ARG "" "" "DEPENDS;CMAKE_ARGS;PREFIXES;RUNTIMES " ${ARGN} )
213
213
214
214
include (${LLVM_BINARY_DIR} /runtimes/Components.cmake OPTIONAL )
215
215
set (SUB_CHECK_TARGETS ${SUB_CHECK_TARGETS} PARENT_SCOPE )
216
216
set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR} /runtimes/Components.cmake )
217
217
218
+ set (LLVM_ENABLE_RUNTIMES ${ARG_RUNTIMES} )
218
219
foreach (runtime_name ${RUNTIME_NAMES} )
219
220
list (APPEND extra_targets
220
221
${runtime_name}
@@ -269,11 +270,12 @@ endfunction()
269
270
# runtime_register_target(name)
270
271
# Utility function to register external runtime target.
271
272
function (runtime_register_target name )
272
- cmake_parse_arguments (ARG "" "BASE_NAME" "DEPENDS;CMAKE_ARGS;EXTRA_ARGS" ${ARGN} )
273
+ cmake_parse_arguments (ARG "" "BASE_NAME" "DEPENDS;CMAKE_ARGS;EXTRA_ARGS;RUNTIMES " ${ARGN} )
273
274
include (${LLVM_BINARY_DIR} /runtimes/${name}/Components.cmake OPTIONAL )
274
275
set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR} /runtimes/${name}/Components.cmake )
275
276
276
277
set (runtime_names ${RUNTIME_NAMES} )
278
+ set (LLVM_ENABLE_RUNTIMES ${ARG_RUNTIMES} )
277
279
foreach (_name IN ITEMS ${ARG_BASE_NAME} ${name} )
278
280
if (RUNTIMES_${_name}_LLVM_ENABLE_RUNTIMES )
279
281
set (runtime_names )
@@ -449,39 +451,65 @@ if(runtimes)
449
451
endforeach ()
450
452
endif ()
451
453
endif ()
452
- if (NOT LLVM_RUNTIME_TARGETS )
453
- runtime_default_target (
454
- DEPENDS ${builtins_dep} ${extra_deps}
455
- CMAKE_ARGS ${libc_cmake_args}
456
- PREFIXES ${prefixes} )
457
- set (test_targets check-runtimes )
454
+
455
+ # Get the list of all target triples requested for this build.
456
+ if (LLVM_RUNTIME_TARGETS )
457
+ set (runtime_targets ${LLVM_RUNTIME_TARGETS} )
458
458
else ()
459
- if ("default" IN_LIST LLVM_RUNTIME_TARGETS )
459
+ set (runtime_targets "default" )
460
+ endif ()
461
+ set (extra_targets "" )
462
+ foreach (proj ${LLVM_ENABLE_RUNTIMES} )
463
+ string (TOUPPER "${proj} " canon_name )
464
+ string (REGEX REPLACE "-" "_" canon_name ${canon_name} )
465
+ if (LLVM_${canon_name}_RUNTIME_TARGETS )
466
+ list (APPEND extra_targets ${LLVM_${canon_name}_RUNTIME_TARGETS} )
467
+ endif ()
468
+ endforeach ()
469
+ list (REMOVE_DUPLICATES runtime_targets )
470
+
471
+ # If we have any non-default triples we need to create custom targets.
472
+ if (NOT "default" IN_LIST runtime_targets AND NOT "default" IN_LIST extra_targets )
473
+ add_custom_target (runtimes )
474
+ add_custom_target (runtimes-configure )
475
+ add_custom_target (install -runtimes )
476
+ add_custom_target (install -runtimes-stripped )
477
+ if (LLVM_INCLUDE_TESTS )
478
+ add_custom_target (check-runtimes )
479
+ add_custom_target (runtimes-test-depends )
480
+ set (test_targets "" )
481
+ endif ()
482
+ if (LLVM_RUNTIME_DISTRIBUTION_COMPONENTS )
483
+ foreach (component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS} )
484
+ add_custom_target (${component} )
485
+ add_custom_target (install -${component} )
486
+ add_custom_target (install -${component}-stripped )
487
+ endforeach ()
488
+ endif ()
489
+ endif ()
490
+
491
+ # Register each requested target triple using the projects that requested that
492
+ # target.
493
+ foreach (name ${runtime_targets} ${extra_targets} )
494
+ set (enabled_runtimes "" )
495
+ foreach (proj ${LLVM_ENABLE_RUNTIMES} )
496
+ string (TOUPPER "${proj} " canon_name )
497
+ string (REGEX REPLACE "-" "_" canon_name ${canon_name} )
498
+ if (NOT LLVM_${canon_name}_RUNTIME_TARGETS AND ${name} IN_LIST runtime_targets )
499
+ list (APPEND enabled_runtimes ${proj} )
500
+ elseif (${name} IN_LIST LLVM_${canon_name}_RUNTIME_TARGETS )
501
+ list (APPEND enabled_runtimes ${proj} )
502
+ endif ()
503
+ endforeach ()
504
+
505
+ if ("${name} " STREQUAL "default" )
460
506
runtime_default_target (
461
507
DEPENDS ${builtins_dep} ${extra_deps}
462
508
CMAKE_ARGS ${libc_cmake_args}
463
- PREFIXES ${prefixes} )
464
- list (REMOVE_ITEM LLVM_RUNTIME_TARGETS "default" )
509
+ PREFIXES ${prefixes}
510
+ RUNTIMES ${enabled_runtimes} )
511
+ set (test_targets check-runtimes )
465
512
else ()
466
- add_custom_target (runtimes )
467
- add_custom_target (runtimes-configure )
468
- add_custom_target (install -runtimes )
469
- add_custom_target (install -runtimes-stripped )
470
- if (LLVM_INCLUDE_TESTS )
471
- add_custom_target (check-runtimes )
472
- add_custom_target (runtimes-test-depends )
473
- set (test_targets "" )
474
- endif ()
475
- if (LLVM_RUNTIME_DISTRIBUTION_COMPONENTS )
476
- foreach (component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS} )
477
- add_custom_target (${component} )
478
- add_custom_target (install -${component} )
479
- add_custom_target (install -${component}-stripped )
480
- endforeach ()
481
- endif ()
482
- endif ()
483
-
484
- foreach (name ${LLVM_RUNTIME_TARGETS} )
485
513
if (builtins_dep )
486
514
if (LLVM_BUILTIN_TARGETS )
487
515
set (builtins_dep_name "${builtins_dep} -${name} " )
@@ -495,21 +523,22 @@ if(runtimes)
495
523
runtime_register_target (${name}
496
524
DEPENDS ${builtins_dep_name} ${hdrgen_deps}
497
525
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name} ${libc_cmake_args}
526
+ RUNTIMES ${enabled_runtimes}
498
527
EXTRA_ARGS TARGET_TRIPLE ${name} )
499
- endforeach ()
500
528
501
- foreach (multilib ${LLVM_RUNTIME_MULTILIBS} )
502
- foreach (name ${LLVM_RUNTIME_MULTILIB_${multilib}_TARGETS} )
529
+ foreach (multilib ${LLVM_RUNTIME_MULTILIBS} )
503
530
runtime_register_target (${name} +${multilib}
504
531
DEPENDS runtimes-${name}
505
532
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name}
506
- -DLLVM_RUNTIMES_PREFIX=${name}/
507
- -DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib}
533
+ -DLLVM_ENABLE_RUNTIMES= "${enabled_runtimes} "
534
+ -DLLVM_RUNTIMES_PREFIX=${name}/
535
+ -DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib}
508
536
BASE_NAME ${name}
537
+ RUNTIMES ${enabled_runtimes}
509
538
EXTRA_ARGS TARGET_TRIPLE ${name} )
510
539
endforeach ()
511
- endforeach ()
512
- endif ()
540
+ endif ()
541
+ endforeach ()
513
542
514
543
if (NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP )
515
544
# TODO: This is a hack needed because the libcxx headers are copied into the
0 commit comments