Skip to content

Commit 5e31e82

Browse files
authored
[compiler-rt] Use locally configured llvm-lit for standalone builds (#83178)
When building a standalone build with `-DLLVM_CMAKE_DIR=$HOME/output/llvm-install -DCOMPILER_RT_INCLUDE_TESTS=ON`, the current code will attempt to use `LLVM_DEFAULT_EXTERNAL_LIT` which is set to `$HOME/output/llvm-install/bin/llvm-lit` inside `LLVMConfig.cmake` even though it is not actually installed. If we are adding the llvm-lit subdirectory, we can use `get_llvm_lit_path()` immediately afterwards to set LLVM_EXTERNAL_LIT so that subsequent calls within `add_lit_testsuite()` use llvm-lit from the current build directory instead of the nonexistant one.
1 parent 3250330 commit 5e31e82

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compiler-rt/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,6 @@ mark_as_advanced(COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER)
771771
add_subdirectory(lib)
772772

773773
if(COMPILER_RT_INCLUDE_TESTS)
774-
add_subdirectory(unittests)
775-
add_subdirectory(test)
776774
# Don't build llvm-lit for runtimes-build, it will clean up map_config.
777775
if (COMPILER_RT_STANDALONE_BUILD AND NOT LLVM_RUNTIMES_BUILD)
778776
# If we have a valid source tree, generate llvm-lit into the bin directory.
@@ -782,11 +780,17 @@ if(COMPILER_RT_INCLUDE_TESTS)
782780
# Needed for lit support in standalone builds.
783781
include(AddLLVM)
784782
add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit)
783+
# Ensure that the testsuite uses the local lit rather than
784+
# LLVM_INSTALL_DIR/bin/llvm-lit (which probably does not exist).
785+
get_llvm_lit_path(_base_dir _file_name)
786+
set(LLVM_EXTERNAL_LIT "${_base_dir}/${_file_name}" CACHE STRING "Command used to spawn lit" FORCE)
785787
elseif(NOT EXISTS ${LLVM_EXTERNAL_LIT})
786788
message(WARNING "Could not find LLVM source directory and LLVM_EXTERNAL_LIT does not"
787789
"point to a valid file. You will not be able to run tests.")
788790
endif()
789791
endif()
792+
add_subdirectory(unittests)
793+
add_subdirectory(test)
790794
endif()
791795

792796
add_subdirectory(tools)

0 commit comments

Comments
 (0)