Skip to content
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

Add support for wasm32-wasi-threads #15484

Closed
theoparis opened this issue Apr 27, 2023 · 3 comments
Closed

Add support for wasm32-wasi-threads #15484

theoparis opened this issue Apr 27, 2023 · 3 comments
Labels
arch-wasm 32-bit and 64-bit WebAssembly
Milestone

Comments

@theoparis
Copy link

See WebAssembly/wasi-sdk#274
image

I tried building something that requires cmake and pthreads and it failed to compile with zig;cc as the compiler and wasm32-wasi. If I try to use the wasm32-wasi-threads target I get this:

error: UnknownApplicationBinaryInterface
@andrewrk andrewrk added the arch-wasm 32-bit and 64-bit WebAssembly label Apr 27, 2023
@andrewrk andrewrk added this to the 0.11.0 milestone Apr 27, 2023
@andrewrk
Copy link
Member

andrewrk commented Apr 27, 2023

If WebAssembly supports threads now, we can start by changing this logic:

zig/src/target.zig

Lines 210 to 212 in aa3405a

pub fn isSingleThreaded(target: std.Target) bool {
return target.isWasm();
}

Are WebAssembly threads supported in browsers?

@jakehemmerle
Copy link

Are WebAssembly threads supported in browsers?

It looks like Wasm threads have been supported in major browsers for a year or two now.

Be aware, there are two Wasm threading specs to be aware of: Threads and Atomics (which is in phase3/5 for the core Wasm spec), and wasi-threads (which is phase 1/5 for the WASI spec).

What's the difference? wasi-threads intro explains:

That Threads and Atomics proposal provides the primitives necessary for shared memory, atomic operations, and wait/notify. This wasi-threads proposal solely provides a mechanism for spawning threads. Any other thread-like operations (thread joining, locking, etc.) will use primitives from the Threads and Atomics proposal.

Some background: browsers already have a mechanism for spawning threads — Web Workers — and the Threads and Atomics proposal avoided specifying how thread spawning should occur. This allows other uses of WebAssembly — i.e., outside the browser — to specify their own mechanism for spawning threads.


Regarding support for wasi-threads: wasmtime seems to be the defacto Wasm runtime and it indicates both full support for Threads and Atomics and full support for wasm-threads.

@andrewrk andrewrk modified the milestones: 0.11.0, 0.12.0 Jul 20, 2023
@andrewrk
Copy link
Member

Done:

@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm 32-bit and 64-bit WebAssembly
Projects
None yet
Development

No branches or pull requests

3 participants