Stream: wit-bindgen

Topic: wasm-compose


view this post on Zulip Bailey Hayes (Oct 07 2022 at 16:53):

This isn't strictly a wit-bindgen problem, but I think this is the closest stream for component model tools. I'm trying to get the example in wasm-compose working. I made the following updates: https://github.com/bytecodealliance/wasm-tools/compare/main...ricochet:wasm-tools:fix/wasm-compose-example

I can get the individual components to build now, but it's failing on the last step for running the composed service module in the server.

cargo run --release -- service.wasm
    Finished release [optimized] target(s) in 0.15s
     Running `target/release/host service.wasm`
Error: failed to parse WebAssembly module

Caused by:
    section size mismatch: unexpected data at the end of the section (at offset 0xd)
Low level tooling for WebAssembly in Rust. Contribute to bytecodealliance/wasm-tools development by creating an account on GitHub.

view this post on Zulip Bailey Hayes (Oct 07 2022 at 17:47):

service.wasm wat matches what I think I should expect for a composed component, e.g. high-level component with an instance of the backend and exports for all of the exported interfaces from the various

At one point there was a tool wasm-link whose output was a canonical ABI component. Is there a similar tool available today? The goal being that I could get a plain old wasm module that can run on runtimes that don't yet support the component model.

view this post on Zulip Alex Crichton (Oct 07 2022 at 18:01):

Peter's out til mid next-week and would probably know for sure, but I can try to help investigate soon if I get time.

Otherwise wasmlink has indeed been removed and replaced with various other tools ,but the replacement depends on what functionality you're looking for -- converting to a component is a wit-component job and linking components is wasm-compose

view this post on Zulip Alex Crichton (Oct 07 2022 at 18:36):

@Bailey Hayes I can pair for a bit if you'd like to help bottom this out

view this post on Zulip Bailey Hayes (Oct 07 2022 at 18:46):

I removed the rev pin on wasmtime and got further!

error[E0277]: the trait bound `std::result::Result<ServiceResponse, ServiceError>: ComponentNamedList` is not satisfied
   --> src/main.rs:157:14
    |
157 |             .get_typed_func::<(ServiceRequest,), ServiceResult, _>(&mut store, "execute")?;
    |              ^^^^^^^^^^^^^^ the trait `ComponentNamedList` is not implemented for `std::result::Result<ServiceResponse, ServiceError>`
    |
    = help: the following other types implement trait `ComponentNamedList`:
              ()
              (A1, A2)
              (A1, A2, A3)
              (A1, A2, A3, A4)
              (A1, A2, A3, A4, A5)
              (A1, A2, A3, A4, A5, A6)
              (A1, A2, A3, A4, A5, A6, A7)
              (A1, A2, A3, A4, A5, A6, A7, A8)
            and 9 others
note: required by a bound in `wasmtime::component::Instance::get_typed_func`
   --> /Users/bhayes/.cargo/git/checkouts/wasmtime-41807828cb3a7a7e/e45577e/crates/wasmtime/src/component/instance.rs:94:18
    |
94  |         Results: ComponentNamedList + Lift,
    |                  ^^^^^^^^^^^^^^^^^^ required by this bound in `wasmtime::component::Instance::get_typed_func`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `host` due to previous error

view this post on Zulip Alex Crichton (Oct 07 2022 at 18:49):

Oh change ServiceResult to (ServiceResult,) there

view this post on Zulip Bailey Hayes (Oct 07 2022 at 19:54):

Thank you @Alex Crichton ! Working example: https://github.com/bytecodealliance/wasm-tools/pull/794

Use wit-bindgen-guest-rust expected renamed to result Updated to latest wasmtime to get working server

Last updated: Nov 22 2024 at 16:03 UTC