Stream: wasi

Topic: why is WASI in wasmtime implemented using Yanix and Winx?


view this post on Zulip Emiliano Lesende (May 25 2020 at 14:38):

I'm in the process of implementing some WASI calls and noticed that calls are implemented using YANIX and WINX (which are low level C abstractions) rather than using the Rust std library. May I ask as to why this is the way it is? Is this because we want to compile WASM to native code without having to depend on the Rust std runtime?

view this post on Zulip Till Schneidereit (May 25 2020 at 15:42):

CC @Jakub Konka

view this post on Zulip Jakub Konka (May 25 2020 at 16:21):

Hey @Emiliano Lesende ! That's an excellent question! If you look closely, some of the syscalls use libstd directly; however, some of the more intricate calls (looking at path_* syscalls in particular), are an example of handle-oriented API which Rust libstd simply doesn't provide. Rust's libstd is predominantly path-oriented, much like all (?) libcs out there. Therefore, for those, it seemed appropriate to use POSIX equivalents directly on *nix such as fstatat as opposed to fstat for instance (the latter being bound to by libstd in appropriate calls). However, our Windows implementation still relies mainly on libstd which a few exceptions such as figuring out the file type, etc. I hope that makes sense. Lemme know if anything is unclear and I'll hopefully be able to shed some more light on! :-)

view this post on Zulip Jakub Konka (May 25 2020 at 16:24):

Oh, and to provide an even fuller context, we used to use nix crate on *nixes, but it was basically too big for our purposes, plus it was defining/binding stuff we simply would never support. Oh, and at the time of writing, it didn't really cross-compile to wasm32-unknown-emscripten, which is a bit of a pain. Hence, we decided we'd rather focus on a more tailored to our use case, in-house crate, hence yanix was born ;-)

view this post on Zulip Emiliano Lesende (May 25 2020 at 16:24):

@Jakub Konka Thanks for that detail answer. I guess I need some guidance here. I am in the process of implementing WASI equivalents for getaddrinfo, connect, setsockopt, etc. Basic outbound socket connections (no listen/bind yet). I am unsure as to if I should use Rust std or libc for them. Socket are handle oriented, so I am guessing I need to implement them in libc. getaddrinfo can be an exception here and could be implemented in Rust std I guess since it doesn't deal with handles at all.

view this post on Zulip Jakub Konka (May 25 2020 at 16:27):

Oh, right, gotcha! Uhm, so first of, I'll be more than happy to answer any questions, and provide any necessary guidance. Secondly, I'd start off with trying to offload as much to libstd as possible, and if we basically bump into a wall that needs some host-specific addressing, then we can add the necessary bindings to yanix/winx. Does that make sense?

view this post on Zulip Emiliano Lesende (May 25 2020 at 16:38):

@Jakub Konka Makes sense. Thanks again.

view this post on Zulip Jakub Konka (May 25 2020 at 16:39):

Sure thing! Fire away if something is still unclear or you'd like to discuss something!


Last updated: Nov 22 2024 at 16:03 UTC