-
Notifications
You must be signed in to change notification settings - Fork 412
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
Support for wasm32-wasi target? #654
Comments
We don't support wasi yet. It isn't totally clear what wasm-pack should do with wasi yet. (Not saying it is particularly difficult to figure out, we just haven't discussed it too much yet). |
Just allowing to somehow set target to WASI would be already good. Right now playing with porting some libraries to WASM via wasm-pack, but running into runtime panics due to unimplemented syscalls, which would be solved by passing WASI as a target. |
@yurydelendik Looks like the linked issue has been resolved since. |
True. While underline tools are fixed, the wasm-pack code checks and operates only with 'wasm32-unknown-unknown' target. |
Yeah, and seems like at this point it would be a fairly simple fix to allow other targets. |
This would be a very useful feature. |
I was hoping to use use Looking at https://nodejs.org/api/wasi.html, I probably need to upgrade my Node.js version and call |
I think this needs to be added to wasm-bindgen first before it can be added to wasm-pack. |
I came across just now https://github.com/bytecodealliance/cargo-wasi and I'm not sure if I should use that directly instead for wasi projects in rust. Can some code be shared to add support to wasm-pack? |
Does wasm-bindgen differentiate or, indeed, even know, which target Wasm was built with? I think it should already work with IIUC the issue is only in wasm-pack because it passes the |
@RReverser For WASI it is necessary to pass in the WASI functions, but wasm-bindgen doesn't do this, therefore And there could be some other assumptions that wasm-bindgen makes about |
Ah yeah, that's a good point, these imports would have to be propagated via JS wrapper. |
Perhaps wasmer-js could be used to handle the WASI functions. |
It seems this may need supported in |
There is no need to commit to any specific implementation for WASI syscalls, the JS wrapper would simply need to propagate the imports and let Webpack config or whatever handle them by mapping to a real implementation. |
As of rust-lang/rust#79998, in order to fix the use-case of linking C code (which passes structs by value) with Rust code, the wasm32-wasi target now has an ABI incompatibility with wam_bindgen (when passing structs by value). Thus, to make this happen someone would likely need to adopt rust-lang/rust-bindgen#1952 and make the wasm_bindgen support the clang WASM ABI. |
I've tried the examples of ssvm-wasi-helper documented at Access operating system resources from WebAssembly and it worked pretty well. |
If you want to link WASM project against more advanced C libraries this is required. WASI provides working LIBC for WASM. I haven't yet figured out how to build Rust library with C dependencies using wasm-pack. |
There seems to be an ongoing effort for |
Does wasm-pack support building for the new
wasm32-wasi
target instead ofwasm32-unknown-unknown
?I have a project configured to use wasm-pack for wasm32-unknown-unknown, would like to switch to wasm32-wasi, wondering if I have to change the build tool, or if this is not supported and if there is a possibility it may in the future.
I tried
wasm-pack build --target wasm32-wasi
but this option specifies something else:Couldn't find any mention of "wasi" in this repository.
Background: https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-intro.md
The text was updated successfully, but these errors were encountered: