mirror of
https://github.com/apple/swift.git
synced 2026-10-10 13:50:43 +02:00
Under interface-LTO the Synchronization library's archive holds real code that clients must link against; under the default Inlinable model it's empty. Introduce a lit substitution that always adds `-lswiftSynchronization` and thread it through every executable embedded test that `import`s Synchronization. Harmless under default codegen (the archive is empty), load-bearing under interface-LTO.
32 lines
750 B
Swift
32 lines
750 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend -parse-as-library -enable-experimental-feature Embedded -disable-availability-checking -wmo %s -c -o %t/main.o
|
|
// RUN: %target-embedded-link %target-clang-resource-dir-opt %t/main.o %target-embedded-single-threaded-shim %target-embedded-synchronization -o %t/a.out -dead_strip
|
|
// RUN: %target-run %t/a.out
|
|
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: optimized_stdlib
|
|
// REQUIRES: synchronization
|
|
// REQUIRES: swift_feature_Embedded
|
|
|
|
import Synchronization
|
|
|
|
var result = 0
|
|
|
|
@main
|
|
struct Main {
|
|
static func main() {
|
|
let mutex = Mutex(0)
|
|
|
|
mutex.withLock {
|
|
$0 += 1
|
|
}
|
|
|
|
let value = mutex.withLockIfAvailable {
|
|
$0 += 1
|
|
return $0
|
|
}
|
|
|
|
result = value!
|
|
}
|
|
}
|