Skip to content

Commit 782147e

Browse files
authored
[CMake][LIT] Add option to run lit testsuites in parallel (#82899)
Currently `add_lit_target` sets the `USES_TERMINAL` CMake option. When using Ninja, this forces all lit testsuite targets into the single-threaded `console` pool. This PR adds a new option `LLVM_PARALLEL_LIT` which drops the `USES_TERMINAL` flag, allowing Ninja to run them in parallel. The default setting (`LLVM_PARALLEL_LIT=OFF`) retains the existing behavior of serial testsuite execution.
1 parent b4bc19e commit 782147e

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

llvm/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,8 @@ if(LLVM_INDIVIDUAL_TEST_COVERAGE)
718718
endif()
719719
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
720720

721+
option(LLVM_PARALLEL_LIT "Enable multiple lit suites to run in parallel" OFF)
722+
721723
# On Win32 hosts, provide an option to specify the path to the GnuWin32 tools.
722724
if( WIN32 AND NOT CYGWIN )
723725
set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools")

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,11 +1947,18 @@ function(add_lit_target target comment)
19471947
list(APPEND LIT_COMMAND --param ${param})
19481948
endforeach()
19491949
if (ARG_UNPARSED_ARGUMENTS)
1950-
add_custom_target(${target}
1951-
COMMAND ${LIT_COMMAND} ${ARG_UNPARSED_ARGUMENTS}
1952-
COMMENT "${comment}"
1953-
USES_TERMINAL
1954-
)
1950+
if (LLVM_PARALLEL_LIT)
1951+
add_custom_target(${target}
1952+
COMMAND ${LIT_COMMAND} ${ARG_UNPARSED_ARGUMENTS}
1953+
COMMENT "${comment}"
1954+
)
1955+
else()
1956+
add_custom_target(${target}
1957+
COMMAND ${LIT_COMMAND} ${ARG_UNPARSED_ARGUMENTS}
1958+
COMMENT "${comment}"
1959+
USES_TERMINAL
1960+
)
1961+
endif()
19551962
else()
19561963
add_custom_target(${target}
19571964
COMMAND ${CMAKE_COMMAND} -E echo "${target} does nothing, no tools built.")

llvm/docs/CMake.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,12 @@ enabled sub-projects. Nearly all of these variable names begin with
762762
**LLVM_PARALLEL_LINK_JOBS**:STRING
763763
Define the maximum number of concurrent link jobs.
764764

765+
**LLVM_PARALLEL_LIT**:BOOL
766+
Defaults to ``OFF``. If set to ``OFF``, lit testsuites will be configured
767+
with CMake's ``USES_TERMINAL`` flag to give direct access to the terminal. If
768+
set to ``ON``, that flag will be removed allowing Ninja to schedule multiple
769+
lit testsuites in parallel.
770+
765771
**LLVM_RAM_PER_COMPILE_JOB**:STRING
766772
Calculates the amount of Ninja compile jobs according to available resources.
767773
Value has to be in MB, overwrites LLVM_PARALLEL_COMPILE_JOBS. Compile jobs

0 commit comments

Comments
 (0)