Skip to content

Commit 6aac73a

Browse files
committed
Runtimes: propagate SwiftRT objects via swiftCore
Runtime clients of swiftCore need the SwiftRT image-registration object on their link lines. On COFF this object supplies pSwiftImageConstructor and the .sw5* section range symbols used to register Swift metadata and conformances for each image. CMake propagates usage requirements when an OBJECT library appears in an INTERFACE_LINK_LIBRARIES chain, but it does not add that object's payload to the final consumer link line. Keep the swiftrt targets in the interface for their usage requirements, and explicitly propagate their object files with TARGET_OBJECTS.
1 parent 7413e0b commit 6aac73a

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

Runtimes/Core/Core/CMakeLists.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,25 @@ target_link_libraries(swiftCore
353353
swiftRuntimeCoreCMakeConfig)
354354

355355
string(TOLOWER "${SwiftCore_OBJECT_FORMAT}" SwiftCore_OBJECT_FORMAT_lc)
356+
# Runtime clients need the Swift image-registration object on their link lines
357+
# (on COFF this supplies pSwiftImageConstructor and the .sw5* section ranges).
358+
# CMake propagates usage requirements for an OBJECT library that appears in an
359+
# INTERFACE_LINK_LIBRARIES chain, but it does not also add the object's payload to
360+
# the final link line. Keep the swiftrt target for its usage requirements, and
361+
# explicitly propagate the object payload through swiftCore's interface.
356362
if("${SwiftCore_OBJECT_FORMAT_lc}" STREQUAL "elf")
357363
target_link_libraries(swiftCore INTERFACE
358-
swiftrt)
364+
swiftrt
365+
$<TARGET_OBJECTS:swiftrt>)
359366
elseif("${SwiftCore_OBJECT_FORMAT_lc}" STREQUAL "coff")
360367
if(BUILD_SHARED_LIBS)
361368
target_link_libraries(swiftCore INTERFACE
362-
swiftrt)
369+
swiftrt
370+
$<TARGET_OBJECTS:swiftrt>)
363371
else()
364372
target_link_libraries(swiftCore INTERFACE
365-
swiftrtT)
373+
swiftrtT
374+
$<TARGET_OBJECTS:swiftrtT>)
366375
endif()
367376
endif()
368377

0 commit comments

Comments
 (0)