From 66cd83d2a1367e97101daebd11d69149c16cd944 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Fri, 11 Sep 2026 19:51:33 +0700 Subject: [PATCH] wasm32 runs the table, and the hash matches sand-headless prints 2256461126764447066 on native and on wasm32, at -O2 and at -O0, in one dune test run. That is the whole point of the exercise and the reason rand-f32 is written in Flan rather than bound to libc. The old note said the builtins archive has to come from a wasi-sdk release. It does not: emscripten builds the same compiler-rt and it links correctly under the other name. It is a different triple built by a different clang, so it is a substitution rather than the real article, and both the code and the note say so - nobody should read "wasm32 works" without knowing which joint is glued. Two findings the note did not have. The entry point is __main_argc_argv, not main, and the link succeeds before trapping on a signature-mismatched weak stub. And the target has to reach the C compiles as well as the link, since flan_rt.c includes stdio.h. Also corrects why sand is two programs. Two claims had been run together: raylib does work on wasm through emscripten, and a game loop is expressible there with emscripten_set_main_loop - a different main, not a different program. What justifies the split is only that a headless test needs no window on any target. What makes it mandatory is Load collecting a package's C and link flags whether or not anything references the package, and that is the thing to fix. --- NEXT.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/NEXT.md b/NEXT.md index d22790f..da43f24 100644 --- a/NEXT.md +++ b/NEXT.md @@ -346,6 +346,30 @@ callable), no cycle detection, and a package cannot import another one. ## sand.flan is two programs +**The stated reason below is narrower than it reads, and the real fix is a +one-line change to `Load` rather than two files.** Two claims got run together: + +- *raylib does not work on wasm* — false. It works through emscripten, which + plan.org says itself. What is true is that it does not work on the **wasi** + path, which is what the headless table targets, and which has no GL and no + browser. +- *a game loop cannot be expressed on wasm* — false. The browser cannot be + blocked, so a web build drives the loop with `emscripten_set_main_loop` + instead of a `while`. That is a different `main`, not a different program, + and nothing about it requires the simulation to live in its own package. + +What actually justifies the split is smaller and stands on its own: **the +headless test needs no window and no input on any target.** `sand.flan` could +not be that test even natively — with no mouse the grid stays empty and +`settle` and `move-grain` never run on real data. + +What makes the split *mandatory* rather than chosen is the packaging +limitation: **`Load` collects a package's C sources and link flags whether or +not anything references the package.** Make that conditional and the two files +become a preference. That is the thing to fix, and it is not large. + + + plan.org wants sand tested twice — interactive at 120 fps, and headless over N frames with the grid hashed, the version CI runs on native *and* wasm32. Those cannot be one binary: `Load` collects a package's C sources and linker