Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text Format (%.wat) generator #356

Open
codefromthecrypt opened this issue Oct 6, 2022 · 6 comments
Open

Text Format (%.wat) generator #356

codefromthecrypt opened this issue Oct 6, 2022 · 6 comments

Comments

@codefromthecrypt
Copy link

The wit format is neat in that it gives hints like string to make better language bindings. However, in the process, it can be confusing what the actual imports will be. This is especially confusing as there are a couple string-based proposals to the spec. It would be nice to be able to generate%.wat instead and use that as the gold copy (for those who prefer seeing the raw wasm signatures). If we had this feature, it would be less scary to use the higher level types, which are becoming more interesting.

@alexcrichton
Copy link
Member

Do you have an example of what you'd like to see generated? I would naively interpret this as:

$ cat foo.wit
foo: func()
$ wit-bindgen guest wat --import foo.wit
(module 
    (import "foo" "foo" (func))
)

but I'm not sure if that's what you are thinking of? Or are you wondering to get the full component representation instead?

@codefromthecrypt
Copy link
Author

yes! for starters non-componentized is great. meanwhile I was thinking to emit c and then wasm2wat the result ;)

@codefromthecrypt
Copy link
Author

codefromthecrypt commented Oct 23, 2022

I think this is very important especially as modeling is fluid here. For example, it isn't intuitive that 64bit flag would be two fields, especially as wasm supports 64 bit and when used as a parameter two places is clunky. We need a way to know that decisions in markup will result in consistent wasm signatures, even if not enforced via wat. otherwise, we'll need another markup that can be trusted to not drift. as you can imagine, some may think of this as a spec document and if the representation changes without someone knowing, it fails at its primary purpose.

@Maaarcocr
Copy link

Maaarcocr commented Nov 15, 2022

Do you have an example of what you'd like to see generated? I would naively interpret this as:

$ cat foo.wit
foo: func()
$ wit-bindgen guest wat --import foo.wit
(module 
    (import "foo" "foo" (func))
)

but I'm not sure if that's what you are thinking of? Or are you wondering to get the full component representation instead?

@alexcrichton That would be incredibly useful (especially if it spit out some wat I could link with other components written in rust, using wasmtime Linker). If one were to try to implement that, where would you suggest they start digging around? Any tips?

@alexcrichton
Copy link
Member

This is actually already implemented here so the implementation here would be mostly to expose that in a package somewhere.

@codefromthecrypt
Copy link
Author

@Maaarcocr I'm cool on your view of the outcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants