Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion stdlib/public/Synchronization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,24 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB)
if(SWIFT_EMBEDDED_STDLIB_SDKS_FOR_TARGET_TRIPLES)
set(SWIFT_SDK_embedded_ARCH_${arch}_PATH "${EMBEDDED_STDLIB_SDK_FOR_${triple}}")
endif()

set(SWIFT_SYNCHRONIZATION_EMBEDDED_SOURCES)

if("${arch}" MATCHES "wasm32")
list(APPEND SWIFT_SYNCHRONIZATION_EMBEDDED_SOURCES ${SWIFT_SYNCHRONIZATION_SOURCES})
list(APPEND SWIFT_SYNCHRONIZATION_EMBEDDED_SOURCES ${SWIFT_SYNCHRONIZATION_WASM_SOURCES})
else()
list(APPEND SWIFT_SYNCHRONIZATION_EMBEDDED_SOURCES ${SWIFT_SYNCHRONIZATION_ATOMIC_SOURCES})
endif()

add_swift_target_library_single(
embedded-synchronization-${mod}
swiftSynchronization
ONLY_SWIFTMODULE
IS_FRAGILE

${SWIFT_SYNCHRONIZATION_ATOMIC_SOURCES}
${SWIFT_SYNCHRONIZATION_EMBEDDED_SOURCES}

GYB_SOURCES
${SWIFT_SYNCHRONIZATION_GYB_SOURCES}

Expand Down
21 changes: 21 additions & 0 deletions test/embedded/wasm/mutex.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// RUN: %target-run-simple-swift(-enable-experimental-feature Embedded -parse-as-library -wmo) | %FileCheck %s

// REQUIRES: executable_test
// REQUIRES: OS=wasip1
// REQUIRES: swift_feature_Embedded

import Synchronization
@main struct Main {
static func main() {
let m = Mutex(42)

m.withLock {
print("Hello \($0)") // CHECK: Hello 42
$0 = 37
}

m.withLock {
print("Hello \($0)") // CHECK: Hello 37
}
}
}