I recently heard of WASIX https://wasix.org and thought that might be useful as a deployment target for some applications we have that have to run on various remote LINUX based embedded systems. So decided to take it for a spin and tried installing it. In all cases the installation has silently failed:

$ cargo install cargo-wasix
    Finished release [optimized] target(s) in 52.76s
  Installing /Users/zicog/.cargo/bin/cargo-wasix
   Installed package `cargo-wasix v0.1.20` (executable `cargo-wasix`)
$ cargo wasix version
cargo-wasix 0.1.20
$ rustup target list | grep wasix

Hmm...nothing there.

$ rustup target list | grep was  
wasm32-unknown-unknown (installed)

Nope. Nothing.

The commonality is that all my systems are ARM64 based:
Nvidia Jetson NX.
Raspberry Pi 4
Mac Book Pro M1

Googling around for WASIX and ARM64 turns up nothing.

Anyone know if there is a WASIX for ARM64 yet? Or am I too early.

What I'm hoping for at the end of the day is that a Rust programs WASM executable compiled on Mac or Windows can be dropped onto ARM and Intel based systems and just work!

Try cargo install cargo-wasix --git https://github.com/wasix-org/cargo-wasix

I have, about 3-4 months ago, been able to run a wasix binary on my mac m1. I had issues when using the version from crates.io, but, had no issues when using the latest git branch. I'm not 100% sure if this would work now, but, still worth a shot.

Thanks. But still no luck (on MacBook M1 at least):

 $ cargo install cargo-wasix --git https://github.com/wasix-org/cargo-wasix
    Updating git repository `https://github.com/wasix-org/cargo-wasix`
  Installing cargo-wasix v0.1.19 (https://github.com/wasix-org/cargo-wasix#1ce2359a)
    Updating crates.io index
$ cargo wasix --version
cargo-wasix 0.1.19 (1ce2359a6b 2023-06-28)
$ rustup target list | grep wasix

Still nothing.

Oddly the version seems to have jumped backwards to 0.1.19 from 0.1.20. Might have expected git to be a step ahead.

It looks like you have to use cargo wasix build to build and then cargo-wasix internally handles I think downloading of a precompiled version of wasix's patched rustc (GitHub - wasix-org/rust: Rust with WASIX targets.):

This rust toolchain seems to be put under the name wasix, and it is not rustup managed so rustup target list will not work on this toolchain.

1 Like

Thanks. But:

$ cargo wasix build-toolchain 
Building the wasix toolchain...
WARNING: this could take a long time and use a lot of disk space!
Running apt-get --version:
error: libc builds are only supported on Linux
$ cargo wasix build       
error: could not find `Cargo.toml` in `/Users/zicog` or any parent directory

This might be a rabbit hole too deep for me at this time...

1 Like

Silly question, but are you running cargo wasix build from an existing Rust project?

The cargo wasix build command is for building a Rust project using the wasix target so you'll need to be inside a folder with a Cargo.toml file. If you are familiar with cross the workflow is quite similar (i.e. use cargo wasix foo instead of cargo foo for anything that involves building anything with that target).

Pretty good question. No I did not have an existing Rust project in mind yet. I was just following the wasix installation instructions here: Installation and stalled at this step:

Check that the wasix toolchain was installed correctly by running:

$ rustup target list | grep wasixwasix

Which produced no such result, so I assumed it was not working.

However prompted by your question I blindly pressed on:

Install wasix as per the document:

$ cargo install cargo-wasix

Check the version:

$ cargo wasix --version
cargo-wasix 0.1.20

Check tool chain installed correctly. THIS FAILS!

$ rustup target list | grep wasix

Create a new hello world project and check it builds/runs normally:

$ cargo new wasi-hello
$ cd wasi-hello
$ cargo run 

Try and build/run it as WASM:

$ cargo wasix run 

This fails for the lack of wasmer, install wasmer as suggested:

$ curl https://get.wasmer.io -sSfL | sh
$ source /Users/zicog/.wasmer/wasmer.sh

And try again:

$ cargo wasix run 
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `/Users/zicog/.cargo/bin/cargo-wasix target/wasm32-wasmer-wasi/debug/wasi-hello.wasm`
info: Post-processing WebAssembly files
     Running `target/wasm32-wasmer-wasi/debug/wasi-hello.wasm`
Hello, world!

Yay! It works.

And finally, run the generated WASM with wasmer:

$ wasmer target/wasm32-wasmer-wasi/debug/wasi-hello.wasm
Hello, world!

More yay! That works too.

Thanks for the shove there. Now to see it it flies on the Pi and Jetson.

1 Like

All looking good until I try and compile one of my existing projects:

$ cargo wasix run  --release 
   Compiling zeroize_derive v1.4.2
   Compiling ring v0.16.20
   Compiling serde_derive v1.0.171
   Compiling futures-util v0.3.28
   Compiling futures-sink v0.3.28
   Compiling tinyvec_macros v0.1.1
   Compiling ppv-lite86 v0.2.17
   Compiling base64 v0.13.1
error[E0432]: unresolved import `super::sysrand_chunk`
   --> /Users/zicog/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ring-0.16.20/src/rand.rs:306:16
306 |     use super::sysrand_chunk::chunk;
    |                ^^^^^^^^^^^^^ could not find `sysrand_chunk` in `super`

What is up with that ring thing? It seems to give me problems all the time.

ring doesn't know how to request randomness from the WASI system interface. Needs a patch to upstream to add OS support.

1 Like

Ring uses a bunch of assembly for things so it doesn't cross-compile out of the box.

You'll need to patch ring with a WASIX-compatible version until we can get the fixes merged upstream.

# Cargo.toml

ring = { git = "https://github.com/wasix-org/ring", branch = "wasix" }

I know we only recently got ring to compile, so let me know if it doesn't work for you.

You might also want to refer to some of the examples in the example repo:


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.