wasix-org / cargo-wasix

Cargo wrapper for working with Webassembly wasi(x).
Apache License 2.0
54 stars 10 forks source link

cargo-wasix as the successor to cargo-wasi #33

Open jedisct1 opened 1 year ago

jedisct1 commented 1 year ago

cargo-wasi is being archived, so users need a replacement.

cargo-wasix could be what we should use and recommend instead. But it currently requires/install the wasix-libc as well as an old Rust toolchain. This may not be desirable, and is an issue for packaging.

Would it be reasonable to only download the wasix components when actually compiling to wasix? And maybe provide a cargo wasi command for people who need a maintained version of cargo wasi?

jedisct1 commented 1 year ago

Looks like it currently also requires wasmer to be present.

And cargo wasix build doesn't work when Rust was not installed with rustup.

Fixing these little things would also be good in order to recommend cargo-wasix as the replacement for cargo-wasi.

theduke commented 1 year ago

Hey @jedisct1 , at the moment cargo-wasix is geared towards WASIX.

It uses the wasm32-wasmer-wasi target by default, runs a wasm-opt pass with the --asyncify enabled (because WASIX requires it for fork/exec), and as you've noticed, currently requires rustup and uses wasmer as the default runtime.

The rustup dependency is something we'd like to get rid of anyway, and making the runtime configurable was also always a target and wouldn't be hard.

The main challenge would be deciding between regular wasm32-wasi and WASIX targets without regressing the user experience.

theduke commented 1 year ago

I general we'd definitely be open to making cargo-wasix also fill the shoes of cargo-wasi, as long as we can resolve the above in a satisfactory way.

One option would be defaulting to WASIX, but offering a flag / env var / custom Cargo.toml metadata to use wasm32-wasi instead.

jedisct1 commented 1 year ago

Could it install a cargo-wasi command in addition to cargo-wasix?

theduke commented 1 year ago

Duh, that's much more sensible.

It can be just the same binary (copied/symlinked as cargo-wasix and cargo-wasi), and we detect what to do based on the command name.

We'll tackle the rustup and configurable engine ourselves, but we'll probably be hard-pressed to find cycles for the cargo-wasi compat mode, and would wait for an outside contribution.