Skip to content

Commit 7545283

Browse files
authored
[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: #117812
1 parent 468fb5f commit 7545283

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ else()
7777
set(COMPILER_RT_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE PATH "C++ Compiler to use for testing")
7878
endif()
7979

80-
if("${COMPILER_RT_TEST_COMPILER}" MATCHES "clang[+]*$")
80+
get_filename_component(_test_compiler_name "${COMPILER_RT_TEST_COMPILER}" NAME)
81+
if("${COMPILER_RT_TEST_COMPILER}" STREQUAL "${CMAKE_C_COMPILER}")
82+
set(COMPILER_RT_TEST_COMPILER_ID "${CMAKE_C_COMPILER_ID}")
83+
elseif("${_test_compiler_name}" MATCHES "clang.*")
8184
set(COMPILER_RT_TEST_COMPILER_ID Clang)
82-
elseif("${COMPILER_RT_TEST_COMPILER}" MATCHES "clang.*.exe$")
83-
set(COMPILER_RT_TEST_COMPILER_ID Clang)
84-
elseif("${COMPILER_RT_TEST_COMPILER}" MATCHES "cl.exe$")
85+
elseif("${_test_compiler_name}" MATCHES "cl.exe$")
8586
set(COMPILER_RT_TEST_COMPILER_ID MSVC)
8687
else()
88+
message(STATUS "Unknown compiler ${COMPILER_RT_TEST_COMPILER}, assuming GNU")
8789
set(COMPILER_RT_TEST_COMPILER_ID GNU)
8890
endif()
8991

0 commit comments

Comments
 (0)