Skip to content

Commit 0f3fe94

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 552106d commit 0f3fe94

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,9 @@ target_link_libraries(swift_Concurrency PRIVATE
117117
# Link to the runtime that we are just building.
118118
swiftCore
119119
$<$<NOT:$<PLATFORM_ID:Darwin>>:swiftrt>)
120-
target_link_options(swift_Concurrency PRIVATE
121-
-nostartfiles)
122120
set_target_properties(swift_Concurrency PROPERTIES
123-
Swift_MODULE_NAME _Concurrency)
121+
Swift_MODULE_NAME _Concurrency
122+
LINKER_LANGUAGE CXX)
124123

125124
install(TARGETS swift_Concurrency
126125
EXPORT SwiftCoreTargets

Runtimes/Core/core/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ if(NOT LINUX AND NOT ANDROID)
250250
target_sources(swiftCore PRIVATE ObjectIdentifier+DebugDescription.swift)
251251
endif()
252252

253-
set_target_properties(swiftCore PROPERTIES Swift_MODULE_NAME Swift)
253+
set_target_properties(swiftCore PROPERTIES
254+
Swift_MODULE_NAME Swift
255+
LINKER_LANGUAGE CXX)
254256

255257
if(SwiftCore_ENABLE_COMMANDLINE_SUPPORT)
256258
target_sources(swiftCore PRIVATE CommandLine.swift)
@@ -313,8 +315,6 @@ target_link_libraries(swiftCore
313315
$<$<NOT:$<PLATFORM_ID:Darwin>>:swiftrt$<$<PLATFORM_ID:Windows>:T>>
314316
PUBLIC
315317
swiftShims)
316-
target_link_options(swiftCore PRIVATE
317-
-nostartfiles)
318318
if(NOT POLICY CMP0157)
319319
target_compile_options(swiftCore PRIVATE
320320
$<TARGET_OBJECTS:swiftRuntime>

0 commit comments

Comments
 (0)