Skip to content

Commit 68dfde2

Browse files
committed
[Build] Fix some issues with the standalone library build.
When we're building static libraries, we don't need to include the threading objects in both Concurrency and Core, and we also don't need two copies of the threading library's fatal error handler. rdar://90776105
1 parent 43cc1f9 commit 68dfde2

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ endif()
2525
set(SWIFT_RUNTIME_CONCURRENCY_C_FLAGS)
2626
set(SWIFT_RUNTIME_CONCURRENCY_SWIFT_FLAGS)
2727

28-
set(swift_concurrency_private_link_libraries swiftThreading)
28+
set(swift_concurrency_private_link_libraries)
2929
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
3030
list(APPEND swift_concurrency_private_link_libraries Synchronization)
3131
endif()
3232

33+
set(swift_concurrency_incorporate_object_libraries)
34+
if(NOT SWIFT_BUILD_STATIC_STDLIB)
35+
list(APPEND swift_concurrency_incorporate_object_libraries swiftThreading)
36+
endif()
37+
3338
if("${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
3439
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
3540
include_directories(AFTER
@@ -72,6 +77,11 @@ endif()
7277
list(APPEND SWIFT_RUNTIME_CONCURRENCY_C_FLAGS
7378
"-D__STDC_WANT_LIB_EXT1__=1")
7479

80+
if(SWIFT_BUILD_STATIC_STDLIB)
81+
list(APPEND SWIFT_RUNTIME_CONCURRENCY_C_FLAGS
82+
"-DSWIFT_BUILD_STATIC_STDLIB=1")
83+
endif()
84+
7585
add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
7686
../CompatibilityOverride/CompatibilityOverride.cpp
7787
Actor.cpp
@@ -132,7 +142,7 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
132142
SWIFT_MODULE_DEPENDS_WINDOWS CRT
133143

134144
PRIVATE_LINK_LIBRARIES ${swift_concurrency_private_link_libraries}
135-
145+
INCORPORATE_OBJECT_LIBRARIES ${swift_concurrency_incorporate_object_libraries}
136146
LINK_LIBRARIES ${swift_concurrency_link_libraries}
137147

138148
C_COMPILE_FLAGS

stdlib/public/Concurrency/Error.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void swift::swift_Concurrency_fatalError(uint32_t flags, const char *format,
3535
swift_Concurrency_fatalErrorv(flags, format, val);
3636
}
3737

38+
#if !SWIFT_BUILD_STATIC_STDLIB
3839
// Handle fatal errors from the threading library
3940
SWIFT_ATTRIBUTE_NORETURN
4041
SWIFT_FORMAT(1, 2)
@@ -44,3 +45,4 @@ void swift::threading::fatal(const char *format, ...) {
4445
va_start(val, format);
4546
swift_Concurrency_fatalErrorv(0, format, val);
4647
}
48+
#endif // !SWIFT_BUILD_STATIC_STDLIB

stdlib/public/core/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ endif()
245245
set(GROUP_INFO_JSON_FILE ${CMAKE_CURRENT_SOURCE_DIR}/GroupInfo.json)
246246
set(swift_core_link_flags "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}")
247247
set(swift_core_framework_depends)
248-
set(swift_core_private_link_libraries swiftThreading)
248+
set(swift_core_private_link_libraries)
249249
set(swift_stdlib_compile_flags "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}")
250250

251251
if(SWIFT_PRIMARY_VARIANT_SDK STREQUAL CYGWIN)
@@ -299,6 +299,7 @@ list(APPEND swift_core_incorporate_object_libraries swiftRuntime)
299299
list(APPEND swift_core_incorporate_object_libraries swiftLLVMSupport)
300300
list(APPEND swift_core_incorporate_object_libraries swiftDemangling)
301301
list(APPEND swift_core_incorporate_object_libraries swiftStdlibStubs)
302+
list(APPEND swift_core_incorporate_object_libraries swiftThreading)
302303
if(SWIFT_STDLIB_HAS_COMMANDLINE)
303304
list(APPEND swift_core_incorporate_object_libraries swiftCommandLineSupport)
304305
endif()

0 commit comments

Comments
 (0)