Skip to content

Commit 1dc97c2

Browse files
committed
[CMake] Use CXX linker for Core and Concurrency
swiftCore and swift_Concurrency libraries use C++ and Swift. The C++ does not use the Swift C++ interop. Swift driver only uses clang++ to link when building in C++ interop mode and there currently isn't a flag to change that. Since we're explicitly linking the runtime registration when necessary and do not need compatibility libraries, it is safe to use clang++ as the linker directly, instead of going through swiftc. In versions of CMake older than 3.29, Swift is always used as a linker and has no compile stage. By using clang++ as the linker, we require the split build model (CMP0157), so we cannot allow versions of CMake older than 3.29.
1 parent 1950aa4 commit 1dc97c2

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Runtimes/Core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# -- Will need shadow invocations to generate swiftmodules for Swift parts
3030
# Install *.abi.json, swiftdoc, and swiftsourceinfo
3131

32-
cmake_minimum_required(VERSION 3.26...3.29)
32+
cmake_minimum_required(VERSION 3.29)
3333

3434
set(CMAKE_C_VISIBILITY_PRESET "hidden")
3535
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")

Runtimes/Core/Concurrency/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ target_link_libraries(swift_Concurrency PRIVATE
117117
# Link to the runtime that we are just building.
118118
swiftCore)
119119
set_target_properties(swift_Concurrency PROPERTIES
120-
Swift_MODULE_NAME _Concurrency)
120+
Swift_MODULE_NAME _Concurrency
121+
LINKER_LANGUAGE CXX)
121122

122123
install(TARGETS swift_Concurrency
123124
EXPORT SwiftCoreTargets

Runtimes/Core/core/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ if(SwiftCore_ENABLE_VECTOR_TYPES)
269269
"${CMAKE_CURRENT_BINARY_DIR}/SIMDVectorTypes.swift")
270270
endif()
271271

272-
set_target_properties(swiftCore PROPERTIES Swift_MODULE_NAME Swift)
272+
set_target_properties(swiftCore PROPERTIES
273+
Swift_MODULE_NAME Swift
274+
LINKER_LANGUAGE CXX)
273275

274276
target_compile_definitions(swiftCore
275277
PRIVATE

0 commit comments

Comments
 (0)