Stream: wasmtime

Topic: Using "classic" imports in components


view this post on Zulip Antoine Lavandier (Sep 26 2025 at 11:56):

I'm using no-std and the component model and right now component-model-async requires std but the async feature doesn't. Also Component::LinkerInstance::func_wrap_async only requires the asyncfeature. So my idea to put some async functionality was to:

view this post on Zulip Alex Crichton (Sep 26 2025 at 19:45):

Can you describe more what you're trying to do? Without an error message or a reproduction it's tough to reach a conclusion such as "yeah this isn't supported" vs "oh just tweak this that's a minor configuration error" or anything inbetween

view this post on Zulip Antoine Lavandier (Sep 29 2025 at 07:54):

Basically, I was trying to turn this kind of (rust) file into a component:

// imports
wit_bindgen::generate("world");

// implement Guest Trait etc...

#[link(wasm_import_module = "foo")]
unsafe extern "C" {
  fn bar();
}

The reason why I'm trying to do this is to manually bind "[foo]bar" using component::Linker::func_wrap_aysnc to circumvent using the component-model-async feature.

In any case, compiling such a file to Wasm works but running wasm-tools component new fails with

Caused by:
    0: failed to decode world from module
    1: module was not valid
    2: failed to resolve import `foo::bar`
    3: module requires an import interface named `foo`

view this post on Zulip Till Schneidereit (Sep 29 2025 at 10:52):

The component model doesn't support importing/exporting core wasm functions: you have to wrap the function in a component export instead.

I'm not sure I entirely follow what you're trying to do wrt async, but note that you can in principle generate C bindings for your interface and then implement them in largely the same way you're trying to use core wasm functions here


Last updated: Dec 06 2025 at 06:05 UTC