WIP: Improve Emscripten support - #5259
Conversation
|
@QuantumSegfault: This seems like a viable approach - basing Emscripten on your WASI work, after reading https://v8.dev/blog/emscripten-standalone-wasm and noting that they apparently try to use WASI APIs as much as possible, even in non-standalone-wasm mode. To get the druntime test runners to link, I only had to avoid a single undefined |
|
I'm not sure this makes sense to do like this. Emscripten use a more vanilla Musl, without all of the differences to the headers WASI-libc made. They opted to stub out functions, rather than remove them, and otherwise use the unmodified types, constants, etc. (other than where architecture specific differences are concerned). A lot of the
|
|
Yeah the I'd hope that Emscripten would eventually be based on wasi-libc... |
dc050c1 to
b03eb55
Compare
|
Okay, this is now based on I'm okay with depending/building on predefined |
Threading is a notable difference. Emscripten actually DOES support threading (over web workers; with some caveats). https://emscripten.org/docs/porting/pthreads.html Signals still not, other than for Though I wouldn't mind holding off on the threading discussion until I figure out WASIp3 (with Other than that I think the rest of the WASI route-arounds should be fine, if not always necessary. |
Yeah that sounds good to me. [And note that I've just started with The compiler has a special case wrt. TLS globals for wasm in general IIRC, emitting them as thread-global; so the compiler will probably have to be adapted for wasm threading too. |
I'm fairly certain that WASIp1 is the only valid option for Emscripten. They provide a subset of WASIp1 for the web (but not p2+ AFAICT) https://github.com/emscripten-core/emscripten/blob/main/src/lib/libwasi.js
Good to know. |
| enum B_NO_TRANSLATOR = (B_TRANSLATION_ERROR_BASE + 1); | ||
| enum B_ILLEGAL_DATA = (B_TRANSLATION_ERROR_BASE + 2); | ||
| } | ||
| else version (CRuntime_WASI) |
There was a problem hiding this comment.
These errno are correct, but Emscripten provides additional ones:
There was a problem hiding this comment.
Yeah here I was lazy and didn't want to duplicate the existing CRuntime_WASI block, after seeing that the Emscripten headers forward the WASI codes. [And I don't really care about the extra ones; if people relied on them, their code wouldn't work with WASI.]
At least a comment wrt. Emscripten would be good though; there's some polishing left to do, hence the draft state and WIP title. :)
Based on WASI.