[compiler-rt] 5e31e82 - [compiler-rt] Use locally configured llvm-lit for standalone builds (#83178)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 27 13:00:11 PST 2024


Author: Alexander Richardson
Date: 2024-02-27T21:00:07Z
New Revision: 5e31e82698d9f1d3f1dd881c87b8c5399d790772

URL: https://github.com/llvm/llvm-project/commit/5e31e82698d9f1d3f1dd881c87b8c5399d790772
DIFF: https://github.com/llvm/llvm-project/commit/5e31e82698d9f1d3f1dd881c87b8c5399d790772.diff

LOG: [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.

Added: 
    

Modified: 
    compiler-rt/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index bbb4e8d7c333e4..8a2b138d8d7020 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -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.
@@ -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)


        


More information about the llvm-commits mailing list