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

WIT support #657

Closed
flavio opened this issue Feb 8, 2023 · 9 comments
Closed

WIT support #657

flavio opened this issue Feb 8, 2023 · 9 comments
Labels
cool Cool stuff.

Comments

@flavio
Copy link

flavio commented Feb 8, 2023

As part of the WebAssembly Component Model proposal, the WIT format is used to describe the interfaces used by components.

There's a cli tool, wit-bindgen that can to scaffold the import/export code of a certain component.

Currently wit-bindgen can generate export and import code for Wasmtime, but it lacks wasmi support.

In case you're interested, I've created a forked version of wit-bindgen that can generate both import and export code for wasmi.
The code currently lives inside of this repository, under the wasmi branch.

wit-bindgen is undergoing a lot of changes. I've targeted the v0.2.0 release, which is the one used by projects like Spin and SpiderLightning.

I will not push the code upstream yet, because of all these undergoing changes (see this comment).

I'm opening this issue in case other wasmi users could benefit from using this code.

If you want to see the code in action, you can take a look at this codebase.

@Robbepop
Copy link
Member

Robbepop commented Feb 8, 2023

This is amazing!

Thanks for the links and the work to support wasmi in wit-bindgen.
Unfortunately I am myself not yet very up to date with the Wasm component model and wanted to wait for the dust to settle before I try understanding and maybe implementing the required parts for it in wasmi (if there are any).

I am sure people will find this useful!

@flavio
Copy link
Author

flavio commented Feb 9, 2023

I totally understand. The component model is moving damn fast, I expect I'll have to rewrite quite a lot of all the code from my fork.

However, there's just one minor thing that could be done inside of wasmi. It would be great to have the equivalent of wasmtime's Linker::define. This is not required (I managed to deal with its lack), but it would make the ergonomics better.

I started to implement it, but then I stopped because 1) I was running out of time for my hackathon 2) I would have broken wasmiAPI.

If you are fine to have this API I would be glad to finish my PR.

@Robbepop
Copy link
Member

Robbepop commented Feb 9, 2023

However, there's just one minor thing that could be done inside of wasmi. It would be great to have the equivalent of wasmtime's Linker::define. This is not required (I managed to deal with its lack), but it would make the ergonomics better.

I started to implement it, but then I stopped because 1) I was running out of time for my hackathon 2) I would have broken wasmiAPI.

If you are fine to have this API I would be glad to finish my PR.

I am a bit confused about this since the Linker::define API exists in wasmi already.

@flavio
Copy link
Author

flavio commented Feb 9, 2023

Sorry, that's entirely my fault... I meant Linker::func_wrap

@Robbepop
Copy link
Member

Robbepop commented Feb 14, 2023

If you are fine to have this API I would be glad to finish my PR.

It just occured to me that I have never really answered your question. I was just thinking about this Linker API and how we could implement it in wasmi when I saw that you apparently seem to have already implemented the whole thing. I could do it, too but I happily accept contributions.
So yeah if you have time and energy and want to contribute: please go ahead. :) Otherwise I can do it, too since I already wrapped my head around it hehe.

@flavio
Copy link
Author

flavio commented Feb 15, 2023

On Fri I'll take a look at the code I started writing and I'll let you know. I would like to contribute to the project if time permits :)

@Robbepop
Copy link
Member

Robbepop commented Mar 1, 2023

@flavio Could you please move this issue to a discussion item? I think a discussion about wit-bindgen support for wasmi makes more sense than a technical issue. :)

@flavio
Copy link
Author

flavio commented Mar 2, 2023

Done, I've created this discussion: #703

@flavio flavio closed this as completed Mar 2, 2023
@Robbepop
Copy link
Member

Robbepop commented Mar 2, 2023

@flavio Thank you!

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

No branches or pull requests

2 participants