Skip to content

Enable pthread_mutex_t use on WASI with a multithreaded runtime. #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 1, 2024

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Mar 31, 2024

This PR opts WASI builds into using pthread_mutex_t in Locked when the WASI environment supports threading.

_runtime(_multithreaded) was added very recently with swiftlang/swift#72649, so we need an additional compiler version check before testing the runtime flag. That change has not been cherry-picked to Swift 6.0, so assume 6.1 or later is needed.

WASI with Swift 5.10, as well as WASI without threading, will continue to stub out Locked.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR opts WASI builds into using `pthread_mutex_t` in `Locked` when the WASI environment supports threading.

`_runtime(_multithreaded)` was added very recently with swiftlang/swift#72649, so we need an additional compiler version check before testing the runtime flag.

WASI with Swift 5.10, as well as WASI without threading, will continue to stub out `Locked`.
@grynspan grynspan added enhancement New feature or request concurrency 🔀 Swift concurrency/sendability issues wasi/wasm 🧭 WebAssembly support labels Mar 31, 2024
@grynspan grynspan self-assigned this Mar 31, 2024
@grynspan
Copy link
Contributor Author

@kateinoigakukun, does this look right to you?

@grynspan
Copy link
Contributor Author

@swift-ci please test

…o assume it will be available in Swift 6.1 instead.
@grynspan
Copy link
Contributor Author

@swift-ci please test

Copy link
Member

@kateinoigakukun kateinoigakukun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked it compiles well on my local SDK with threads, thanks!

@grynspan grynspan merged commit a82de3b into main Apr 1, 2024
@grynspan grynspan deleted the jgrynspan/wasi-multithreaded branch April 1, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
concurrency 🔀 Swift concurrency/sendability issues enhancement New feature or request wasi/wasm 🧭 WebAssembly support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants