-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support for multivalue
#3552
Comments
Huh, I didn't realise that enabling multivalue affected the C ABI. That... kind of seems like a bug to me? Even though it's currently wrong, the C ABI is still supposed to be a fixed ABI that matches C, not change depending on what target features are enabled.
That was already pretty much the plan anyway, we're trying to make it so that |
When it comes to potentially enabling |
The ideal solution would be to wait for Now that I think about it though, it should actually be fine to switch only return types to match the standard C ABI right away. The two ABIs are identical in how they handle return types, as long as multivalue is disabled, and As for trying to fix it on The only solution like that that I can think of is to forcibly use the standard C ABI's handling of return values no matter what (using retptrs whenever the return type takes up more than one value). I'm not sure if that's possible though; see the second half of #3595's description for why. So if that's impossible, we'd have to always use retptrs no matter what, which isn't ideal. |
For reference: rust-lang/rust#117918. |
Right, but C ABI that Rust is supposed to match also changed depending on multivalue. It's intentional, because the whole point of multivalue as a feature is to change the ABI of passing/returning complex types like structs and fixed-size arrays by value from "a pointer allocated on the shadow stack" to "an actual tuple of values that is up to the engine to pass around efficiently". |
Oh, this is the first I've heard of that - it isn't mentioned in tool-conventions. I assume you mean the one clang uses with
I'm not so sure about that - it only happens on If it is intentional though, the rest of Rust's Wasm targets need to be updated to do the same thing. Supporting it in Even then, it seems a bit questionable to me to do it automatically when |
Ah yeah Rust-specific incompatibility of wasm32-unknown-unknown still needs to be fixed separately. (long overdue, really) Interesting that in Clang ABI change still requires experimental opt-in... For some reason I thought it's already enabled automatically when this feature is used. I must have misremembered some previous discussions on changing external C ABI for multivalue. |
It seems like |
I guess this can be closed now then, considering multivalue works without the multivalue ABI if you just switch to the spec compliant C ABI, which is intended to be the default soon anyway. |
Motivation
Multivalue is now finally properly supported by LLVM 17, which made its way into recent Rust nightlies.
Proposed Solution
It seems like a bunch of bindings that wasm-bindgen generates are using multivalue, but wasm-bindgen doesn't generate the JS side correctly to return multiple values.
Alternatives
The bindings could be adjusted to just not use multivalue at all, then the JS side doesn't need to be changed.
Additional Context
None so far
The text was updated successfully, but these errors were encountered: