Repository navigation
Description
Summary
./flow wasm --backend=mlir already works for small console programs (Flow → MLIR → LLVM → emcc), but browser gfx games and file-backed apps still depend on --backend=c. The doom-flow GitHub Pages demo is a real stress case: full Doom in Flow, gfx_present game loop, ASYNCIFY, WAD preload, and flow_rt_support.c. Today it must use the C backend. Please treat Flow → MLIR → WASM as first-class for gfx loops and document/test it at gallery (and eventually doom-flow) scale.
Motivation
The natural story for Flow-in-the-browser is:
*.flow → MLIR → LLVM IR → emcc → .wasm
That path exists (--backend=mlir / FLOW_CPU_BACKEND=mlir), but production browser demos still advertise/ship:
*.flow → C → emcc → .wasm
For doom-flow we had to explain “we’re not on MLIR yet” in the README/site. Users reasonably expect the MLIR path once native --backend=mlir exists.
Live demo (C path today): https://godofecht.github.io/doom-flow/
Current state (as of filing)
| Area | Status |
|---|---|
./flow wasm … --backend=mlir |
Works for examples/wasm/hello_wasm.flow (smoke + tests/integration/test_wasm_backends.py) |
Gallery games (snake_gfx, etc.) |
C only (ROADMAP: gallery stays C) |
wasm_build.py gfx link |
Can attach runtime/gfx_wasm.c + -sASYNCIFY for either backend when gfx is detected — not gallery-validated on MLIR |
--fs / --preload / --threads |
Refuse MLIR (“crossings currently require --backend=c”) |
| doom-flow browser build | Custom scripts/build_wasm.sh: Flow→C→emcc + gfx_wasm.c + flow_rt_support.c + --preload-file DOOM1.WAD@/doom1.wad + larger ASYNCIFY/memory |
Relevant docs: docs/language/wasm.md, docs/demos/wasm.md, docs/language/wasm-crossings.md, ROADMAP.md.
Related closed roadmap: #121 (WASM target — Flow→C→emcc partial). No open issue for MLIR WASM gfx/doom-scale.
What doom-flow needs on MLIR
-
Gfx loop under
--backend=mlir
Same contract as C:while+gfx_present→ ASYNCIFY +runtime/gfx_wasm.c, verified in-browser (snake-class minimum). -
Runtime link set
Stockwasm_build.pyonly addsgfx_wasm.c. Doom also needsruntime/flow_rt_support.c(fnptr trampolines / errno / host helpers). Either teachflow wasmto pick package[native]extras, or document a supported link hook. -
Filesystem preload on MLIR
Unblock--preload/ MEMFS (or equivalent) for--backend=mlir. Doom ships shareware IWAD via--preload-file …@/doom1.wad. -
Sizing knobs
Doom needs roughlyASYNCIFY_STACK_SIZE≥65536,INITIAL_MEMORY≥64MB(stock defaults are smaller). Expose or auto-scale for large programs. -
wasm32 vs pointer-as-i64
Doom still has LP64-era*_OFF_*/(ptr as i64)patterns in places. Clarify MLIR’s wasm32 pointer model vs C→emcc so ports don’t silently mis-index tables (we already hit this class of bug once on music layouts). -
Language gaps that bite large apps
Capturing closures / effects on MLIR; missing runtime symbols; docs warn “larger programs may need extra emcc flags.” Need a clear “supported for gfx games” bar.
Proposed acceptance criteria
-
./flow wasm examples/games/snake_gfx.flow --backend=mlirbuilds and runs in a browser (ASYNCIFY frame loop) - At least one CI / integration smoke for MLIR gfx (not only
hello_wasm) -
--preload DIR@/mount(or documented equivalent) works with--backend=mlir - Documented way to link extra runtime C (
flow_rt_support.c) on the MLIR wasm path -
docs/language/wasm.md+LANGUAGE_SPEC§9.3 updated so dual-backend status matches reality - Stretch: doom-flow Pages build can switch to
--backend=mlirwithout a custom C-only script
Workarounds today
# doom-flow (C path — works)
FLOW_DIR=~/flow ./scripts/build_wasm.sh
# Flow hello on MLIR (works; not gfx)
./flow wasm examples/wasm/hello_wasm.flow --backend=mlirContext links
- Port: https://github.com/godofecht/doom-flow
- RL sister: https://github.com/godofecht/doom-flow-rl
- Pages: https://godofecht.github.io/doom-flow/
Happy to help validate patches against doom-flow’s WASM build once the MLIR path grows the hooks above.
Activity
godofecht commentedon Aug 7, 2026
Child issues (split from this epic)
u8/…) toiNllvm.mlir.zerollvm.getelementptrmixingflow wasm --backend=mlir: honor--preload/--linkValidation target
doom-flow Pages currently ships C → emcc (
scripts/build_wasm.sh). Once snake-class gfx + preload work on MLIR, we can dual-build and A/B.Observed “assets missing” on doom WASM (C path)
Not IWAD 404 — WAD loads (
adding doom1.wad). Apparent gaps are:FEATURE_SOUND/ music soft-skipped on wasmThose are separate from the MLIR epic but motivate keeping the C path healthy while MLIR catches up.
godofecht commentedon Aug 7, 2026
Progress toward this epic:
uN→ MLIRiNso gfx externs parse under mlir-opt. After that fix,snake_gfx --backend=mliradvances to the next failure: memref vsllvm.getelementptrmixing (MLIR: memref vs llvm.getelementptr type mixing breaks game arrays #224).?mode=playnow autostarts.Still open for doom-scale MLIR: #223 (null ptr), #224 (memref/gep), #225 (preload/link).
godofecht commentedon Aug 7, 2026
Progress
PR #229 lands:
Validated locally:
./flow wasm examples/games/snake_gfx.flow --backend=mlirbuilds a gfx canvas page (ASYNCIFY +gfx_wasm.c).Next for doom-scale: #225 (
--preload/--link/ memory knobs) then try dual-building doom-flow.test: dual c/mlir smoke for wasm_build backends
fix(mlir): uN/null/memref + MLIR wasm preload (#222–#225) (#229)
godofecht commentedon Aug 7, 2026
Children #222–#225 landed via #229. Remaining stretch: doom-flow Pages dual-build on the MLIR path (preload + link + gfx knobs are now in stock
./flow wasm --backend=mlir).docs+test: finalize MLIR WASM epic #221 acceptance (#231)
godofecht commentedon Aug 7, 2026
Closed — acceptance met
snake_gfx --backend=mlirgfx+ASYNCIFY pagetest_wasm_mlir_gfx_snakein #231--preload/--linkon MLIRwasm.md, LANGUAGE_SPEC §9.3, ROADMAP)BACKEND=mlirin doom-flowscripts/build_wasm.shNot in scope for this close: full
doom.flowMLIR lower still fails (KeyError: mlir_name…). Tracked as #230.Children #222–#225 already closed via #229.
release: Flow 0.10.0 (#243)