Skip to content

Commit

Permalink
[runtimes] Use a response file for runtimes test suites
Browse files Browse the repository at this point in the history
We don't know which test suites are going to be included by runtimes
builds so we cannot include those before running the sub-build, but
that's not possible during the LLVM build configuration. We instead use
a response file that's populated by the runtimes build as a level of
indirection.

This addresses the issue described in:
https://discourse.llvm.org/t/cmake-regeneration-is-broken/62788

Differential Revision: https://reviews.llvm.org/D132438

(cherry picked from commit 992e10a)
  • Loading branch information
petrhosek authored and tru committed Aug 25, 2022
1 parent 427e1ea commit 3a481d4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
18 changes: 4 additions & 14 deletions llvm/runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,7 @@ function(runtime_default_target)
endforeach()

if(LLVM_INCLUDE_TESTS)
include(${LLVM_BINARY_DIR}/runtimes/Tests.cmake OPTIONAL RESULT_VARIABLE have_tests)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/Tests.cmake)
if(have_tests)
set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_TESTSUITES ${SUB_LIT_TESTSUITES})
set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_PARAMS ${SUB_LIT_PARAMS})
set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_EXTRA_ARGS ${SUB_LIT_EXTRA_ARGS})
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_TESTSUITES "@${LLVM_BINARY_DIR}/runtimes/Tests.rsp")
list(APPEND test_targets runtimes-test-depends check-runtimes)
endif()

Expand Down Expand Up @@ -301,13 +295,7 @@ function(runtime_register_target name target)
endforeach()

if(LLVM_INCLUDE_TESTS)
include(${LLVM_BINARY_DIR}/runtimes/${name}/Tests.cmake OPTIONAL RESULT_VARIABLE have_tests)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LLVM_BINARY_DIR}/runtimes/${name}/Tests.cmake)
if(have_tests)
set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_TESTSUITES ${SUB_LIT_TESTSUITES})
set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_PARAMS ${SUB_LIT_PARAMS})
set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_EXTRA_ARGS ${SUB_LIT_EXTRA_ARGS})
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_TESTSUITES "@${LLVM_BINARY_DIR}/runtimes/${name}/Tests.rsp")
set(runtimes-test-depends-${name} runtimes-test-depends)
set(check-runtimes-${name} check-runtimes)
list(APPEND ${name}_test_targets runtimes-test-depends-${name} check-runtimes-${name})
Expand Down Expand Up @@ -497,5 +485,7 @@ if(runtimes)
foreach(target ${test_targets} ${SUB_CHECK_TARGETS})
add_dependencies(${target} ${RUNTIMES_TEST_DEPENDS})
endforeach()

set_property(GLOBAL APPEND PROPERTY LLVM_ALL_ADDITIONAL_TEST_TARGETS runtimes ${RUNTIMES_TEST_DEPENDS})
endif()
endif()
10 changes: 4 additions & 6 deletions runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,12 @@ if(LLVM_INCLUDE_TESTS)
${CMAKE_CURRENT_BINARY_DIR}/llvm-lit)
endif()

get_property(LLVM_RUNTIMES_LIT_TESTSUITES GLOBAL PROPERTY LLVM_RUNTIMES_LIT_TESTSUITES)
string(REPLACE ";" "\n" LLVM_RUNTIMES_LIT_TESTSUITES "${LLVM_RUNTIMES_LIT_TESTSUITES}")
if(LLVM_RUNTIMES_TARGET)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Tests.cmake.in
${LLVM_BINARY_DIR}/runtimes/${LLVM_RUNTIMES_TARGET}/Tests.cmake)
file(WRITE ${LLVM_BINARY_DIR}/runtimes/${LLVM_RUNTIMES_TARGET}/Tests.rsp ${LLVM_RUNTIMES_LIT_TESTSUITES})
else()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Tests.cmake.in
${LLVM_BINARY_DIR}/runtimes/Tests.cmake)
file(WRITE ${LLVM_BINARY_DIR}/runtimes/Tests.rsp ${LLVM_RUNTIMES_LIT_TESTSUITES})
endif()
endif()

Expand Down
3 changes: 0 additions & 3 deletions runtimes/Tests.cmake.in

This file was deleted.

0 comments on commit 3a481d4

Please sign in to comment.