[Concurrency] Include more pieces of Concurrency in Embedded (AsyncStream, continuations)

We have been only including a subset of files and functionality on Embedded Concurrency, let's instead include all the
source files, and have a fine grained opt out on things that don't yet work. Namely, this is still avoiding clocks, task
sleeping and custom executors.

Add a test for AsyncStream and continuations on Embedded Concurrency.
This commit is contained in:
Kuba Mracek
2024-09-27 16:07:36 -07:00
parent 7f597c63ae
commit ed441eb1bf
18 changed files with 221 additions and 44 deletions

View File

@@ -0,0 +1,85 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -target %target-cpu-apple-macos14 -disable-availability-checking -parse-as-library -enable-experimental-feature Embedded %s -c -o %t/a.o
// RUN: %target-clang -x c -std=c11 -I %swift_obj_root/include -c %S/Inputs/executor.c -o %t/executor.o
// RUN: %target-clang %t/a.o %t/executor.o -o %t/a.out %swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos/libswift_Concurrency.a -dead_strip
// RUN: grep DEP\: %s | sed 's#// DEP\: ##' | sort > %t/allowed-dependencies.txt
// RUN: %llvm-nm --undefined-only --format=just-symbols %t/a.out | sort | tee %t/actual-dependencies.txt
// Fail if there is any entry in actual-dependencies.txt that's not in allowed-dependencies.txt
// RUN: test -z "`comm -13 %t/allowed-dependencies.txt %t/actual-dependencies.txt`"
// DEP: __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKc
// DEP: __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKcm
// DEP: __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEmPKc
// DEP: __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev
// DEP: __ZNSt3__16chrono12steady_clock3nowEv
// DEP: __ZNSt3__19to_stringEj
// DEP: __ZNSt3__19to_stringEy
// DEP: __ZdlPv
// DEP: __ZdlPvm
// DEP: __Znwm
// DEP: ___assert_rtn
// DEP: ___error
// DEP: ___stack_chk_fail
// DEP: ___stack_chk_guard
// DEP: ___stderrp
// DEP: _abort
// DEP: _exit
// DEP: _fprintf
// DEP: _free
// DEP: _malloc
// DEP: _memmove
// DEP: _memset
// DEP: _memset_s
// DEP: _nanosleep
// DEP: _posix_memalign
// DEP: _putchar
// DEP: _strlen
// DEP: _vfprintf
// DEP: _vsnprintf
// DEP: _write
// RUN: %target-run %t/a.out | %FileCheck %s
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx
import _Concurrency
public func test() async -> Int {
print("test")
let t = Task {
print("return 42")
return 42
}
print("await")
let v = await t.value
print("return")
return v
}
@main
struct Main {
static func main() async {
print("main")
// CHECK: main
let t = Task {
print("task")
let x = await test()
print(x == 42 ? "42" : "???")
}
print("after task")
await t.value
// CHECK-NEXT: after task
// CHECK-NEXT: task
// CHECK-NEXT: test
// CHECK-NEXT: await
// CHECK-NEXT: return 42
// CHECK-NEXT: return
// CHECK-NEXT: 42
}
}