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

Readme Rust example without WASI? #523

Open
vmx opened this issue Feb 26, 2023 · 3 comments
Open

Readme Rust example without WASI? #523

vmx opened this issue Feb 26, 2023 · 3 comments

Comments

@vmx
Copy link

vmx commented Feb 26, 2023

I've tried things out for the first time, so I might be totally wrong. Hence I haven't opened a PR editing the readme, but I thought I ask first.

I've followed the steps from the Guest: Rust section of the readme. It starts with using wasm32-wasi as target. At the end you should use an adapter module to build the component. When I run wasm-tools component wit my-component.wasm I get lots of output that refers to WASI things. I guess that's correct.

But when I try to run it via Wasmtime, I get the error Error: import `wasi-stderr` not defined.

What worked for me is: Using wasm32-unknown-unknown as target. I then don't add the adapter and simply run:

wasm-tools component new ./target/wasm32-wasi/debug/my-project.wasm  -o my-component.wasm

The wasm-tools component wit my-component.wasm prints out what the readme says. When I run the resulting wasm file with Wasmime, it works as expected.

@alexcrichton
Copy link
Member

Yes WASI is not required and you can use the wasm32-unknown-unknown target as you've seen. The drawback to this is that many crates and the standard library won't work, along with standard utilities like println!. I think mentioning this in the README is fine since it's basically just dropping the --adapt argument as you've seen.

@vmx
Copy link
Author

vmx commented Feb 27, 2023

And what would be the fix to get the WASI version working? Is it a Wasmtime bug?

@alexcrichton
Copy link
Member

Ah I just answered a related issue about that, namely that this repository hosts a work-in-progress implementation which will move upstream to Wasmtime eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants