Skip to content

Commit e8b36ab

Browse files
authored
[Concurrency] Enable concurrent global executor on non-Darwin platforms (swiftlang#35871)
* [Concurrency] Enable concurrent global executor on non-Darwin platforms * Fix runtime unittest build
1 parent cb0cb30 commit e8b36ab

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ if(SWIFT_CONCURRENCY_USES_DISPATCH)
2727
# FIXME: we can't rely on libdispatch having been built for the
2828
# target at this point in the process. Currently, we're relying
2929
# on soft-linking.
30-
#list(APPEND swift_concurrency_link_libraries
31-
# dispatch)
30+
list(APPEND swift_concurrency_link_libraries
31+
dispatch)
3232
endif()
3333
endif()
3434

stdlib/public/Concurrency/TaskPrivate.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ void _swift_task_alloc_destroy(AsyncTask *task);
3434

3535
#if defined(SWIFT_STDLIB_SINGLE_THREADED_RUNTIME)
3636
#define SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR 1
37-
#elif !__APPLE__
38-
// FIXME: this is a terrible workaround for our temporary
39-
// inability to link libdispatch.
40-
#define SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR 1
4137
#else
4238
#define SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR 0
4339
#endif

test/Concurrency/Runtime/mainactor.swift

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
1-
// RUN: %target-run-simple-swift(-parse-as-library -Xfrontend -enable-experimental-concurrency) | %FileCheck %s
1+
// RUN: %target-run-simple-swift(-parse-as-library -Xfrontend -enable-experimental-concurrency %import-libdispatch) | %FileCheck %s
22

33
// REQUIRES: executable_test
44
// REQUIRES: concurrency
5+
// REQUIRES: libdispatch
56

6-
// REQUIRES: OS=macosx || OS=ios
7-
// FIXME: should not require Darwin to run this test once we have async main!
8-
9-
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
10-
import Dispatch
11-
#endif
7+
import Dispatch
128

139
/// @returns true iff the expected answer is actually the case, i.e., correct.
1410
/// If the current queue does not match expectations, this function may return
1511
/// false or just crash the program with non-zero exit code, depending on SDK.
1612
func checkIfMainQueue(expectedAnswer expected: Bool) -> Bool {
17-
// FIXME: until we start using dispatch on Linux, we only check
18-
// which queue we're on with Darwin platforms.
19-
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
2013
if #available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *) {
2114
dispatchPrecondition(condition: expected ? .onQueue(DispatchQueue.main)
2215
: .notOnQueue(DispatchQueue.main))
23-
2416
}
25-
#endif
2617
return true
2718
}
2819

unittests/runtime/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
6969
list(APPEND PLATFORM_TARGET_LINK_LIBRARIES
7070
swift_Concurrency${SWIFT_PRIMARY_VARIANT_SUFFIX}
7171
)
72+
73+
if(NOT "${SWIFT_PRIMARY_VARIANT_SDK}" IN_LIST SWIFT_APPLE_PLATFORMS)
74+
list(APPEND PLATFORM_TARGET_LINK_LIBRARIES
75+
dispatch${SWIFT_PRIMARY_VARIANT_SUFFIX}
76+
BlocksRuntime${SWIFT_PRIMARY_VARIANT_SUFFIX}
77+
)
78+
endif()
7279
endif()
7380

7481
# Don't complain about these files not being in the sources list.

0 commit comments

Comments
 (0)