Skip to content

Commit e1bc4f1

Browse files
committed
[Build][Concurrency] Fix Concurrency build to work for Linux.
`SWIFT_BUILD_STATIC_STDLIB` is not mutually exclusive with `SWIFT_BUILD_DYNAMIC_STDLIB`, and Linux sets both, so we can't use `SWIFT_BUILD_STATIC_STDLIB` to conditionalise things. The linker error about duplicate definitions for the threading error handler was happening because we were forced to include the object containing that symbol; moving it to another object should fix that. And it turns out there's a way to get CMake to include the threading object library only when building a shared object, so use that too. rdar://90776105
1 parent 68dfde2 commit e1bc4f1

File tree

3 files changed

+30
-22
lines changed

3 files changed

+30
-22
lines changed

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ 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()
33+
set(swift_concurrency_incorporate_object_libraries_so swiftThreading)
3734

3835
if("${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
3936
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
@@ -77,11 +74,6 @@ endif()
7774
list(APPEND SWIFT_RUNTIME_CONCURRENCY_C_FLAGS
7875
"-D__STDC_WANT_LIB_EXT1__=1")
7976

80-
if(SWIFT_BUILD_STATIC_STDLIB)
81-
list(APPEND SWIFT_RUNTIME_CONCURRENCY_C_FLAGS
82-
"-DSWIFT_BUILD_STATIC_STDLIB=1")
83-
endif()
84-
8577
add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
8678
../CompatibilityOverride/CompatibilityOverride.cpp
8779
Actor.cpp
@@ -125,6 +117,7 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
125117
TaskLocal.swift
126118
TaskSleep.swift
127119
ThreadSanitizer.cpp
120+
ThreadingError.cpp
128121
TracingSignpost.cpp
129122
AsyncStreamBuffer.swift
130123
AsyncStream.swift
@@ -142,7 +135,8 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
142135
SWIFT_MODULE_DEPENDS_WINDOWS CRT
143136

144137
PRIVATE_LINK_LIBRARIES ${swift_concurrency_private_link_libraries}
145-
INCORPORATE_OBJECT_LIBRARIES ${swift_concurrency_incorporate_object_libraries}
138+
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY
139+
${swift_concurrency_incorporate_object_libraries_so}
146140
LINK_LIBRARIES ${swift_concurrency_link_libraries}
147141

148142
C_COMPILE_FLAGS

stdlib/public/Concurrency/Error.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,3 @@ void swift::swift_Concurrency_fatalError(uint32_t flags, const char *format,
3434
va_start(val, format);
3535
swift_Concurrency_fatalErrorv(flags, format, val);
3636
}
37-
38-
#if !SWIFT_BUILD_STATIC_STDLIB
39-
// Handle fatal errors from the threading library
40-
SWIFT_ATTRIBUTE_NORETURN
41-
SWIFT_FORMAT(1, 2)
42-
void swift::threading::fatal(const char *format, ...) {
43-
va_list val;
44-
45-
va_start(val, format);
46-
swift_Concurrency_fatalErrorv(0, format, val);
47-
}
48-
#endif // !SWIFT_BUILD_STATIC_STDLIB
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===--- ThreadingError.cpp - Error handling support code -----------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "swift/Threading/Errors.h"
14+
#include <cstdio>
15+
16+
#include "Error.h"
17+
18+
// Handle fatal errors from the threading library
19+
SWIFT_ATTRIBUTE_NORETURN
20+
SWIFT_FORMAT(1, 2)
21+
void swift::threading::fatal(const char *format, ...) {
22+
va_list val;
23+
24+
va_start(val, format);
25+
swift_Concurrency_fatalErrorv(0, format, val);
26+
}

0 commit comments

Comments
 (0)