Stream: wasi

Topic: wasi-libc/tools/wasi-headers


view this post on Zulip Pat Hickey (Jan 14 2020 at 18:44):

so, just before break my witx-test tool (a proptest generator for witx specs, plus a driver to use wasi-headers to generate a header and validate the header with clang) found some parts of the witx grammar that wasi-headers couldn't handle correctly

view this post on Zulip Pat Hickey (Jan 14 2020 at 18:45):

most of it is easy to fix, the tough part to crack is that the representation of witx arrays in C is tricky/inconstient

view this post on Zulip Pat Hickey (Jan 14 2020 at 18:46):

we currently don't have any way to deal with an array as a member of a struct, or a variant in a union

view this post on Zulip Pat Hickey (Jan 14 2020 at 18:49):

i think the correct way to deal with arrays in either of those cases is to define a struct array_$typename { $typename *ptr; size_t len; };

view this post on Zulip Pat Hickey (Jan 14 2020 at 18:50):

this is going to complicate the one-pass nature of the tool, but i dont think theres any other way to handle it correctly. does anyone have objections?

view this post on Zulip Pat Hickey (Jan 14 2020 at 18:53):

along those same lines - right now the wasi-headers tool hard codes its input files and output files. im going to extend the main to take an optional input and output path - if both are blank it will do what it does now, which is use the latest snapshot and output to the right spot in the libc. but in general i think its a pretty useful tool to use elsewhere

view this post on Zulip Dan Gohman (Jan 14 2020 at 18:55):

One option is just to return an error; WASI itself has no arrays inside of structs or unions

view this post on Zulip Pat Hickey (Jan 14 2020 at 18:56):

id argue that it already does have arrays inside structs, $iovec and $ciovec

view this post on Zulip Pat Hickey (Jan 14 2020 at 18:56):

which are a pair of pointer and len

view this post on Zulip Pat Hickey (Jan 14 2020 at 18:58):

those should be arrays, i think, in order to get rid of pointers in witx. i dont want to figure out how to get rid of pointers today, but i want to eventaully :)

view this post on Zulip Pat Hickey (Jan 14 2020 at 18:58):

(reason being that pointers arent an interface type, but arrays are)

view this post on Zulip Pat Hickey (Jan 14 2020 at 18:59):

also, i just realized this issue would happen if you ever put a string inside a struct or union as well

view this post on Zulip Dan Gohman (Jan 14 2020 at 19:00):

Yeah, that does make sense. I guess I'm just feeling a little conservative about supporting "arrays" which become pointers with not-entirely-obvious lifetimes outside of function parameters.

view this post on Zulip Pat Hickey (Jan 14 2020 at 19:00):

hmm. thats a fair concern

view this post on Zulip Pat Hickey (Jan 14 2020 at 19:01):

well, we can punt on it for now.

view this post on Zulip Pat Hickey (Jan 14 2020 at 19:01):

ill make a PR that fixes some simpler stuff, and panics in the code generator in these unsupported cases

view this post on Zulip Dan Gohman (Jan 14 2020 at 19:05):

Admittadly, the existing pointer type isn't exactly watertight either.

view this post on Zulip Dan Gohman (Jan 14 2020 at 19:05):

But it feels different -- with interface types focusing on by-value semantics, if we have something that we describe as an "array", the value of the array should be passed by copy.

view this post on Zulip Dan Gohman (Jan 14 2020 at 19:08):

Also, there are ongoing discussions at the interface types level about the possibilty of making memory slices a proper thing in interface types, and if we get that, that could change how all of these things work.

view this post on Zulip Pat Hickey (Jan 14 2020 at 19:08):

i havent kept up to date on those discussions

view this post on Zulip Dan Gohman (Jan 14 2020 at 19:08):

So my instinct here is to not get too far ahead of those discussions.

view this post on Zulip Pat Hickey (Jan 14 2020 at 19:08):

ok, works for me


Last updated: Dec 23 2024 at 12:05 UTC