kellytk opened issue #7536:
$ git repo
commit 321294a5d21f7006a959ba378ebd32782a76d3d2
...$ wasmtime --version
wasmtime-cli 16.0.0crates/test-programs$ cargo build --target=wasm32-wasi
$ wasmtime preview2_ip_name_lookup.wasm
Error: failed to run main modulepreview2_ip_name_lookup.wasm
Caused by:
0: failed to instantiate "preview2_ip_name_lookup.wasm"
1: unknown import:wasi:sockets/network@0.2.0-rc-2023-11-10::[resource-drop]network
has not been definedHow can this error be resolved?
kellytk edited issue #7536:
$ git log
commit 321294a5d21f7006a959ba378ebd32782a76d3d2
...$ wasmtime --version
wasmtime-cli 16.0.0crates/test-programs$ cargo build --target=wasm32-wasi
$ wasmtime preview2_ip_name_lookup.wasm
Error: failed to run main modulepreview2_ip_name_lookup.wasm
Caused by:
0: failed to instantiate "preview2_ip_name_lookup.wasm"
1: unknown import:wasi:sockets/network@0.2.0-rc-2023-11-10::[resource-drop]network
has not been definedHow can this error be resolved?
kellytk edited issue #7536:
$ git log
commit 321294a5d21f7006a959ba378ebd32782a76d3d2
...$ wasmtime --version
wasmtime-cli 16.0.0crates/test-programs$ cargo build --target=wasm32-wasi
$ wasmtime preview2_ip_name_lookup.wasm
Error: failed to run main module `preview2_ip_name_lookup.wasm` Caused by: 0: failed to instantiate "preview2_ip_name_lookup.wasm" 1: unknown import: `wasi:sockets/network@0.2.0-rc-2023-11-10::[resource-drop]network` has not been defined
How can this error be resolved?
alexcrichton commented on issue #7536:
Thanks for the report! I think this indicates that you're running a WebAssembly core module which was intended to become a component directly as a core module instead of a component. There is no specification for the API that you listed at this time, meaning that youre program cannot be run directly. Instead you'll need to run
wasm-tools component new
to produce a component which can then be run inside of Wasmtime.
kellytk commented on issue #7536:
Thank you for such a prompt reply. The code I'm attempting to run is located at https://github.com/bytecodealliance/wasmtime/blob/main/crates/test-programs/src/bin/preview2_ip_name_lookup.rs. Is the workflow for using
wasm-tools
through to running the program documented somewhere? I would think code within thewasmtime
repo would all be easily runnable.
kellytk commented on issue #7536:
I don't know if this is what you're referring to, however
wasm-tools component new preview2_ip_name_lookup.wasm -o out.wasm
(from https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wit-component#cli-usage) generates:error: failed to encode a component from module Caused by: 0: module requires an import interface named `wasi_snapshot_preview1`
alexcrichton commented on issue #7536:
Unfortunately no it's not currently documented, but you'll need to pass an
--adapt
argument to thewasm-tools
command which points to a preview1-to-preview2 adapter. Those can be found in Wasmtime releases for example
kellytk commented on issue #7536:
Ok, I'll do something to improve that.
Is
wasm-tools component new preview2_ip_name_lookup.wasm -o out.wasm --adapt ~/wasi_snapshot_preview1.command.wasm
correct? If so, it runs with apparently no output.
alexcrichton commented on issue #7536:
That should produce an
out.wasm
component file. You can inspect it withwasm-tools component wit out.wasm
for example.
kellytk commented on issue #7536:
Haha, right, pardon me.
$ wasm-tools component wit out.wasm
package root:component; world root { import wasi:io/poll@0.2.0-rc-2023-11-10; import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10; import wasi:sockets/network@0.2.0-rc-2023-11-10; import wasi:sockets/instance-network@0.2.0-rc-2023-11-10; import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-10; import wasi:io/streams@0.2.0-rc-2023-10-18; import wasi:filesystem/types@0.2.0-rc-2023-10-18; import wasi:filesystem/preopens@0.2.0-rc-2023-10-18; import wasi:sockets/tcp@0.2.0-rc-2023-10-18; import wasi:cli/environment@0.2.0-rc-2023-10-18; import wasi:cli/exit@0.2.0-rc-2023-10-18; import wasi:cli/stdin@0.2.0-rc-2023-10-18; import wasi:cli/stdout@0.2.0-rc-2023-10-18; import wasi:cli/stderr@0.2.0-rc-2023-10-18; import wasi:cli/terminal-input@0.2.0-rc-2023-10-18; import wasi:cli/terminal-output@0.2.0-rc-2023-10-18; import wasi:cli/terminal-stdin@0.2.0-rc-2023-10-18; import wasi:cli/terminal-stdout@0.2.0-rc-2023-10-18; import wasi:cli/terminal-stderr@0.2.0-rc-2023-10-18; export wasi:cli/run@0.2.0-rc-2023-10-18; }
$ wasmtime out.wasm
Error: cannot execute a component without `--wasm component-model`
$ wasmtime --wasm component-model out.wasm
Error: failed to run main module `out.wasm` Caused by: 0: import `wasi:io/streams@0.2.0-rc-2023-10-18` has the wrong type 1: instance export `output-stream` has the wrong type 2: expected resource found nothing
pchickey commented on issue #7536:
If you are using wasmtime-cli from source, it has a newer version of those interfaces than the ones you have built with that adapter, so make sure you use a wasmtime-cli from the same release as the adapter, or build the adapter from source.
These problems will go away once we ship preview 2 and have stable versions across wasmtime releases, we are almost there.
pchickey edited a comment on issue #7536:
If you are using wasmtime-cli from source, it has a newer version of those interfaces than the ones you have built with that adapter, so make sure you use a wasmtime-cli from the same release as the adapter, or build the adapter from source.
These problems will go away once we ship preview 2 and have stable interface versions across wasmtime releases, we are almost there.
kellytk commented on issue #7536:
Thank you both for enduring the overhead while the ecosystem is so green.
Is the process for building adapters from source documented? I have the wasmtime repo cloned and have built wasmtime from it.
These problems will go away once we ship preview 2 and have stable interface versions across wasmtime releases, we are almost there.
Is an up-to-date schedule for such milestones published?
alexcrichton commented on issue #7536:
We're working on getting all these things documented but one thing I'll point out is that when everything is in flux there's not always great documentation. I'd recommend reading a bit into how things work in this repository while we're working on stabilizing everything. The source-of-truth for example about building the adapter is our GitHub Actions configuration which would point you to this script.
Additionally for schedules and milestones and such we do not have a concrete set of documentation to point you towards at this time. Much of this depends on the stabilization of WASI itself which is moving through the standards process. It's intended that by the end of the year WASI has stabilized.
alexcrichton edited a comment on issue #7536:
We're working on getting all these things documented but one thing I'll point out is that when everything is in flux there's not always great documentation. I'd recommend reading a bit into how things work in this repository while we're working on stabilizing everything. The source-of-truth for example about building the adapter is our GitHub Actions configuration which would point you to this script.
Additionally for schedules and milestones and such we do not have a concrete set of documentation to point you towards at this time. Much of this depends on the stabilization of WASI itself which is moving through the standards process. It's intended that by the end of the year WASI has a more stable 0.2.0 release.
kellytk closed issue #7536:
$ git log
commit 321294a5d21f7006a959ba378ebd32782a76d3d2
...$ wasmtime --version
wasmtime-cli 16.0.0crates/test-programs$ cargo build --target=wasm32-wasi
$ wasmtime preview2_ip_name_lookup.wasm
Error: failed to run main module `preview2_ip_name_lookup.wasm` Caused by: 0: failed to instantiate "preview2_ip_name_lookup.wasm" 1: unknown import: `wasi:sockets/network@0.2.0-rc-2023-11-10::[resource-drop]network` has not been defined
How can this error be resolved?
Last updated: Dec 23 2024 at 13:07 UTC