-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Function arguments when returning a struct #2726
Comments
Correct
Apart from reading the source of rustc and LLVM there isn't really for wasm32-unknown-unknown. Probably the best description is rust-lang/rust#81388 (comment). For wasm32-unknown-emscripten and wasm32-wasi, the official C abi for wasm is followed, but for wasm32-unknown-unknown this is not the case. By accident LLVM was allowed to do it's own abi adjustments and now it can't be changed anymore without breaking wasm-bindgen. (source: I broke it by accident a while ago by doing something that prevented LLVM from doing it's own abi adjustments.) |
The C ABI for the wasm32 target is currently documented at https://github.com/WebAssembly/tool-conventions/blob/master/BasicCABI.md, although the Rust ABI for wasm32-unknown-unknown differs from Clang for historical reasons. Using the wasm32-wasi target, however, the ABIs will be the same. |
Ok! |
Hi,
I'm pretty new to the whole rust/wasm world.
I'm passing to rust host from rust wasm function that returns a simple struct.
I'm compiling with cargo and the target wasm32-unknown-unknown.
I saw that when I check the module exports this function get an extra arguments... making some guessing I find out that is the memory pointer for the return struct...
I cannot find out some documentation for this behaviour... someone can please address me to the right direction?
Thanks a lot ☺
The text was updated successfully, but these errors were encountered: