Stream: wasmtime

Topic: wasmtime-cli: support run --invoke for components using wave


view this post on Zulip Timothy McCallum (Mar 29 2025 at 02:27):

I built wasmtime using a branch that implements wasmtime-cli support to --invoke an individual function (that resides in a Wasm component).

The steps I followed to use the wasmtime branch with the updates are below:

cd /Users/tpmccallum
git clone https://github.com/bytecodealliance/wasmtime.git
cd wasmtime
git checkout main
git pull origin main
git checkout pch/invoke_wave
git merge main
cargo clean
cargo build --release

Then the actual component, creation and execution steps I used are below (for your convenience). This is the Rust app structure:

tpmccallum %tree .
.
├── compress
    ├── Cargo.lock
    ├── Cargo.toml
    ├── src
       ├── bindings.rs // automatically generated by cargo component
       └── lib.rs
    └── wit
        └── compress.wit

This is the WIT:

package example:component;

world compress {
    export compress: func() -> list<u8>;
}

This is the Cargo.toml:

[package]
name = "compress"
version = "0.1.0"
edition = "2021"

[dependencies]
zstd = "0.13"
wit-bindgen-rt = { version = "0.39.0", features = ["bitflags"] }

[lib]
crate-type = ["cdylib"]

[package.metadata.component]
target = { path = "wit/compress.wit" }

This is the src/lib.rs:

#[allow(warnings)]
mod bindings;

use bindings::Guest;
use zstd::stream::encode_all;
use std::io::Cursor;

struct Component;

impl Guest for Component {
    fn compress() -> Vec<u8> {
        let input = "this is a data compression example".as_bytes();
        encode_all(Cursor::new(input), 5).unwrap()
    }
}

bindings::export!(Component with_types_in bindings);

I used cargo-build with wasip1 target:

The PR for this work/branch that I used is still in draft. Can this me moved along (out of draft) and into a testing phase then be merged? < https://github.com/bytecodealliance/wasmtime/pull/10054 >

view this post on Zulip Andrew Brown (Mar 31 2025 at 16:52):

@Pat Hickey, do you want to hand that PR off to @Timothy McCallum to fix a few remaining CI issues and try to get it merged? I can't remember if there was any opposition to using WAVE syntax but it always seemed reasonable to me.

view this post on Zulip Pat Hickey (Mar 31 2025 at 16:53):

It really just needs better error messages to be ready to land, and yes @Timothy McCallum if you want to make a PR targeting my branch that improves that, we can get it landed soon

view this post on Zulip Timothy McCallum (Apr 01 2025 at 03:59):

Sounds like a plan @Andrew Brown and @Pat Hickey
Chat soon

view this post on Zulip Timothy McCallum (Apr 01 2025 at 11:23):

Hi @Pat Hickey
Please note that I have updated the error message output for the --invoke feature and also updated the related documentation. More info here:

https://github.com/bytecodealliance/wasmtime/pull/10054#issuecomment-2768318470

I will look at the CI errors tomorrow.
Chat soon

We read every piece of feedback, and take your input very seriously.

view this post on Zulip Timothy McCallum (Apr 02 2025 at 08:35):

Hi @Pat Hickey and @Andrew Brown
Please note, I have an update on this --invoke work at https://github.com/bytecodealliance/wasmtime/pull/10511

@Alex Crichton I see that you have automatically been assigned as a reviewer :wave: :smile:
Super happy to do more on this topic (there are a couple of things to iron out in the PR). Will check back in tomorrow. Please feel free to hit me up for tasks relating to this one. Happy to help.
Chat soon
Tim

This PR is in relation to the Zulip conversation at #wasmtime > wasmtime-cli: support run --invoke for components using wave. This PR includes @pchickey's existing PR 10054. (Apologies @pchi...

view this post on Zulip Pat Hickey (Apr 04 2025 at 22:56):

thanks for bearing with me this week, i was traveling and in meetings nonstop. just got the PR ready for review sitting at the airport waiting to fly home

view this post on Zulip Alex Crichton (Apr 04 2025 at 22:58):

Oh you're fine lol

view this post on Zulip Alex Crichton (Apr 04 2025 at 22:59):

I've been chasing segfaults all week it seems...


Last updated: Apr 07 2025 at 05:03 UTC