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

wit-bindgen bindings for renamed interface #5961

Closed
sunfishcode opened this issue Mar 8, 2023 · 4 comments · Fixed by #5968
Closed

wit-bindgen bindings for renamed interface #5961

sunfishcode opened this issue Mar 8, 2023 · 4 comments · Fixed by #5968

Comments

@sunfishcode
Copy link
Member

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.

@sunfishcode
Copy link
Member Author

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.

sunfishcode added a commit to bytecodealliance/preview2-prototyping that referenced this issue Mar 8, 2023
This updates to the latest wasi-filesystem, wasi-sockets, wasi-io, and
wasi-cli wit changes, except for one thing: `filesystem.types` is still
named `filesystem.filesystem` to work around bytecodealliance/wasmtime#5961.
sunfishcode added a commit to bytecodealliance/preview2-prototyping that referenced this issue Mar 8, 2023
This updates to the latest wasi-filesystem, wasi-sockets, wasi-io, and
wasi-cli wit changes, except for one thing: `filesystem.types` is still
named `filesystem.filesystem` to work around bytecodealliance/wasmtime#5961.
sunfishcode added a commit to bytecodealliance/preview2-prototyping that referenced this issue Mar 8, 2023
This updates to the latest wasi-filesystem, wasi-sockets, wasi-io, and
wasi-cli wit changes, except for two things:
 - `filesystem.types` is temporarily still named `filesystem.filesystem`, to
    work around bytecodealliance/wasmtime#5961
 - wasi-stderr is temporarily still present, for debugging
sunfishcode added a commit to bytecodealliance/preview2-prototyping that referenced this issue Mar 8, 2023
This updates to the latest wasi-filesystem, wasi-sockets, wasi-io, and
wasi-cli wit changes, except for two things:
 - `filesystem.types` is temporarily still named `filesystem.filesystem`, to
    work around bytecodealliance/wasmtime#5961
 - wasi-stderr is temporarily still present, for debugging
@alexcrichton
Copy link
Member

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?

@sunfishcode
Copy link
Member Author

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.

alexcrichton added a commit to alexcrichton/wasmtime that referenced this issue Mar 8, 2023
This follows the same strategy pioneered by the `wit-bindgen` guest Rust
bindgen which keeps track of the latest name of an interface for how to
refer to an interface.

Closes bytecodealliance#5961
alexcrichton added a commit to alexcrichton/wasmtime that referenced this issue Mar 8, 2023
This follows the same strategy pioneered by the `wit-bindgen` guest Rust
bindgen which keeps track of the latest name of an interface for how to
refer to an interface.

Closes bytecodealliance#5961
@alexcrichton
Copy link
Member

Oh no worries, just wanted to confirm! I think #5968 should fix this

alexcrichton added a commit that referenced this issue Mar 8, 2023
This follows the same strategy pioneered by the `wit-bindgen` guest Rust
bindgen which keeps track of the latest name of an interface for how to
refer to an interface.

Closes #5961
pchickey pushed a commit to pchickey/wasmtime that referenced this issue May 12, 2023
This updates to the latest wasi-filesystem, wasi-sockets, wasi-io, and
wasi-cli wit changes, except for two things:
 - `filesystem.types` is temporarily still named `filesystem.filesystem`, to
    work around bytecodealliance#5961
 - wasi-stderr is temporarily still present, for debugging
pchickey pushed a commit to pchickey/wasmtime that referenced this issue May 16, 2023
This updates to the latest wasi-filesystem, wasi-sockets, wasi-io, and
wasi-cli wit changes, except for two things:
 - `filesystem.types` is temporarily still named `filesystem.filesystem`, to
    work around bytecodealliance#5961
 - wasi-stderr is temporarily still present, for debugging
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

Successfully merging a pull request may close this issue.

2 participants