Conversation
…r wasm32 Follow-up to the generic compile gates: makes every crate except ppvm-python-native cross-compile for wasm32-unknown-unknown (browser / wasm-bindgen) with no extra flags, while native builds keep gxhash/dashmap/ ahash/rayon and stay byte-for-byte unchanged. Mechanism (automatic, no per-command flags): the native-only acceleration deps move into [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tables, so Cargo prunes them on wasm. Their features stay nominally on but their dep: activations become no-ops, and every code site that names those crates is gated with the same not(target_arch = "wasm32"), so it compiles out cleanly. - ppvm-traits: target-gate ahash/dashmap/gxhash/rayon; gate the dashmap map module, the ahash ACMap impls, and the gxhash HashFinalize impl. - ppvm-pauli-word: target-gate gxhash. - ppvm-pauli-sum: target-gate dashmap/gxhash; gate the config::dashmap module and config::indexmap's ByteGxHash/ByteGxHashF64 (also fixes a latent indexmap-without-gxhash coupling). - ppvm-tableau-sum: target-gate gxhash/rayon; word_fingerprint falls back from GxHasher to fxhash::FxHasher on wasm (it is a transient in-memory dedup hash resolved by structurally_equal, never persisted or compared cross-platform). - ppvm-tableau / ppvm-stim: target-gate rayon (no OS threads on wasm). - rand entropy: rand::make_rng() has no default source on wasm32-unknown-unknown, so select getrandom's wasm_js (Web Crypto) backend via a --cfg getrandom_backend="wasm_js" rustflag in .cargo/config.toml plus the wasm_js feature in ppvm-tableau's wasm-only dep table; feature unification covers tableau-sum/stim/top-level ppvm. - CI: new 'wasm32 build (browser)' job cross-compiles the workspace on every PR. - docs: WebAssembly subsection in develop.astro. Verified: native cargo test --workspace = 744 passed, 0 failed; native --all-targets and the ppvm-python-native cdylib build unchanged; the full workspace (incl. ppvm-tableau, ppvm-tableau-sum, ppvm-stim, top-level ppvm) builds for wasm32-unknown-unknown; and on wasm the dependency tree drops ahash/gxhash/getrandom-0.3 entirely, leaving only getrandom 0.4 (wasm_js) for rand entropy. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Collaborator
Author
|
No performance impact on native builds. Every change in this PR is wasm-only — a |
Collaborator
Author
|
I think WASM is fully supported now. cc: @rafaelha |
Collaborator
|
Confirming that WASM compilation works for me now |
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.
Summary
Follow-up to #143 (now merged): #143 made the compile gates generic; this PR
closes the dependency / feature-graph blockers so the whole workspace
except
ppvm-python-nativecross-compiles towasm32-unknown-unknown(browser / wasm-bindgen) —
cargo build --target wasm32-unknown-unknownwithno extra flags. Native builds keep gxhash/dashmap/ahash/rayon and are
byte-for-byte unchanged.
Mechanism (automatic)
Cargo prunes a dependency under
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]on wasm, but the feature named after it stays on, so
#[cfg(feature = "X")]code would still try to compile against the absent crate. The fix is two
coordinated moves per native-only dep: target-gate the dep and gate its code
sites with the same
not(target_arch = "wasm32"). The features then go inert onwasm, so no
default-features = falsepropagation through the inter-crate depsis needed.
Changes
ppvm-traits— target-gateahash/dashmap/gxhash/rayon; gate thedashmap map module, the ahash
ACMapimpls, and thegxhashHashFinalizeimpl.ppvm-pauli-word— target-gategxhash.ppvm-pauli-sum— target-gatedashmap/gxhash; gate theconfig::dashmapmodule andconfig::indexmap'sByteGxHash/ByteGxHashF64(also fixes a latent
indexmap-without-gxhashcoupling).ppvm-tableau-sum— target-gategxhash/rayon;word_fingerprintfalls back from
GxHashertofxhash::FxHasheron wasm (a transient in-memorydedup hash, resolved by
structurally_equal, never persisted or comparedacross platforms).
ppvm-tableau/ppvm-stim— target-gaterayon(no OS threads on wasm).rand::make_rng()has no default source onwasm32-unknown-unknown, so select getrandom'swasm_js(Web Crypto) backendvia a
--cfg getrandom_backend="wasm_js"rustflag in.cargo/config.tomlplusthe
wasm_jsfeature inppvm-tableau's wasm-only dep table; featureunification covers tableau-sum / stim / top-level
ppvm.wasm32 build (browser)job cross-compiles the workspace on every PR.develop.astro.Verification
cargo test --workspace(excl. python-native's macOS test-link issue):744 passed, 0 failed.
--all-targetsand theppvm-python-nativecdylib build unchanged.wasm32-unknown-unknown— incl.ppvm-tableau,ppvm-tableau-sum,ppvm-stim, and the top-levelppvmcrate.ahash/gxhash/getrandom 0.3entirely,leaving only
getrandom 0.4(wasm_js) forrand.🤖 Generated with Claude Code