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

wasm-builder uses hacks to build WASMs #4235

Open
3 of 7 tasks
StackOverflowExcept1on opened this issue Sep 14, 2024 · 1 comment
Open
3 of 7 tasks

wasm-builder uses hacks to build WASMs #4235

StackOverflowExcept1on opened this issue Sep 14, 2024 · 1 comment
Assignees
Labels
C0-bug Something isn't working P1-asap High priority

Comments

@StackOverflowExcept1on
Copy link
Member

StackOverflowExcept1on commented Sep 14, 2024

Problem

Starting with Rust 1.82 WASMs contain multi-value and reference-types features: https://blog.rust-lang.org/2024/09/24/webassembly-targets-change-in-default-target-features.html. However, Rust does not currently even provide support for multi-value and reference-types in language.

We currently use hack #4247 to solve this issue. This hack results in end user having to:

Other optimization/parsing/executions issues:

Steps

No response

Possible Solution

Notes

No response

Relevant Log Output

No response

@StackOverflowExcept1on StackOverflowExcept1on added P1-asap High priority C0-bug Something isn't working labels Sep 14, 2024
@StackOverflowExcept1on StackOverflowExcept1on changed the title wasm-builder: can't build contracts/runtime with beta version of rust wasm-builder uses hacks to build WASMs Sep 25, 2024
@playX18
Copy link
Member

playX18 commented Dec 12, 2024

I was looking into Wasmtime and Wasmer in terms of supporting new features including multivalue and ref-types.

Wasmtime

Wasmtime did not have singlepass backend until recently, now they have Winch which is still Tier 4 in support aka it does not support reference-types and only can compile to x86_64 backend at the moment.
I did some local testing and while it runs small programs I throw at it just fine I am unable to test it to full extent yet, probably we could try to experimentally add Winch support to Gear if we ever look into using it instead of Wasmer.

Wasmer

Wasmer does have singlepass backend but does not support multivalue which we need so much. It's possible to fork wasmer and add the code for x64 and aarch64 backends by our own efforts and then try merge that into mainstream but it's unlikely it will be prioritized by the Wasmer team (see wasmerio/wasmer#5286).
We could instead maintain our own fork and sync it with mainstream when needed.

Alternatives

One possible alternative is using something like binaryen API to implement a pass that removes multivalue usage in code and converts it to locals. There is only one cons of this approach is that it could add significant overhead to upload_code as it would require constructing internal binaryen CFG in order to perform operations on WASM code.
As @breathx pointed out in chat, we can run this pass in wasm-builder instead and just verify that multivalue does not exist in code at instrumentation phase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C0-bug Something isn't working P1-asap High priority
Projects
None yet
Development

No branches or pull requests

2 participants