Stream: wasi

Topic: HELP: entrypoint of world


view this post on Zulip Emiel Van Severen (Jul 18 2023 at 10:23):

Hi,

I'm trying to get a simple preview2 example to work. I have a simple world that imports a few custom things and has a single exported run function. When executing:wasm-tools component new ./target/wasm32-wasi/debug/guest.wasm -o guest.component.wasm --adapt wasi_snapshot_preview1=./wasi_snapshot_preview1.command.wasm

it gives me the following error: duplicate export found for interface run
I can't seem to figure out what the exported function / entrypoint should be called in a world?

view this post on Zulip Karel Hrkal (kajacx) (Jul 18 2023 at 10:36):

How does your wit world look like? And also, how do you want to run your plugin, from wasmtime rust, or from wasmtime cli?

view this post on Zulip Emiel Van Severen (Jul 18 2023 at 10:42):

world: `package example:gpio

world my-world {
import types
export run: func() -> result
}`

from wasmtime rust

view this post on Zulip Karel Hrkal (kajacx) (Jul 18 2023 at 13:39):

In that case, you can take a look at how things are done in this example repo, although I have not used that solution myself.

I got a solution working using cargo component for the plugin, the code can be seen here. Look at the plugin-wasi and runtime-rust-wasmtime folders for a full example.

Other than that, I cannot say what is wrong with your setup without seeing the entirety of it.

Contribute to DougAnderson444/wit-wasm development by creating an account on GitHub.
A Cargo subcommand for creating WebAssembly components based on the component model proposal. - GitHub - bytecodealliance/cargo-component: A Cargo subcommand for creating WebAssembly components bas...
Various projects related to WASM, each in it's own branch, so that I don't have 50 repositories. - GitHub - kajacx/wasm-playground at wit-bindgen-wasi-MVP

view this post on Zulip Robin Brown (Jul 18 2023 at 15:10):

FYI, we just call what you keep referring to as "plugins" as "guest code" or "guests" officially and in docs. Whether a given guest is a plugin, extension, application, etc. depends on how that guest component is designed to be used and is used in practice.

You're obviously welcome to refer to your own components and guests however you like, but it's a bit confusing when you ask "how do you want to run your plugin" to people just talking about components generally.

view this post on Zulip Pat Hickey (Jul 18 2023 at 17:30):

the command adapter is just for programs that are CLI style and use _start (which initialize guest libc and then call the user's main). if you are creating your own world, use the reactor adapter

view this post on Zulip Emiel Van Severen (Jul 18 2023 at 19:52):

If I use the reactor (with the command I used in my previous message) i get the following error: component-type version 2 does not match supported version 3. I am using wit-bindgen 0.9.0 and wasm-tools 1.0.36.

view this post on Zulip Emiel Van Severen (Jul 18 2023 at 20:16):

The reactor is from wasmtime release 10.0.1

view this post on Zulip Emiel Van Severen (Jul 18 2023 at 20:25):

Apparently the reactor of wasmtime 10.0.1 is too old.. Used the reactor of wasm-tools (https://github.com/bytecodealliance/wasmtime/releases/tag/dev)

A fast and secure runtime for WebAssembly. Contribute to bytecodealliance/wasmtime development by creating an account on GitHub.

Last updated: Oct 23 2024 at 20:03 UTC