[compiler-rt] 7545283 - [compiler-rt] Don't detect a versioned clang test compiler as GCC

via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 2 11:49:55 PST 2024


Author: Alexander Richardson
Date: 2024-12-02T11:49:52-08:00
New Revision: 75452831948d86674374f645df75c543f4587635

URL: https://github.com/llvm/llvm-project/commit/75452831948d86674374f645df75c543f4587635
DIFF: https://github.com/llvm/llvm-project/commit/75452831948d86674374f645df75c543f4587635.diff

LOG: [compiler-rt] Don't detect a versioned clang test compiler as GCC

I was trying to build compiler-rt with /usr/bin/clang-17 and the testsuite
failed due to the code in lit.common.cfg.py:
```
# GCC-ASan uses dynamic runtime by default (since config.bits is not set).
if config.compiler_id == "GNU":
    gcc_dir = os.path.dirname(config.clang)
    libasan_dir = os.path.join(gcc_dir, "..", "lib" + config.bits)
    push_dynamic_library_lookup_path(config, libasan_dir)
```

Fix this in two ways: First, if the test compiler matches the library
compiler, set COMPILER_RT_TEST_COMPILER_ID to CMAKE_C_COMPILER_ID. Second,
relax the regex detecting clang to allow any kind of suffix.

Reviewed By: compnerd

Pull Request: https://github.com/llvm/llvm-project/pull/117812

Added: 
    

Modified: 
    compiler-rt/cmake/base-config-ix.cmake

Removed: 
    


################################################################################
diff  --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake
index 286a622a4b5202..9717c21d8977bd 100644
--- a/compiler-rt/cmake/base-config-ix.cmake
+++ b/compiler-rt/cmake/base-config-ix.cmake
@@ -77,13 +77,15 @@ else()
   set(COMPILER_RT_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE PATH "C++ Compiler to use for testing")
 endif()
 
-if("${COMPILER_RT_TEST_COMPILER}" MATCHES "clang[+]*$")
+get_filename_component(_test_compiler_name "${COMPILER_RT_TEST_COMPILER}" NAME)
+if("${COMPILER_RT_TEST_COMPILER}" STREQUAL "${CMAKE_C_COMPILER}")
+  set(COMPILER_RT_TEST_COMPILER_ID "${CMAKE_C_COMPILER_ID}")
+elseif("${_test_compiler_name}" MATCHES "clang.*")
   set(COMPILER_RT_TEST_COMPILER_ID Clang)
-elseif("${COMPILER_RT_TEST_COMPILER}" MATCHES "clang.*.exe$")
-  set(COMPILER_RT_TEST_COMPILER_ID Clang)
-elseif("${COMPILER_RT_TEST_COMPILER}" MATCHES "cl.exe$")
+elseif("${_test_compiler_name}" MATCHES "cl.exe$")
   set(COMPILER_RT_TEST_COMPILER_ID MSVC)
 else()
+  message(STATUS "Unknown compiler ${COMPILER_RT_TEST_COMPILER}, assuming GNU")
   set(COMPILER_RT_TEST_COMPILER_ID GNU)
 endif()
 


        


More information about the llvm-commits mailing list