Skip to content

Fix wasm build in rust 1.85 #2326

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

Merged
merged 2 commits into from
Feb 21, 2025
Merged

Fix wasm build in rust 1.85 #2326

merged 2 commits into from
Feb 21, 2025

Conversation

Alenar
Copy link
Collaborator

@Alenar Alenar commented Feb 21, 2025

Content

This PR fix build of the wasm library that's failing since release of rust 1.85.

$ npm run build:node                                                                                                                   
                                                                                                                                        
> @mithril-dev/mithril-client-wasm@0.8.4 build:node                                                                                     
> wasm-pack build --target nodejs --out-dir dist/node $WASM_PACK_ARGS                                                                   
                                                                                                                                        
[INFO]: 🎯  Checking for the Wasm target...                                                                                             
[INFO]: 🌀  Compiling to Wasm...                                                                                                        
   Compiling mithril-common v0.5.4 (/home/dev/mithril/mithril-common)                                                             
   Compiling mithril-client v0.11.3 (/home/dev/mithril/mithril-client)                                                            
   Compiling mithril-client-wasm v0.8.4 (/home/dev/mithril/mithril-client-wasm)                                                   
    Finished `release` profile [optimized] target(s) in 13.49s                                                                          
thread 'main' panicked at crates/wasm-interpreter/src/lib.rs:245:21:                                                                    
mithril_common::signable_builder::interface::_::__ctor::h4977fb9f7c35308c: Read a negative address value from the stack. Did we run out 
of memory?                                                                                                                              
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace                                                           
Error: Running the wasm-bindgen CLI                                                                                                     
Caused by: Running the wasm-bindgen CLI
Caused by: failed to execute `wasm-bindgen`: exited with exit status: 101 

This is due to an incompatibility between the type-tag crate and wasm.
Removing typetag from the wasm build solve the issue at the price of not being able to use typetag bound generics fields with serde in wasm.
This is acceptable because the only use case for type tag right now in our code base is in the mithril-aggregator, that's not compiled to wasm, to serialize/deserialize in json the artifact field of the signed_entity table.

There's a remaining question: This incompatibility is not new and is not related to rust 1.85 so why wasm builds start to fails only now ?

Pre-submit checklist

  • Branch
    • Crates versions are updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • No clippy warnings in the CI
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

Issue(s)

Closes #2325

As it's incompatible.

This means that in wasm we can't serialize/deserialize a field that
contains a generics bound to type tagged trait (only `Artifact` trait
is impacted).
We only have one use case for this rigth now, storing artifacts in a
generic database records field, which is not compiled to wasm so this is
acceptable.
* mithril-common from `0.5.4` to `0.5.5`
@Alenar Alenar self-assigned this Feb 21, 2025
Copy link
Collaborator

@dlachaume dlachaume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Member

@jpraynaud jpraynaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🔥

Copy link

github-actions bot commented Feb 21, 2025

Test Results

    3 files  ±0     52 suites  ±0   10m 35s ⏱️ -4s
1 645 tests ±0  1 645 ✅ ±0  0 💤 ±0  0 ❌ ±0 
1 929 runs  ±0  1 929 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 249b875. ± Comparison against base commit fc119af.

♻️ This comment has been updated with latest results.

@Alenar Alenar temporarily deployed to testing-preview February 21, 2025 10:56 — with GitHub Actions Inactive
@Alenar Alenar merged commit be28830 into main Feb 21, 2025
38 of 42 checks passed
@Alenar Alenar deleted the djo/fix-wasm-build-in-rust-1.85 branch February 21, 2025 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build client WASM fails with Rust 1.85
4 participants