Skip to content

Use wasm-gc to handle pointer casts in wasi #129040

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

Open
hoodmane opened this issue Jan 20, 2025 · 3 comments
Open

Use wasm-gc to handle pointer casts in wasi #129040

hoodmane opened this issue Jan 20, 2025 · 3 comments
Labels
OS-wasi type-feature A feature request or enhancement

Comments

@hoodmane
Copy link
Contributor

hoodmane commented Jan 20, 2025

In #128628 I switched the way of handling function pointer casts in emscripten to an approach based on wasm-gc. Unlike the previous approaches this should work on the wasi targets, at least the ones that include wasm-gc. There's some difficulty in that there's no support for the instructions in the clang C front end, nor really in the backend yet. So I'm not sure what is the best way to emit these instructions. We only would need to generate one short function using them though.

@brettcannon WDYT?

@brettcannon
Copy link
Member

What's the specific benefit for trying to make the switch for WASI when "there's no support for the instructions in the clang C front end, nor really in the backend yet" as I don't think wasmtime has landed their GC proposal support fully yet? Plus there isn't a WASI trampoline like there is with Emscripten, so I'm not sure where you're suggesting to insert the assembly code, unless you're trying to broaden the trampoline to be WASM-agnostic?

@hoodmane
Copy link
Contributor Author

Right well if wasmtime or your favorite wasi runtime don't support wasm-gc yet then there's no benefit until they do. But wasi has the same function pointer cast problem as emscripten. Once the wasi runtimes all support wasm I think it makes sense to think about how to get a trampoline running. But it is indeed annoying if it's necessary to hand craft an object file. I'll look into what the options are, maybe there's a reasonable way with a .s file or inline assembly.

@brettcannon
Copy link
Member

if wasmtime or your favorite wasi runtime don't support wasm-gc yet then there's no benefit until they do.

Looks like I misspoke; wasmtime landed support in version 27 in late November.

@picnixz picnixz added the type-feature A feature request or enhancement label Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-wasi type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants