-
Notifications
You must be signed in to change notification settings - Fork 708
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
wasm-interp --wasi --enable-threads can't handle emcc's pthread support #1645
Comments
Yes there is no support threads in WASI and no thread API to speak of. There it generally very little support for WASI in emscripten-generated code. Only the most trivial emscripten output doesn't include calls to APIs that are outside of WASI and even emscripten-specific. So yeah.. although it would be nice to have one day what you are trying to do won't work today. |
Hm, so for code that I want to run under WASI, would I be better off using I've been using Emscripten up to because (initially) it was the only game in town, and then (later) it wasn't clear to me what the best options for libc/wasi support were. (Clang would actually be easier for us to support since we always have a recent clang available due to LLVM deps, and wouldn't require separate install/update like emsdk does.) |
wasi-sdk (which is basically clang + wasi-libc) is your best bet if you are targeting WASI: https://github.com/WebAssembly/wasi-sdk emscripten tries it best to output WASI-compatible stuff where it can.. but this is normally impossible since many emsripten features (including threads) are built on JS APIs. |
Yikes, I missed this the first time through. That's, uh, surprising? Judging from the comments on WebAssembly/WASI#296 (which I'm now following) it looks like the consensus is "we'll get around to adding it to WASI someday", which, well, again, is surprising. Sounds like the current status quo in wasm is basically "threads only work when compiling using emcc and using webworkers". |
Yes, basically. The WebAssembly threads proposal doesn't include any APIs for creating of joining threads, only the core concepts of shared memory and the operations on it. I think WASI wants to wait for some kind of standardized thread primitives in core WebAssembly before moving forward. |
I suspect this is a known issue, but recording it here:
emcc will allow you to compile with
-pthread
, and generate nice wrapper callers for POSIX pthread calls. I'd expect that invoking with--wasi --enable-threads
would allow wasm code of this form to load and run, but it fails at load time withwasi error: unknown module import: env
Looking at the wasm2wat output for my code I see only two symbols in env:
(import "env" "pthread_create" (func $pthread_create (type 7)))
(import "env" "pthread_join" (func $pthread_join (type 1)))
I presume this is a known-ish issue due to the current incomplete status of wasi support? Just wanted to note it down here for reference (and in case someone else encounters it).
The text was updated successfully, but these errors were encountered: