Stream: git-wasmtime

Topic: wasmtime / issue #5961 wit-bindgen bindings for renamed i...


view this post on Zulip Wasmtime GitHub notifications bot (Mar 08 2023 at 00:14):

sunfishcode opened issue #5961:

This wit:

interface red {
  use self.green.{thing}

  foo: func() -> thing
}

interface green {
  type thing = s32
}

default world neptune {
  import blue: self.red
  import orange: self.green
}

with this Rust:

wasmtime::component::bindgen!({
   path: "test.wit",
});

fn main() {}

gets this error:

error[E0433]: failed to resolve: could not find `green` in the crate root
 --> src/main.rs:1:1
  |
1 | / wasmtime::component::bindgen!({
2 | |    path: "a.wit",
3 | | });
  | |__^ could not find `green` in the crate root
  |

It appears the bindgen-generated bindings for the neptune world use the original name of the interface green rather than the world's name orange.

For comparison, the wit-bindgen guest bindings do appear to use the orange name.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 08 2023 at 00:32):

sunfishcode commented on issue #5961:

The cargo expand code has

pub mod orange {
   ...
}
pub mod blue {
    ...
    pub type Thing = super::green::Thing;
    ...
}

That reference to green should be renamed to a reference to orange.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 08 2023 at 15:49):

alexcrichton commented on issue #5961:

I think this would be reasonable enough to fix as-is, but I'll also take the opportunity to ask, would you expect something different to be generated here? For example do you think that mod orange should be called mod green? Or do you think it's reasonable to rename the green interface to orange because of the worlds exports/imports?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 08 2023 at 16:51):

sunfishcode commented on issue #5961:

Ah, I think I misspoke above. I'd expect it to have mod orange and reference orange, because the bindings are generated for a world, and not for interfaces in isolation. Inside the world here, the name is orange, so it should be orange in the bindings.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 08 2023 at 22:33):

alexcrichton commented on issue #5961:

Oh no worries, just wanted to confirm! I think https://github.com/bytecodealliance/wasmtime/pull/5968 should fix this

view this post on Zulip Wasmtime GitHub notifications bot (Mar 08 2023 at 23:50):

alexcrichton closed issue #5961:

This wit:

interface red {
  use self.green.{thing}

  foo: func() -> thing
}

interface green {
  type thing = s32
}

default world neptune {
  import blue: self.red
  import orange: self.green
}

with this Rust:

wasmtime::component::bindgen!({
   path: "test.wit",
});

fn main() {}

gets this error:

error[E0433]: failed to resolve: could not find `green` in the crate root
 --> src/main.rs:1:1
  |
1 | / wasmtime::component::bindgen!({
2 | |    path: "a.wit",
3 | | });
  | |__^ could not find `green` in the crate root
  |

It appears the bindgen-generated bindings for the neptune world use the original name of the interface green rather than the world's name orange.

For comparison, the wit-bindgen guest bindings do appear to use the orange name.


Last updated: Nov 22 2024 at 16:03 UTC