-
Notifications
You must be signed in to change notification settings - Fork 231
Description
Hi everyone!
I'm not 100% sure if this is the right place to ask this question or if it maybe is a more of a rustc
problem.
In any case: I'm trying to generate a component that implements a certain interface and only that interface.
Consider this example:
wit_bindgen::generate!({
inline: r#"
package foo:bar;
world bar {
export baz : interface {
zero: func() -> u32;
}
}
"#
});
struct MyComponent;
impl crate::exports::baz::Guest for MyComponent {
fn zero() -> u32 {
0
}
}
export!(MyComponent);
Given this code, I would expect the wit
embedded in the resulting component to look similar to this
package root:component;
world root {
export baz: interface {
zero: func() -> u32;
}
}
Instead, wasm-tools component wit target/wasm32-wasip2/debug/super_simplest.wasm
outputs
package root:component;
world root {
import wasi:cli/environment@0.2.3;
import wasi:cli/exit@0.2.3;
import wasi:io/error@0.2.3;
import wasi:io/streams@0.2.3;
import wasi:cli/stdin@0.2.3;
import wasi:cli/stdout@0.2.3;
import wasi:cli/stderr@0.2.3;
import wasi:clocks/wall-clock@0.2.3;
import wasi:filesystem/types@0.2.3;
import wasi:filesystem/preopens@0.2.3;
export baz: interface {
zero: func() -> u32;
}
}
// + all package definitions of imported packages
My guess was that these imports are necessary to handle stuff like error messages on panic that the rust compiler might introduce. However, compiling while declaring the #![no_std]
(which I assumed to disable these things) at the top of lib.rs
does not help and the same wit
is embedded.
Is there a way to only generate the interface as specified?
I'm using wit-bindgen 0.42.1
, cargo/rustc 1.87.0-nightly
, and wasm-tools 1.219.1
.
Cheers,
Markus
P.S.: After writing this issue I tried everything out with the code mentioned here and have encountered the same problem.