@@ -262,7 +262,10 @@ function(runtime_default_target)
262262
263263 if (LLVM_INCLUDE_TESTS)
264264 set_property (GLOBAL APPEND PROPERTY LLVM_ALL_LIT_TESTSUITES "@${LLVM_BINARY_DIR} /runtimes/runtimes-bins/lit.tests" )
265- list (APPEND test_targets runtimes-test -depends check-runtimes)
265+ list (APPEND test_targets runtimes-test -depends check-runtimes check-builtins)
266+
267+ # The default runtimes target can run tests the default builtins target
268+ list (APPEND ARG_CMAKE_ARGS "-DCOMPILER_RT_TEST_BUILTINS_DIR=${LLVM_BINARY_DIR} /runtimes/builtins-bins/" )
266269 endif ()
267270
268271 set_enable_per_target_runtime_dir()
@@ -369,6 +372,15 @@ function(runtime_register_target name)
369372 list (APPEND ${name} _test_targets ${target} -${name} )
370373 list (APPEND test_targets ${target} -${name} )
371374 endforeach ()
375+
376+ # If a builtins-${name} target exists, we'll test those builtins
377+ # with this runtimes build
378+ if (TARGET builtins-${name} )
379+ list (APPEND ARG_CMAKE_ARGS "-DCOMPILER_RT_TEST_BUILTINS_DIR=${LLVM_BINARY_DIR} /runtimes/builtins-${name} -bins/" )
380+ set (check-builtins-${name} check-builtins)
381+ list (APPEND ${name} _test_targets check-builtins-${name} )
382+ list (APPEND test_targets check-builtins-${name} )
383+ endif ()
372384 set (test_targets "${test_targets} " PARENT_SCOPE)
373385 endif ()
374386
@@ -434,6 +446,9 @@ function(runtime_register_target name)
434446 if (LLVM_INCLUDE_TESTS)
435447 add_dependencies (check-runtimes check-runtimes-${name} )
436448 add_dependencies (runtimes-test -depends runtimes-test -depends -${name} )
449+ if (TARGET builtins-${name} )
450+ add_dependencies (check-builtins check-builtins-${name} )
451+ endif ()
437452 endif ()
438453 foreach (runtime_name ${runtime_names} )
439454 if (NOT TARGET ${runtime_name} )
@@ -609,6 +624,17 @@ if(build_runtimes)
609624 PROPERTIES FOLDER "Runtimes"
610625 )
611626 set (test_targets "" )
627+
628+ # NOTE: Currently, the builtins tests are run with the runtimes build,
629+ # and the default runtimes target installs a check-builtins target
630+ # which forwards to the default builtins build. If the default runtimes
631+ # target is not used, we create a custom target which will depend on
632+ # each check-builtins-${name}.
633+ add_custom_target (check-builtins)
634+ set_target_properties (
635+ check-builtins
636+ PROPERTIES FOLDER "Compiler-RT"
637+ )
612638 endif ()
613639 if (LLVM_RUNTIME_DISTRIBUTION_COMPONENTS)
614640 foreach (component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS} )
0 commit comments