Stream: wit-bindgen

Topic: Re-exporting host exports from a component


view this post on Zulip Roman Volosatovs (Aug 29 2024 at 12:20):

Hey everyone!

I have sort of a niche use case, and I'm trying to build a component, which would essentially re-export the host exports (i.e. the component itself would export the wasi:cli/imports world etc.)

Unfortunately, I hit:

interface transitively depends on an interface in incompatible ways

in Rust bindgen version 0.30 with:

package repro:component@0.1.0;

world component {
    export wasi:io/poll@0.2.1;
    export wasi:http/types@0.2.1;
}

I've summed up by observations here: https://github.com/bytecodealliance/wit-bindgen/issues/1043 and added a repro here: https://github.com/rvolosatovs/wit-bindgen-export-bug-repro

Curious is anyone has an idea of what might be going wrong here and if there's some way to fix it apart from manually implementing exports in the component?

Looks like perhaps I'm hitting an instance of https://github.com/WebAssembly/component-model/issues/208 ?

Given following WIT: package repro:component@0.1.0; world component { export wasi:io/poll@0.2.1; export wasi:http/types@0.2.1; } And following lib.rs: mod bindings { use super::Component; wit_bindg...
Contribute to rvolosatovs/wit-bindgen-export-bug-repro development by creating an account on GitHub.
One of the subtelties of imports and exports in WIT is that they both need to somehow resolve their transitive dependencies. For example this world: package foo:bar interface foo { type t = u32 } i...

view this post on Zulip Roman Volosatovs (Aug 29 2024 at 12:35):

interestingly, this seems to work for wasi-virt: https://github.com/bytecodealliance/WASI-Virt/blob/c4512614d0bbe50044b93577099232c1701b06e2/wit/virt.wit#L5-L45 https://github.com/bytecodealliance/WASI-Virt/blob/c4512614d0bbe50044b93577099232c1701b06e2/virtual-adapter/src/lib.rs#L9-L13

:thinking:

Virtual implementations of WASI APIs. Contribute to bytecodealliance/WASI-Virt development by creating an account on GitHub.
Virtual implementations of WASI APIs. Contribute to bytecodealliance/WASI-Virt development by creating an account on GitHub.

view this post on Zulip Alex Crichton (Aug 29 2024 at 19:39):

The fix for this is to basically export more things. The problem is that the transitive dependencies of wasi:http/types are imported. What ends up happening though is that wasi:io/poll is both an import and an export in that case, but various types are wired up to the wrong places. What you're describing in theory could work but probably won't work the way you'd like it to.

view this post on Zulip Alex Crichton (Aug 29 2024 at 19:39):

In any case the interim solution is to export more interfaces so the transitive dependencies of wasi:http/types are all exports as opposed to becoming implicitly imports

view this post on Zulip Roman Volosatovs (Aug 30 2024 at 13:01):

Thanks! I'll try that out


Last updated: Nov 22 2024 at 16:03 UTC