Files
swift-mirror/test/embedded/synchronization-mutex-single-threaded.swift
Doug Gregor 48e60681f9 [Embedded tests] Add %target-embedded-synchronization substitution
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.
2026-07-14 11:56:50 -07:00

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!
}
}