-
Notifications
You must be signed in to change notification settings - Fork 296
size calculation for wasm32 and wasm64 #1446
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
Conversation
Thanks for this! I'm trying to look a bit ahead into the future and see how this would integrate into various bindings generators to see if this is the best design for that. One thing I'm concluding is that I don't think it'd be reasonable to generate code that works in both. For example by using In Rust I think that the way this will work is that there will be a That's basically a long-winded way of saying I think that this is in the right direction. I might suggest some changes, though:
|
Oh, I didn't realize that there is a self object to remember and pass the ABI selection, of course that makes sense. Also, I really would like to create code like I trust your assessment on whether a default 32 bit object should exist, right now |
Oh I really like that idea! Could the return value of size/align perhaps return something "symbolic" which is something like If that's too complicated though I'm happy to merge as-is. |
Well, given a calculated offset of S for wasm64 and T for wasm32 using above code, the factors become So even with the code as is this is possible, there might just be a more elegant way. BTW: I added wasm64 to Rust bindgen as part of cpetig/wit-bindgen@1a90bd8 - I should probably separate it from the rest of the C++ history and contribute as a separate MR to wit-bindgen. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok let's go ahead and merge this and can always iterate later if necessary, but seems fine to see how this plays out.
And yeah if you'd be up for sending a PR for Rust support that'd be much appreciated! Unfortunately it can't really be tested right now due to Wasmtime not having support for memory64 plus components, however.
Well, I was already able to test it as part of … my native compilation test at https://github.com/cpetig/wit-bindgen/tree/main/crates/cpp/tests/native_strings Now the generated Rust code needs zero patching, I still work on getting the C++ "host" code generated correctly. This compiles the Rust or C++ guest code into a shared object and generates matching C++ "host" code for the calling, lifting and lowering. The same binary interface on the guest side can also be implemented with wasm2c or a runtime. |
Calculate size and alignment depending on the ABI variant