Skip to content

Commit

Permalink
[compiler-rt] Use locally configured llvm-lit for standalone builds (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
arichardson committed Feb 27, 2024
1 parent 3250330 commit 5e31e82
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions compiler-rt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -771,8 +771,6 @@ mark_as_advanced(COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER)
add_subdirectory(lib)

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

add_subdirectory(tools)

0 comments on commit 5e31e82

Please sign in to comment.