-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Port the JS WASI polyfill to wasi-common #520
Comments
@sunfishcode I would like to indicate my interest in helping here. I have a question here. I have been experimenting with file descriptor syscalls in the current |
Okay, so I want to check my understanding with you here. In order to implement the same polyfill in |
Concerning WASI's use of 64-bit ints: in the long term, JS engines will support this via bignums. In the short term, we're hoping that shims can be sufficient. The shims may get a little ugly, but I don't know of any better solution, short of changing the WASI APIs, which would also be ugly. The I think the thing to start with is compiling wasi-common with wasm32-unknown-emscripten. That should give you a library containing C symbols prefixed with The next step is to start adapting the current polyfill's wasi.js to call that library. I think the main things to do are:
|
@sunfishcode Thank you very much for the clear instruction. If I understand correctly, we are relying on the |
Hey @dingxiangfei2009, some (if not most) of our syscalls impl does indeed depend on the |
@kubkon I see. I assume that CraneStation/wasi-common#16 is related as well, so I will watch that list of functions. Also, would you mind giving some hints on which function can reuse |
That's true, but as it turns out, we don't need to operate on raw descriptors at all times anymore. Instead, it's preferable to use So all in all, the current trend is to move away from relying on raw descriptor manipulation as much as possible (of course, sometimes, like in the case of path manipulation, it might not be possible). I hope that made it a bit clearer. If not, fire away and I'll try to explain it more! :-) |
@kubkon Thanks for the explanation, and I managed to get some findings after poking around. I have looked deeper into Access mode of file descriptors look promising and Maybe I am overlooking something. Would you mind giving a direction here, like exactly which syscall can be "simplified" with Speaking of overlooking stuff, I did find that |
Also, since |
@dingxiangfei2009 patching
All in all, I think that your plan of patching |
After putting in some thought into this and doing a little experiment with My proposition here is that we remove |
Actually, I'd appreciate your feedback @alexcrichton on this as well. |
If nix is an obstacle, then I think dropping the dependency on nix is a sound decision, especially that we have a slightly different understanding of Could we possibly keep the Rusty wrappers in a separate crate, similar to |
I agree on keeping the wrappers in a separate crate :-) |
This sounds like a reasonable solution to me, it's likely inevitable that there's a |
Me too 🙂 |
It’s settled then! I’ve already started prepping some ground work and should be able to deliver a working (not necessarily final mind you) solution, i.e., @marmistrz, how about |
@kubkon |
Closing this old issue, as the JS polyfill referenced here is no longer in use. |
Wasmtime has a JS polyfill implementation of WASI:
https://github.com/CraneStation/wasmtime/tree/polyfill/wasmtime-wasi/js-polyfill
which works by compiling wasmtime's C implementation of WASI with Emscripten, and then adding a bit of support code on top of that.
We should port the support code to work on top of wasi-common, compiled with wasm32-unknown-emscripten. In theory, all the big pieces are in place -- wasi-common provides the same functionality as Wasmtime's C implementation of WASI, Emscripten can provide the same underlying support in both cases, and the support code should roughly be the same. So the work here is in rewiring everything up in wasi.js, and porting polyfill.c to Rust, probably splitting out that
EM_ASM
into a standalone JS file.I've marked this "help wanted" -- if someone's interested in doing this port, that'd be great (and I can help mentor), but it'd even help just to have more ideas for packaging, binding, or other ways we could make the polyfill better. The current support code and shell.html is super minimal.
The text was updated successfully, but these errors were encountered: