guest271314 opened issue #5621:
$ ./wasmtime hello.wat Error: failed to run main module `hello.wat` Caused by: 0: failed to instantiate "hello.wat" 1: unknown import: `::hello` has not been defined
bjorn3 commented on issue #5621:
hello.wat
imports a function calledhello
which it then calls. You need to pass in a definition for this import when instantiating the wasm module. This is something that can only be done from the wasmtime api, not the wasmtime cli. See https://github.com/bytecodealliance/wasmtime/blob/c9bc0efef559865fb0c8dc48c757b0a6d969b517/examples/hello.rs#L51-L52 The wasmtime cli is mostly useful for running WASI programs, whichhello.wat
is not. For a wasi example you can run using the wasmtime cli see examples/wasi/wasm/wasi.rs.
guest271314 commented on issue #5621:
So I can run heelo.rs directly with
wasmtime
? It would be helpful if the distinction was clear exactly whatwasmtime
can run and what it can't out of the box re WASI/WASM.I was testing
wasmedge
earlier substituted forwasmtime
and it does not run a Native Messaging host out of the box, the host exits. Is that based on the same constraints?
guest271314 commented on issue #5621:
This is something that can only be done from the wasmtime api, not the wasmtime cli.
What is the difference?
How is a novice in WebAssembly supposed to know there is a difference between wasmtime _api_ and wasmtime _cli_, or that they are two different animals that exist under the name wasmtime by reading README?
bjorn3 commented on issue #5621:
So I can run heelo.rs directly with wasmtime?
Not when using the wasmtime cli.
I was testing wasmedge earlier substituted for wasmtime and it does not run a Native Messaging host out of the box, the host exits. Is that based on the same constraints?
I'm not familiar with wasmedge so I have no clue why that doesn't work.
What is the difference?
The wasmtime api is what you would call when using wasmtime as library. The wasmtime cli is a commandline interface built on top of the wasmtime api. It is less flexible, but more convenient if your wasm module fits within the basic shape it expects (a wasi program that doesn't require any non-wasi imports)
guest271314 commented on issue #5621:
The wasmtime api is what you would call when using wasmtime as library. The wasmtime cli is a commandline interface built on top of the wasmtime api. It is less flexible, but more convenient if your wasm module fits within the basic shape it expects (a wasi program that doesn't require any non-wasi imports)
I am not gathering what is going on. I expected
wasmtime
to just work. I didn't know there was two entirely differentwasmtime
programs emanting from this single repository. I'll close this.
guest271314 closed issue #5621:
$ ./wasmtime hello.wat Error: failed to run main module `hello.wat` Caused by: 0: failed to instantiate "hello.wat" 1: unknown import: `::hello` has not been defined
Last updated: Nov 22 2024 at 16:03 UTC