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

wasmtime_wasi::bindings compilation error for wasi:cli/exit and wasi:socket/network, missing LinkOptions parameter #10119

Closed
robherley opened this issue Jan 27, 2025 · 5 comments
Labels
bug Incorrect behavior in the current implementation that needs fixing

Comments

@robherley
Copy link

Test Case

I have a minimal repro in this repository: https://github.com/robherley/wasmtime-bindgen-repro

Steps to Reproduce

  1. Follow the example from wasmtime-wasi crate:
    //! with: {
    //! "wasi": wasmtime_wasi::bindings,
    //! },
  2. Attempt to compile.
  3. Error, need to cargo expand (see my expanded.rs) or add include_generated_code_from_file: true to the macro.

Expected Results

The generated binding have the correction function signatures.

Actual Results

Image

Versions and Environment

Wasmtime version or commit: 29.0.1

Operating system: macOS 15.1.1

Architecture: arm64

Extra Info

The only affected bindings are:

__with_name0::cli::exit::add_to_linker(linker, get)?;
__with_name0::sockets::network::add_to_linker(linker, get)?;

Which are missing &wasmtime_wasi::bindings::cli::exit::LinkOptions and &wasmtime_wasi::bindings::sockets::network::LinkOptions

@robherley robherley added the bug Incorrect behavior in the current implementation that needs fixing label Jan 27, 2025
@robherley
Copy link
Author

I'm guessing this is related to runtime feature-gated options:

Instead, the generated add_to_linker*** functions take an additional LinkOptions parameter if the world/interface has any unstable features.

@alexcrichton
Copy link
Member

Thanks for the report! I think the problem may lie in your original WIT files perhaps? Looking at https://github.com/robherley/wasmtime-bindgen-repro/blob/main/wit/deps/wasi-cli-0.2.3/package.wit I don't see exit-with-code which is a feature-gated API, which means that the two bindgens are starting from different WITs?

@robherley
Copy link
Author

👋 @alexcrichton Thanks for following up so fast! It does look like the wit does not match the bindings provided by wasmtime_wasi crate.

But, I resolved my .wit files from wkg:

Image

Which is odd, since the resolved version of wasi-cli-0.2.3 doesn't seem to have exit-with-code?

Even if I run:

wkg get wasi:[email protected]
cat [email protected] | grep exit-with-code

There is no reference to the @unstable(feature = cli-exit-with-code).

Is the version of wasi:cli on the registry incorrect? Or is there something else I'm misunderstanding

@alexcrichton
Copy link
Member

I think the issue might like with wkg yeah, there's some subtelties around handling WIT and features which might need some patching. Mind opening an issue over there and cc'ing me?

@robherley
Copy link
Author

Totally, I'll close this one out 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior in the current implementation that needs fixing
Projects
None yet
Development

No branches or pull requests

2 participants