@@ -209,7 +209,7 @@ 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)
@@ -236,6 +236,7 @@ function(runtime_default_target)
236
236
endif ()
237
237
238
238
set_enable_per_target_runtime_dir()
239
+ set (LLVM_ENABLE_RUNTIMES ${ARG_RUNTIMES} )
239
240
240
241
llvm_ExternalProject_Add(runtimes
241
242
${CMAKE_CURRENT_SOURCE_DIR} /../../runtimes
@@ -269,7 +270,7 @@ 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
@@ -338,6 +339,7 @@ function(runtime_register_target name)
338
339
endif ()
339
340
340
341
set (${name} _extra_args ${ARG_CMAKE_ARGS} )
342
+ set (LLVM_ENABLE_RUNTIMES ${ARG_RUNTIMES} )
341
343
string (REPLACE ";" "|" LLVM_ENABLE_RUNTIMES_PASSTHROUGH "${LLVM_ENABLE_RUNTIMES} " )
342
344
list (APPEND ${name} _extra_args -DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES_PASSTHROUGH} )
343
345
list (APPEND ${name} _extra_args -DLLVM_USE_LINKER=${LLVM_USE_LINKER} )
@@ -449,39 +451,62 @@ 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)
458
- else ()
459
- if ("default" IN_LIST LLVM_RUNTIME_TARGETS)
454
+
455
+ # Get the list of all target triples requested for this build.
456
+ set (runtime_targets "default" )
457
+ if (LLVM_RUNTIME_TARGETS)
458
+ set (runtime_targets ${LLVM_RUNTIME_TARGETS} )
459
+ endif ()
460
+ foreach (proj ${LLVM_ENABLE_RUNTIMES} )
461
+ string (TOUPPER "${proj} " canon_name)
462
+ string (REGEX REPLACE "-" "_" canon_name ${canon_name} )
463
+ if (LLVM_${canon_name} _RUNTIME_TARGETS)
464
+ list (APPEND extra_targets ${LLVM_${canon_name} _RUNTIME_TARGETS})
465
+ endif ()
466
+ endforeach ()
467
+ list (REMOVE_DUPLICATES extra_targets)
468
+
469
+ # If we have any non-default triples we need to create custom targets.
470
+ if (NOT "default" IN_LIST runtime_targets AND NOT "default" IN_LIST extra_targets)
471
+ add_custom_target (runtimes)
472
+ add_custom_target (runtimes-configure)
473
+ add_custom_target (install -runtimes)
474
+ add_custom_target (install -runtimes-stripped)
475
+ if (LLVM_INCLUDE_TESTS)
476
+ add_custom_target (check-runtimes)
477
+ add_custom_target (runtimes-test -depends )
478
+ set (test_targets "" )
479
+ endif ()
480
+ if (LLVM_RUNTIME_DISTRIBUTION_COMPONENTS)
481
+ foreach (component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS} )
482
+ add_custom_target (${component} )
483
+ add_custom_target (install -${component} )
484
+ add_custom_target (install -${component} -stripped)
485
+ endforeach ()
486
+ endif ()
487
+ endif ()
488
+
489
+ # Register each requested target triple using the projects that requested that
490
+ # target.
491
+ foreach (name ${runtime_targets} ${extra_targets} )
492
+ set (enabled_runtimes "" )
493
+ foreach (proj ${LLVM_ENABLE_RUNTIMES} )
494
+ string (TOUPPER "${proj} " canon_name)
495
+ string (REGEX REPLACE "-" "_" canon_name ${canon_name} )
496
+ if ((NOT LLVM_${canon_name} _RUNTIME_TARGETS AND ${name} IN_LIST runtime_targets)
497
+ OR ${name} IN_LIST LLVM_${canon_name} _RUNTIME_TARGETS)
498
+ list (APPEND enabled_runtimes ${proj} )
499
+ endif ()
500
+ endforeach ()
501
+
502
+ if ("${name} " STREQUAL "default" )
460
503
runtime_default_target(
461
504
DEPENDS ${builtins_dep} ${extra_deps}
462
505
CMAKE_ARGS ${libc_cmake_args}
463
- PREFIXES ${prefixes} )
464
- list (REMOVE_ITEM LLVM_RUNTIME_TARGETS "default" )
506
+ PREFIXES ${prefixes}
507
+ RUNTIMES ${enabled_runtimes} )
508
+ set (test_targets check-runtimes)
465
509
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
510
if (builtins_dep)
486
511
if (LLVM_BUILTIN_TARGETS)
487
512
set (builtins_dep_name "${builtins_dep} -${name} " )
@@ -495,21 +520,22 @@ if(runtimes)
495
520
runtime_register_target(${name}
496
521
DEPENDS ${builtins_dep_name} ${hdrgen_deps}
497
522
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name} ${libc_cmake_args}
523
+ RUNTIMES ${enabled_runtimes}
498
524
EXTRA_ARGS TARGET_TRIPLE ${name} )
499
- endforeach ()
500
525
501
- foreach (multilib ${LLVM_RUNTIME_MULTILIBS} )
502
- foreach (name ${LLVM_RUNTIME_MULTILIB_${multilib} _TARGETS})
526
+ foreach (multilib ${LLVM_RUNTIME_MULTILIBS} )
503
527
runtime_register_target(${name} +${multilib}
504
528
DEPENDS runtimes-${name}
505
529
CMAKE_ARGS -DLLVM_DEFAULT_TARGET_TRIPLE=${name}
506
- -DLLVM_RUNTIMES_PREFIX=${name} /
507
- -DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib}
530
+ -DLLVM_ENABLE_RUNTIMES="${enabled_runtimes} "
531
+ -DLLVM_RUNTIMES_PREFIX=${name} /
532
+ -DLLVM_RUNTIMES_LIBDIR_SUBDIR=${multilib}
508
533
BASE_NAME ${name}
534
+ RUNTIMES ${enabled_runtimes}
509
535
EXTRA_ARGS TARGET_TRIPLE ${name} )
510
536
endforeach ()
511
- endforeach ()
512
- endif ()
537
+ endif ()
538
+ endforeach ()
513
539
514
540
if (NOT LLVM_BUILD_INSTRUMENTED AND CLANG_ENABLE_BOOTSTRAP)
515
541
# TODO: This is a hack needed because the libcxx headers are copied into the
0 commit comments