Stream: wit-bindgen

Topic: Error "module is only allowed to import functions"


view this post on Zulip Scott Waye (May 20 2023 at 14:43):

What does this mean from wasm-tools component new, I thought one component would export and another import?

PS C:\github\cswasi> wasm-tools component new .\bin\Debug\net8.0\wasi-wasm\native\cswasi.wasm -o my-component-cs.wasm  --adapt wasi_snapshot_preview1=c:\github\rustimpl\rustimpl\wasi_preview1_component_adapter.reactor.wasm
error: failed to encode a component from module

Caused by:
    0: module is only allowed to import functions

view this post on Zulip Scott Waye (May 20 2023 at 16:26):

I guess I might be confused about how to do this. With witx-bindgen it was possible to create a rust module and a c# module and link them together to run in wasmtime, with the c# module calling a function from the rust module. Is this not possible with wasm-tools components?

view this post on Zulip Alex Crichton (May 22 2023 at 14:32):

The component new command works on a pretty specific shape of module and is not reflective of the component model at large. You can create components via other means, we just don't have the tooling to do so at this time. The situation you are describing is possible with the component model

view this post on Zulip Scott Waye (May 22 2023 at 14:52):

Alex Crichton said:

via other means

Thanks, is there any documentation about what these are?

view this post on Zulip Alex Crichton (May 22 2023 at 14:53):

Sorry I don't mean to imply there are tools that are missing. The component model can express what you're talking about, but I'm not aware of tooling that you can pull off the shelf to use for this. You'd have to write your own tool, perhaps using a library like wasm-encoder, which would create the compoennt.

view this post on Zulip Scott Waye (May 22 2023 at 15:04):

I see, so the tooling right now is focused on imports from the host, i.e. a WASI host?

view this post on Zulip Scott Waye (May 22 2023 at 15:07):

I guess I'm a little confused about how the wit-bindgen tests (e.g. https://github.com/bytecodealliance/wit-bindgen/blob/main/tests/codegen/floats.wit) work, are they using wasm-encoder?

A language binding generator for WebAssembly interface types - wit-bindgen/floats.wit at main · bytecodealliance/wit-bindgen

Last updated: Dec 23 2024 at 13:07 UTC