Stream: git-wasmtime

Topic: wasmtime / issue #7505 preview1-component-adapter compone...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 08 2023 at 21:50):

AAP127 opened issue #7505:

I am trying to test making a wasm component using the steps in the wasi-preview1-component-adapter section, provided here. I tried the steps after downloading and renaming both a command and reactor file from the linked downloads.

I am able to create the component seemingly successfully, but then I attempt to run it with wasmtime 15 and get the following error:

Error: failed to run main module `component.wasm`

Caused by:
    0: import `wasi:io/streams@0.2.0-rc-2023-11-05` has the wrong type
    1: instance export `output-stream` has the wrong type
    2: expected resource found nothing

I was wondering what part in the process might be going wrong, or if I should be trying to run the component some other way. The end goal is to try and see if I test having modules communicate with each other, and I was thinking component model functions might help (i.e. exporting functions from one module to use in another). Any advice would be appreciated, thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 08 2023 at 22:01):

alexcrichton commented on issue #7505:

Can you confirm which Wasmtime version you're using? You're likely running up against a version mismatch between what the adapter wants and what the runtime is expecting. Here for example it seems like the adapter wants 0.2.0-rc-2023-11-05 which I think means that you're using the dev tag and its adapter. Wasmtime 15, which isn't released yet, implements this. Wasmtime 14, however, which is released, does not implement this version. Hence I want to confirm whether you're using Wasmtime 14 or 15.

If you're using Wasmtime 14 then you can download the adapters from here

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2023 at 09:10):

rkrishn7 commented on issue #7505:

Confirmed that this is occurring for me as well using Wasmtime 14 and the adapter from here.

When inspecting the wit interface for my component, all imports are using the following version: 0.2.0-rc-2023-10-18

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2023 at 09:11):

rkrishn7 edited a comment on issue #7505:

Confirmed that this is occurring for me as well using Wasmtime 14.0.4 and the adapter from here.

When inspecting the wit interface for my component, all imports are using the following version: 0.2.0-rc-2023-10-18

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2023 at 14:57):

alexcrichton commented on issue #7505:

Can you clarify the set of steps you're following to reproduce?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2023 at 17:01):

rkrishn7 commented on issue #7505:

@alexcrichton Sure! I created a repo here that contains the code/steps to reproduce.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2023 at 17:53):

alexcrichton commented on issue #7505:

Ah @rkrishn7 your example code doesn't link in WASI. The HelloWorld structure generated does not contain WASI in it but your component does. WASI comes in through the adapter. You'll want to call add_to_linker to pull in all the WASI functions.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2023 at 18:28):

rkrishn7 commented on issue #7505:

Ahh that makes sense. Working well now, thanks a bunch! I've pushed an updated commit showing how to correctly link to WASI here.

On a related note, do we think it might be a good idea to make a note of this in the example found here? While it doesn't show the implementation for the guest function, it could be a point of confusion when attempting to build & run the example.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2023 at 18:41):

alexcrichton commented on issue #7505:

Perhaps yeah! I'm not sure how best to handle that. For example the world in that snippet does not include WASI, so technically feeding in a component that uses WASI correctly reports an error (the error message can definitely be improved). So from a "what went wrong where" perspective the error is a big higher up than the example because either the world isn't correct or the component isn't correct. From a more practical perspective though almost all components will import WASI, so it would also make sense to showcase there. Hence me not being entirely sure how best to handle this.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2023 at 19:03):

rkrishn7 commented on issue #7505:

Yeah, that makes sense. I guess even if it's not fully incorporated into the example, it might be worth mentioning as a side note. Particularly, since wit_bindgen references the macro docs when mentioning host runtimes and the provided guest (Rust) example there calls for building using a target of wasm32-wasi.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2023 at 20:40):

AAP127 commented on issue #7505:

Sorry just to add in, I was using Wasmtime 15 when trying to run the component. $wt15 is the command I have setup to target wastmtime 15 as I previously had installed wasmtime 12, but I do use $wt15 when trying to run the component. Unsure if it is some dev build or similar:

$wt15 --version
wasmtime-cli 15.0.0

As for the steps, the link in the original issue was a small writeup at the bottom and I was directly copying each command after downloading and renaming either preview 1 adapter wasm file. Will try the example @rkrishn7 made and see the results of that. Just to clarify, is the issue faced here that the main rust code doesn't actually use wasi functions, or that it does not do some linking correctly? Am a bit unfamiliar with linking and all.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 13 2023 at 16:45):

alexcrichton commented on issue #7505:

@AAP127 where did you get Wasmtime 15 from? That isn't published yet so you probably have a particular commit, and that may not be the one inteneded for the adapter being used.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 01:57):

AAP127 commented on issue #7505:

I see. I tried looking back for where I would have found it but can't seem to. I will go ahead and try downloading/ updating to wasmtime 14 and running the code linked above. Would there be any specific procedures needed in terms of component adapters?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 15:54):

alexcrichton commented on issue #7505:

At this time the version of Wasmtime and the adapter must be the same. Effectively the two need to be built from the same source. If you use the release artifacts, for example, that guarantee will be provided.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 21:07):

AAP127 commented on issue #7505:

I see, so to clarify then, instead of using the dev version, I should instead make sure I update to wasmtime 14.x and use the accompanying adapter linked with the version number? Aka get the full version number version of the adapter from here and then ensure my wasmtime version matches whichever one I choose?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 22:19):

alexcrichton commented on issue #7505:

Yep that should work! As of right now the versions must all match. That won't be necessary in the future since we'll start having compatibility across versions but for the time being that's the way to go.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 15 2023 at 01:24):

AAP127 commented on issue #7505:

Got it thanks! Will try to use wasmtime 14 and adapter to see if i get better luck with that then,

view this post on Zulip Wasmtime GitHub notifications bot (Nov 29 2023 at 18:43):

AAP127 closed issue #7505:

I am trying to test making a wasm component using the steps in the wasi-preview1-component-adapter section, provided here. I tried the steps after downloading and renaming both a command and reactor file from the linked downloads.

I am able to create the component seemingly successfully, but then I attempt to run it with wasmtime 15 and get the following error:

Error: failed to run main module `component.wasm`

Caused by:
    0: import `wasi:io/streams@0.2.0-rc-2023-11-05` has the wrong type
    1: instance export `output-stream` has the wrong type
    2: expected resource found nothing

I was wondering what part in the process might be going wrong, or if I should be trying to run the component some other way. The end goal is to try and see if I test having modules communicate with each other, and I was thinking component model functions might help (i.e. exporting functions from one module to use in another). Any advice would be appreciated, thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 29 2023 at 18:43):

AAP127 commented on issue #7505:

I ended up using the new release of wasmtime 15 and the corresponding adapter and can now successfully run the component from the example code. Thanks everyone!

view this post on Zulip Wasmtime GitHub notifications bot (Dec 08 2023 at 17:38):

MendyBerger commented on issue #7505:

Where do I find what version of wasi I'm supposed to use with a specific version of wasmtime?


Last updated: Oct 23 2024 at 20:03 UTC