Files
swift-mirror/test/embedded/concurrency-simple.swift
Ian Anderson 8959dd97fe [CMake] [Darwin] Don't build the SDK overlays by default on Apple platforms
The Apple SDKs have been providing the Darwin overlay since macOS 10.14.4, iOS 12.2, et al. More recently the SDK version has diverged from the Swift version making them incompatible. Stop building the overlay from Swift. Once the SDK overlays aren't being built, the clang overlays need to be built in testing.

%target-swift-emit-pcm doesn't use the sdk, but %target-swift-frontend does, which will cause them to have a mismatch with "builtin headers belong to system modules, and _Builtin_ modules are ignored for cstdlib headers" aka LANGOPT(BuiltinHeadersInSystemModules) aka -fbuiltin-headers-in-system-modules.

rdar://115192929
2024-09-06 13:28:14 -07:00

51 lines
1.2 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -parse-as-library %s -c -o %t/a.o
// RUN: %target-clang -x c -c %S/Inputs/print.c -o %t/print.o
// RUN: %target-clang %t/a.o %t/print.o -o %t/a.out %swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos/libswift_Concurrency.a -dead_strip
// RUN: %target-run %t/a.out | %FileCheck %s
// REQUIRES: executable_test
// REQUIRES: swift_in_compiler
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx
// The Darwin SDK overlay module in the macOS SDK cannot be imported in
// embedded Swift mode.
// XFAIL: 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
}
}