Repository navigation
fix(vm): build openvm-circuit for wasm32-unknown-unknown - #3178
Open
pauldelucia wants to merge 1 commit into
Open
pauldelucia wants to merge 1 commit into
pauldelucia wants to merge 1 commit into
Conversation
abi_stable needs libloading::Library, which libloading only defines on unix and windows, so openvm-circuit (and openvm-verify-stark-host with it) failed to build for wasm32-unknown-unknown. Its only use is the RVec<u32> field addr_space_access_count in the metered memory context. Move abi_stable into the existing cfg(any(unix, windows)) dependency section next to memmap2, and give the field a type alias that is RVec<u32> on unix and windows and Vec<u32> elsewhere, like the MemoryBackend split in online.rs. The field is now built with collect(), which works for both (into() would be a same-type conversion on wasm32). Unix and windows keep RVec because the AOT assembly relies on its repr(C) layout for this field. AOT is x86_64-only and needs libloading::Library too, so it never runs on the targets that get Vec.
pauldelucia
force-pushed
the
fix/wasm32-abi-stable
branch
from
December 2, 2026 09:37
ff070c8 to
3780984
Compare
This branch has not been deployed
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.
We want to verify OpenVM STARK proofs in the browser, but
openvm-verify-stark-hostdoesn't build forwasm32-unknown-unknown.openvm-circuitdepends onabi_stableunconditionally, andabi_stableneedslibloading::Library, which libloading only defines on unix and windows:The only use is the
RVec<u32>fieldaddr_space_access_countinarch/execution_mode/metered/memory_ctx.rs. This movesabi_stableinto the existingcfg(any(unix, windows))dependency section next tomemmap2and gives the field an alias that'sRVec<u32>on unix and windows andVec<u32>elsewhere, like theMemoryBackendsplit inonline.rs. The field is now built withcollect(), which works for both types (.into()would be a same-type conversion on wasm32 and tripsclippy::useless_conversion).Unix and windows keep
RVecbecause the AOT assembly reads the field's first word as its buffer pointer (extensions/rv32im/circuit/src/common/mod.rs), whichRVec'srepr(C)layout guarantees. AOT is x86_64-only and needslibloading::Libraryitself, so it never runs on the targets that getVec. If you'd rather dropabi_stablealtogether, making the field aBox<[u32]>likepage_indices_since_checkpointwould also work, since the assembly already reads that field's pointer the same way. This PR leaves native builds onRVecas they are.Testing
cargo clippy -p openvm-circuit --all-targets --tests -- -D warningsandcargo +nightly fmt --all -- --checkpass (aarch64-apple-darwin).cargo clippy -p openvm-circuit --target wasm32-unknown-unknown -- -D warningspasses, withgetrandom's JS backends enabled for the run (jsfor 0.2,wasm_jsfor 0.3).wasm-bindgencrate that depends onopenvm-verify-stark-hostbuilds forwasm32-unknown-unknownon this branch and fails on main with the error above.Building
openvm-verify-stark-hostfor wasm32 also needs a clang with a wasm32 target, forzstd-sys. Neither that nor thegetrandombackends needs a change here. We can add a wasm32 build to CI if that's useful.