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

Exported WebAssembly function cabi_realloc #184

Open
elewis787 opened this issue Oct 1, 2024 · 5 comments
Open

Exported WebAssembly function cabi_realloc #184

elewis787 opened this issue Oct 1, 2024 · 5 comments

Comments

@elewis787
Copy link

elewis787 commented Oct 1, 2024

Are there details on why the export tags for cabi_realloc were removed in 88cdc52

This still seems relevant when targeting wasip1 and using the wasi adapters ( such as the reactor adapter ) to build a component. I have tested this by adding my own cabi_realloc function and using the export tags, then converting to a wasip2 component using the wasmtime adapters.

GOOS=wasip1 GOARCH=wasm go build -o main.wasm main.go

wasm-tools component embed --world word ./wit/lex.wit main.wasm -o main.embed.wasm
wasm-tools component new -o main.component.wasm --adapt wasi_snapshot_preview1=wasi_snapshot_preview1.reactor.wasm main.embed.wasm

experimenting here https://github.com/elewis787/lex

I believe this relates to the work at tinygo-org/tinygo#4451 and golang/go#65199 but hope for some details.

My goal is to use the wit bindings for exported functions and build a wasip2 reactor component in tinygo or go.

@ydnar
Copy link
Collaborator

ydnar commented Oct 2, 2024

The affected code is not used in the current TinyGo implementation.

In suppose we could make this work in Go, but not TinyGo.

@elewis787
Copy link
Author

elewis787 commented Oct 2, 2024

I could see it being helpful for go.

Using go 1.24, I was able to use it and then convert a wasip1 module to a component with the adapters. There are likely edge cases I haven't run into.

Mainly just wanted to see if there was more context that I wasn't thinking of 😄.

Calling out that I did use this in a wasmtime-go host implementation when executing an exported function in a module compiled in both go and tiny-go targeting wasip1.

@ydnar
Copy link
Collaborator

ydnar commented Oct 13, 2024

Have you had any luck just using go:linkname with this package, or reimplementing it in your own package?

@elewis787
Copy link
Author

Reimplementing it in my own package worked. I will look into the go:linkname.

@ydnar
Copy link
Collaborator

ydnar commented Dec 8, 2024

This issue still valid?

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

2 participants