hyperlight-dev / hyperlight-dev/hyperlight-wasm

Interface with an overlapping name used internally will cause build error

Open
#72 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

lifecycle/confirmed
Dominant language
Rust
Stars
728
Forks
39
Avg merge
2d 6h
Merged PRs (30d)
23

Description

If you have a wit file with:

package wasi-sample:example;

world example {
  import host;
  export adder;
}

interface adder {
  add: func(left: u32, right: u32) -> u32;
  call-host-function: func(input: string);
}

interface host {
  host-function: func(input: string) -> string;
}

you will end up with errors

 Compiling hyperlight-wasm v0.1.0 (/home/jstur/projects/hyperlight-wasm/src/hyperlight_wasm)
error: failed to run custom build command for `hyperlight-wasm v0.1.0 (/home/jstur/projects/hyperlight-wasm/src/hyperlight_wasm)`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/home/jstur/projects/hyperlight-wasm/target/debug/build/hyperlight-wasm-f9324c725c3b4d6a/build-script-build` (exit status: 101)
  --- stdout
  cargo::rerun-if-changed=/home/jstur/projects/hyperlight-wasm/src/wasm_runtime
  cargo::rerun-if-env-changed=WIT_WORLD

....

 warning: unused import: `hyperlight_guest_bin::host_comm::call_host_function`
    --> src/component.rs:31:5
     |
  31 | use hyperlight_guest_bin::host_comm::call_host_function;
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: `#[warn(unused_imports)]` on by default

  error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied
    --> src/component.rs:41:1
     |
  41 | hyperlight_wasm_macro::wasm_guest_bindgen!();
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 0 generic arguments
     |
  note: function defined here, with 0 generic parameters
    --> src/component.rs:41:1
     |
  41 | hyperlight_wasm_macro::wasm_guest_bindgen!();
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     = note: this error originates in the macro `hyperlight_wasm_macro::wasm_guest_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)

  error[E0061]: this function takes 1 argument but 3 arguments were supplied
    --> src/component.rs:41:1
     |
  41 | hyperlight_wasm_macro::wasm_guest_bindgen!();
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     | |
     | expected `&FunctionCall`, found `&str`
     | unexpected argument #2 of type `core::option::Option<Vec<ParameterValue>>`
     | unexpected argument #3 of type `ReturnType`
     |
     = note: expected reference `&FunctionCall`
                found reference `&'static str`
  note: function defined here
    --> src/component.rs:41:1
     |
  41 | hyperlight_wasm_macro::wasm_guest_bindgen!();
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     = note: this error originates in the macro `hyperlight_wasm_macro::wasm_guest_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)

looks like this might be caused because the relative call here:

https://github.com/hyperlight-dev/hyperlight-wasm/blob/40ef9e38821fa296bac9d2fdca4ce168c410a388/src/hyperlight_wasm_macro/src/wasmguest.rs#L90

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the build with the WIT example and inspect src/hyperlight_wasm_macro/src/wasmguest.rs around line 90, then trace the generated use from src/component.rs. Confirm how the overlapping interface name changes generated calls, and verify that the example builds without the reported E0107 and E0061 errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.