Skip to content
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

WASI is compatible with all Rust crates? #80

Closed
AchalaSB opened this issue Aug 21, 2019 · 8 comments
Closed

WASI is compatible with all Rust crates? #80

AchalaSB opened this issue Aug 21, 2019 · 8 comments
Labels
discussion A discussion that doesn't yet have a specific conclusion or actionable proposal.

Comments

@AchalaSB
Copy link

Hey,
I'm planning to use WASI to compile my Rust code. But my question is if I use WASI, is it compatible to all rust crates?

Or is there any list to which and all crates WASI is supporting?

I think those crates which is having wasm32-unknown-unknown support will execute.

Thanks,
Achala

@devsnek
Copy link
Member

devsnek commented Aug 21, 2019

not all rust crates, but probably most rust crates. it's more of a question of what rust's stdlib supports (with the exception of stuff like random).

@vitiral
Copy link

vitiral commented Aug 21, 2019

It is important to note that WASI is not yet standardized, so any final answer to this question is impossible until it is.

It is also important to note that certain crates are built specifically for certain platforms, i.e. posix or windows. While wasi aims to create a "conceptual operating system" that attempts to be able to emulate most operating systems, it will certainly not support every possible syscall.

So to (maybe) answer your question: most rust crates that are pure logic should work -- which is probably most rust crates.

@leonwanghui
Copy link
Contributor

Quite interesting topic. I am learning rust and wasm these days, and here are some conclusions from my side:

  • Not support all crates. When I tried to compile some crates like reqwest, some errors occurred with bad network layer support.
  • Currently for latest Rust (v1.37), there should be three targets supporting wasm which are wasm32-unknown-unknown, wasm32-unknown-emscripten and wasm32-wasi. So I think this could make users confused when choosing target to build the code.
  • I found there are also many wasm compilers, so it's also confusing which one is better.

@AchalaSB
Copy link
Author

Agree. All rust crates not supported. But most of crates having webassembly support i.e wasm32-unknown-unknown will support (have tested with 5-10 crates).
wasm32-unknown-unknown and wasm32-wasi is almost similar. It is light-weight. wasi is having additional functionality as it is POSIX compliant.
But another target with emscripten, it contains a JS glue code. if you wan't to use syscalls/Filesystems you may use that. And again the code is not optimized you may require external tools to optimize it like wasm-gc

@leonwanghui
Copy link
Contributor

@AchalaSB If I get it right, if I want to try some system programming with wasi, the best option is wasm32-wasi target.

@AchalaSB
Copy link
Author

@leonwanghui yes in that case try with wasi.
But right now crates like reqwest, hyper, web3, rpc are not webassembly compatible. You may end up with some socket error etc.

@leonwanghui
Copy link
Contributor

Found some issues on hyper and reqwest about wasm support: hyperium/hyper#1245 seanmonstar/reqwest#288

@sunfishcode
Copy link
Member

WASI doesn't currently have general networking support. We're aware this is an important feature and are working on it.

@sunfishcode sunfishcode added the discussion A discussion that doesn't yet have a specific conclusion or actionable proposal. label Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion A discussion that doesn't yet have a specific conclusion or actionable proposal.
Projects
None yet
Development

No branches or pull requests

5 participants