@@ -255,7 +255,10 @@ function(runtime_default_target)
255255
256256 if (LLVM_INCLUDE_TESTS)
257257 set_property (GLOBAL APPEND PROPERTY LLVM_ALL_LIT_TESTSUITES "@${LLVM_BINARY_DIR} /runtimes/runtimes-bins/lit.tests" )
258- list (APPEND test_targets runtimes-test -depends check-runtimes)
258+ list (APPEND test_targets runtimes-test -depends check-runtimes check-builtins)
259+
260+ # The default runtimes target can run tests the default builtins target
261+ list (APPEND ARG_CMAKE_ARGS "-DCOMPILER_RT_FORCE_TEST_BUILTINS_DIR=${LLVM_BINARY_DIR} /runtimes/builtins-bins/" )
259262 endif ()
260263
261264 set_enable_per_target_runtime_dir()
@@ -362,6 +365,15 @@ function(runtime_register_target name)
362365 list (APPEND ${name} _test_targets ${target} -${name} )
363366 list (APPEND test_targets ${target} -${name} )
364367 endforeach ()
368+
369+ # If a builtins-${name} target exists, we'll test those builtins
370+ # with this runtimes build
371+ if (TARGET builtins-${name} )
372+ list (APPEND ARG_CMAKE_ARGS "-DCOMPILER_RT_FORCE_TEST_BUILTINS_DIR=${LLVM_BINARY_DIR} /runtimes/builtins-${name} -bins/" )
373+ set (check-builtins-${name} check-builtins)
374+ list (APPEND ${name} _test_targets check-builtins-${name} )
375+ list (APPEND test_targets check-builtins-${name} )
376+ endif ()
365377 set (test_targets "${test_targets} " PARENT_SCOPE)
366378 endif ()
367379
@@ -427,6 +439,9 @@ function(runtime_register_target name)
427439 if (LLVM_INCLUDE_TESTS)
428440 add_dependencies (check-runtimes check-runtimes-${name} )
429441 add_dependencies (runtimes-test -depends runtimes-test -depends -${name} )
442+ if (TARGET builtins-${name} )
443+ add_dependencies (check-builtins check-builtins-${name} )
444+ endif ()
430445 endif ()
431446 foreach (runtime_name ${runtime_names} )
432447 if (NOT TARGET ${runtime_name} )
@@ -602,6 +617,17 @@ if(build_runtimes)
602617 PROPERTIES FOLDER "Runtimes"
603618 )
604619 set (test_targets "" )
620+
621+ # NOTE: Currently, the builtins tests are run with the runtimes build,
622+ # and the default runtimes target installs a check-builtins target
623+ # which forwards to the default builtins build. If the default runtimes
624+ # target is not used, we create a custom target which will depend on
625+ # each check-builtins-${name}.
626+ add_custom_target (check-builtins)
627+ set_target_properties (
628+ check-builtins
629+ PROPERTIES FOLDER "Compiler-RT"
630+ )
605631 endif ()
606632 if (LLVM_RUNTIME_DISTRIBUTION_COMPONENTS)
607633 foreach (component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS} )
0 commit comments