Browser wasm: feature-detected module variants (relaxed-SIMD) + variant-aware runtime.js #24
Labels
No labels
bug
claude:blocked
claude:done
claude:failed
claude:in-progress
claude:ready
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Build#24
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The browser wasm pipeline produces a single
.wasmcompiled with a fixed ISA feature set, andEnableWasiBrowserRuntimebakes one wasm URL into the generatedindex.html. To adopt newer codegen features that aren't yet baseline across browsers — relaxed SIMD today, others later — without dropping the browsers that lack them, Crafter.Build should be able to:-mflags, andruntime.jsthat feature-detects the browser and fetches the supported variant.Why this belongs in Crafter.Build
Both halves are owned here, not by downstream projects (this surfaced from Crafter.Graphics' WebGPU/DOM backend, which can't influence either):
Flags are hardcoded for every wasm32 target —
implementations/Crafter.Build-Clang.cpp:496:-msimd128is unconditional, so the emitted module hard-requires fixed-width SIMD and there is no way to produce a relaxed-SIMD variant or a fallback.A single wasm URL is templated into the HTML —
implementations/Crafter.Build-Clang.cpp:1257:The shipped
wasi-runtime/runtime.jsfetches/instantiates that one URL; there is no notion of alternative variants.Current motivation: relaxed SIMD
-mrelaxed-simdmodule would break Safari, while staying on-msimd128leaves FMA / dot-product throughput on the table for the other ~2/3 of browsers.Proposed shape (for discussion, not prescriptive)
.wasmper variant, namedoutputName.<label>.wasm.EnableWasiBrowserRuntimeemits a small manifest (label → URL + required probes) instead of / alongside the single{{WASM}}substitution.wasi-runtime/runtime.jsruns the probes at startup (tiny compile-test modules à la GoogleChromeLabs/wasm-feature-detect — each is ~a dozen bytes, no external dependency needed), picks the first variant whose probes all pass (else baseline), then runs the existinginstantiateStreamingagainst the chosen URL.Claude exited with code 3.