Skip to content

Commit fc60c6c

Browse files
committed
CMake: on Darwin be explicit about inclusion in the dyld shared cache
This entails passing a linker flags when the standard library is not meant for inclusion in such cache -- such flag is supported by both LLD and the Apple linkers. For this to have effect on every library, propagate link flags when building _Concurrency and Observation. This is needed for Apple internal configurations. Addresses rdar://120653968
1 parent e773d9a commit fc60c6c

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

stdlib/public/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ if(SWIFT_STDLIB_SIL_DEBUGGING)
1919
list(APPEND SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS "-Xfrontend" "-sil-based-debuginfo")
2020
endif()
2121

22+
option(SWIFT_RUNTIME_PART_OF_DARWIN_SHARED_CACHE
23+
"On Darwin platforms, link the standard library in a way that
24+
allows inclusion in the dyld shared cache"
25+
FALSE)
26+
27+
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND
28+
LLVM_LINKER_DETECTED AND
29+
NOT SWIFT_RUNTIME_PART_OF_DARWIN_SHARED_CACHE)
30+
set(shared_cache_link_flags "LINKER:-not_for_dyld_shared_cache")
31+
list(APPEND SWIFT_RUNTIME_LINK_FLAGS ${shared_cache_link_flags})
32+
list(APPEND SWIFT_RUNTIME_SWIFT_LINK_FLAGS ${shared_cache_link_flags})
33+
endif()
34+
2235
# Build the runtime with -Wall to catch, e.g., uninitialized variables
2336
# warnings.
2437
if(SWIFT_COMPILER_IS_MSVC_LIKE)

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
172172
-diagnostic-style swift
173173
${SWIFT_RUNTIME_CONCURRENCY_SWIFT_FLAGS}
174174
${swift_concurrency_options}
175+
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
175176
INSTALL_IN_COMPONENT stdlib
176177
MACCATALYST_BUILD_FLAVOR zippered
177178
)

stdlib/public/Observation/Sources/Observation/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ add_swift_target_library(swiftObservation ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS
2929

3030
C_COMPILE_FLAGS
3131
${swift_runtime_library_compile_flags}
32+
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
3233

3334
SWIFT_MODULE_DEPENDS _Concurrency
3435
INSTALL_IN_COMPONENT stdlib

0 commit comments

Comments
 (0)