Stream: cargo-component

Topic: How to omit unused WASI interfaces from artifact?


view this post on Zulip Bobby Calderwood (Nov 28 2023 at 22:49):

I'm likely missing something obvious, but I'm trying to switch from wasm-bindgen to using cargo-component to build from my WIT definitions. I'm targeting the browser (via jco), so I don't need any of the default WASI stuff (clocks, cli, random, i/o, etc.), but I can't figure out how to configure cargo-component to omit those unused WASI bits. None of my WIT interfaces import any wasi stuff, so I just assume it's included in every component, but is there a way to avoid this and just use the component model minus WASI via cargo-component?

view this post on Zulip Joel Dice (Nov 28 2023 at 23:01):

https://github.com/bytecodealliance/WASI-Virt will help you with that.

Virtual implementations of WASI APIs. Contribute to bytecodealliance/WASI-Virt development by creating an account on GitHub.

view this post on Zulip Peter Huene (Nov 28 2023 at 23:04):

Additionally, you can pass --target wasm32-unknown-unknown to cargo component build to omit WASI imports from the generated component

view this post on Zulip Bobby Calderwood (Nov 28 2023 at 23:37):

Thanks Joel and Peter! I tried playing around with wasm32-unknown-unknown, but I'll give that another try. I'll also look into the Virtual Implementations.

view this post on Zulip Bobby Calderwood (Nov 29 2023 at 02:40):

Joel Dice said:

https://github.com/bytecodealliance/WASI-Virt will help you with that.

Can these virtual interfaces be used as an adapter?

view this post on Zulip Joel Dice (Nov 29 2023 at 02:51):

No, it can't be used as a replacement for the wasi_snapshot_preview1.wasm adapter, if that's what you mean. It works at the component level to virtualize Preview 2 interfaces, so the adapter it uses doesn't have the shape that wit-component (on which cargo-component is based) expects adapters to have.


Last updated: Nov 25 2024 at 19:03 UTC