a-shell icon indicating copy to clipboard operation
a-shell copied to clipboard

WASM Threads

Open User-art-prog opened this issue 3 months ago • 2 comments

I compiled a program with target: wasm32-wasip1-threads and -pthread support. However I get this error when trying to run: wasm: TypeError: import wasi:thread-spawn must be an object (evaluating 'new WebAssembly.Instance(module, wasi.getImports(module))') Has anyone managed to get pthreads on a-Shell working yet?

User-art-prog avatar Sep 04 '25 01:09 User-art-prog

This error comes directly from Apple's webAssembly engine: it does not support threads (yet). To run a webassembly program with threads, we need two things: compiling it with the right target (as you did), and an engine that supports them (that's the blocking point). Safari does support webWorkers (since recently), so I think it should be able to support pthreads in the near future.

holzschu avatar Sep 04 '25 19:09 holzschu

The Wasm threads feature is different from the WASI threads feature (wasm32-wasip1-threads).

Safari already supports Wasm threads. However, the current WASI implementations used in a-Shell (e.g., Wasmer JS, wasm3) don’t provide the WASI threads feature. Therefore, it’s not because of Safari.

kkebo avatar Sep 05 '25 01:09 kkebo