Add a new, unstable, "wasm-multivalue" ABI#157334
Draft
alexcrichton wants to merge 1 commit into
Draft
Conversation
This commit adds a new ABI string to the Rust compiler, "wasm-multivalue", which corresponds to a new ABI for WebAssembly defined at WebAssembly/tool-conventions#268. The purpose of this ABI is to enable Rust code compiled to WebAssembly to be able to work with WebAssembly functions that have multiple results in their type signature. Currently, despite the `multivalue` target feature being stable, this is not possible. The reason this isn't possible is that the original "C" ABI was created before multivalue and then there's no realistic means to change it. This new ABI is intended to enable all preexisting targets to use this ABI. One day this may become the default ABI for WebAssembly, but we aren't there yet. This adds various bits of plumbing and such throughout the compiler to support the new `wasm-multivalue` ABI. This is only supported with LLVM 23 and later due to required changes in LLVM. This ABI additionally requires the `multivalue` target feature to be enabled to use it.
Member
Author
|
I'll note that I'm creating this as a draft at this time because this requires changes to LLVM which haven't yet landed upstream in LLVM. I hope to land the changes in time for LLVM 23, but we'll see. In the meantime I wanted to at least provide this as a reference point for some discussions I'm having. I don't plan on marking this as ready-for-review until the in-tree version of LLVM supports this new ABI. |
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
bjorn3
reviewed
Jun 2, 2026
| Variants::Empty | Variants::Multiple { .. } => return None, | ||
|
|
||
| // Fall through to go see further... | ||
| Variants::Single { .. } => {} |
Member
There was a problem hiding this comment.
This would also match enums where a single variant is inhabited. This should probably check that the type is actually a struct.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds a new ABI string to the Rust compiler, "wasm-multivalue", which corresponds to a new ABI for WebAssembly defined at WebAssembly/tool-conventions#268. The purpose of this ABI is to enable Rust code compiled to WebAssembly to be able to work with WebAssembly functions that have multiple results in their type signature. Currently, despite the
multivaluetarget feature being stable, this is not possible. The reason this isn't possible is that the original "C" ABI was created before multivalue and then there's no realistic means to change it. This new ABI is intended to enable all preexisting targets to use this ABI. One day this may become the default ABI for WebAssembly, but we aren't there yet.This adds various bits of plumbing and such throughout the compiler to support the new
wasm-multivalueABI. This is only supported with LLVM 23 and later due to required changes in LLVM. This ABI additionally requires themultivaluetarget feature to be enabled to use it.