Skip to content

Conversation

@whitequark
Copy link
Contributor

This commit enables thread support in libc++ for all thread models, enabling C++ applications that use threading APIs like <atomic> but do not spawn threads (e.g. Clang) to be built with minimal changes.

Fixes #546.

Depends on WebAssembly/wasi-libc#602.

@whitequark whitequark marked this pull request as ready for review July 26, 2025 17:43
@whitequark whitequark force-pushed the libcxx-threads-single branch 2 times, most recently from 4f0670b to d25afce Compare July 26, 2025 18:01
@whitequark
Copy link
Contributor Author

This PR of course shouldn't be merged as-is because the submodule shound point to the merge commit in wasi-libc.

This commit enables thread support in libc++ for all thread models,
enabling C++ applications that use threading APIs like `<atomic>` but
do not spawn threads (e.g. Clang) to be built with minimal changes.

Fixes WebAssembly#546.
@whitequark whitequark force-pushed the libcxx-threads-single branch from 8b37dde to fb2ae11 Compare July 27, 2025 00:47
@whitequark
Copy link
Contributor Author

Updated with proper wasi-libc commit, should be ready to merge!

@alexcrichton alexcrichton enabled auto-merge (squash) July 27, 2025 01:12
@alexcrichton alexcrichton merged commit dadbd94 into WebAssembly:main Jul 27, 2025
9 checks passed
@whitequark whitequark deleted the libcxx-threads-single branch July 27, 2025 02:47
@whitequark
Copy link
Contributor Author

@alexcrichton I have compiled Clang with the current HEAD and it builds and runs fine.

kateinoigakukun added a commit to kateinoigakukun/icu that referenced this pull request Jul 27, 2025
Thanks to recent wasi-libc changes, wasi-libc and libc++ in wasi-sdk now
provides `std::atomic`, `std::mutex`, and other thread-related APIs even
for wasm32-wasip1 target.

* WebAssembly/wasi-libc#602
* WebAssembly/wasi-sdk#548
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using libc++ with the "emulated pthreads" mode

2 participants