Stream: general

Topic: wasmtime WASI example / docs


view this post on Zulip 很酷的傢伙 (Feb 14 2024 at 04:59):

Hey! trying to get into WASM / WASI and using wasmtime. I've been looking through the docs / examples, and some of them seem to reference modules that seemingly no longer exist (e.g. wasi_common::sync). Am I missing something or are there new docs somewhere that I should be referring to?

view this post on Zulip Pat Hickey (Feb 14 2024 at 06:46):

if you just cloned main today, functionality that used to be exposed at wasmtime_wasi::sync::{WasiCtxBuilder, add_to_linker} is now provided underneath wasi_common::sync as part of separating our legacy wasi 0.1 only implementation (wasi-common) and our new wasi 0.2 & 0.1 implementation, presently at wasmtime_wasi::preview2

view this post on Zulip Pat Hickey (Feb 14 2024 at 06:47):

so, if you are seeing docs that point to wasi_common::sync, those are based off main as of the last two days, but the latest published version (wasmtime 17) still has that code at its previous home in wasmtime_wasi::sync.

view this post on Zulip Pat Hickey (Feb 14 2024 at 06:49):

when wasmtime 18 is released in a week, it will have that legacy wasi 0.1-only functionality exposed at both paths, with a deprecation warning on wasmtime-wasi's. in wasmtime 19 the legacy code will no longer be available through wasmtime-wasi, but the new implementation (wasmtime_wasi::preview2) will be exposed at the root of the wasmtime_wasi crate (dropping the ::preview2)

view this post on Zulip 很酷的傢伙 (Feb 14 2024 at 17:57):

I see. Would you say the recommendation is to use the new wasi 0.2 stuff? and are there any examples or breaking changes I should be aware of when working with wasi 0.2 and wasmtime?

view this post on Zulip Pat Hickey (Feb 14 2024 at 18:04):

yes, the recommendation is to use the implementation that ships in wasmtime 17 and 18 as wasmtime_wasi::preview2, and will be promoted to wasmtime_wasi in 19. it supports wasi 0.2 as well as 0.1. the api is a little different than wasi-common, specifically it doesnt provide the WasiFile and WasiDir traits if you were using those to implement something, if you dont even know what those are then please dont worry about it

view this post on Zulip 很酷的傢伙 (Feb 14 2024 at 18:04):

awesome, thanks for the pointers!

view this post on Zulip Pat Hickey (Feb 14 2024 at 18:05):

but we believe the new implementation is production ready, its been the default in wasmtime cli for a month or two now, we have gotten some relatively minor bug reports (thanks @Brett Cannon !) that we have fixed, and we haven't heard of any major regressions.

view this post on Zulip Pat Hickey (Feb 14 2024 at 18:08):

after we land the migration of wasmtime_wasi::preview2 to the root of that crate, i'm going to go through all of the remaining integration points (bench tests, c api, and one or two other spots) and various example code, and switch them to use that instead of wasi-common. so, you may see gaps in the documentation and stuff, please flag those to me and i'll get them fixed!

view this post on Zulip Brett Cannon (Feb 14 2024 at 21:09):

Pat Hickey said:

but we believe the new implementation is production ready, its been the default in wasmtime cli for a month or two now, we have gotten some relatively minor bug reports (thanks Brett Cannon !) that we have fixed, and we haven't heard of any major regressions.

First, you're quite welcome on the bug reports! Thanks to the team for fixing them so quickly!

Second, to be explicit as to the bugs/incompatibilities that I've found via CPython's test suite, https://github.com/bytecodealliance/wasmtime/issues/7829 is fixed but not in a released version yet (I assume the issue will be closed at release time). The known compatibility difference I've found is https://github.com/bytecodealliance/wasmtime/issues/7830 and it's a bit esoteric. Everything else has been fixed since wasmtime 17.

Test Case TODO: upload Wasm file here Steps to Reproduce https://github.com/python/cpython/blob/07236f5b39a2e534cf190cd4f7c73300d209520b/Lib/test/test_posix.py#L452-L454 Expected Results Test shoul...
Test Case TODO: upload Wasm file here Steps to Reproduce https://github.com/python/cpython/blob/07236f5b39a2e534cf190cd4f7c73300d209520b/Lib/test/test_posix.py#L520-L525 https://github.com/python/c...

view this post on Zulip Pat Hickey (Feb 14 2024 at 21:14):

yes 7829 is going out in release 18, the fix landed in main and the release-18 branch. we chose not to do a 17 patch release for it because it didnt seem pressing, but we still could if someone really needed it.

view this post on Zulip Ralph (Feb 14 2024 at 22:24):

Perfect. We will set up some work on 18.


Last updated: Nov 22 2024 at 17:03 UTC