Skip to content

Commit 27fab1d

Browse files
committed
build: use the just-built clang for runtime unittests
The runtime is meant to be built with the just built clang (as this absolutely requires clang) as the runtime is a target library. The host tools can be built with the host compiler. Swap out the compiler for the unittests as we do for the runtime itself.
1 parent dc8239f commit 27fab1d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

unittests/runtime/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
22
("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "${SWIFT_PRIMARY_VARIANT_ARCH}"))
33

4+
if(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER)
5+
if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
6+
message(FATAL_ERROR "Building the swift runtime is not supported with ${CMAKE_C_COMPILER_ID}. Use the just-built clang instead.")
7+
else()
8+
message(WARNING "Building the swift runtime using the host compiler, and not the just-built clang.")
9+
endif()
10+
else()
11+
# If we use Clang-cl or MSVC, CMake provides default compiler and linker flags that are incompatible
12+
# with the frontend of Clang or Clang++.
13+
if(SWIFT_COMPILER_IS_MSVC_LIKE)
14+
set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang-cl")
15+
set(CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang-cl")
16+
else()
17+
set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang++")
18+
set(CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang")
19+
endif()
20+
21+
set(CMAKE_C_COMPILER_LAUNCHER "")
22+
set(CMAKE_CXX_COMPILER_LAUNCHER "")
23+
endif()
24+
425
set(swift_runtime_test_extra_libraries)
526
if(SWIFT_BUILD_STATIC_STDLIB AND "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "LINUX")
627
list(APPEND swift_runtime_test_extra_libraries

0 commit comments

Comments
 (0)