| Filename | Latest commit message | Latest commit date |
|---|---|---|
The README called an exception escaping main a trap. It is an uncaught WebAssembly exception, and nothing prints its type or what(); the README says so now. It also lists what a wasm build refuses and why, says that setjmp needs -lsetjmp and that a longjmp across a noexcept function ends the program, that a wasmtime older than 47 needs -W exceptions=y, and that an old wasm-opt on PATH breaks release links. It documents exit and park in a page from EnableWasiBrowserRuntime, with the declaration of the park import. The wasi example still sent Arch users to wasi-libc++, which has no exception-enabled libraries. It asks for a wasi-sdk 33 sysroot or the Flatpak now, and names the browsers a page needs. AGENTS.md notes that the runtime test needs node, so it runs in the native loop and not in CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
| .. | ||
| main.cpp | ||
| project.cpp | ||
| README.md | ||
| serve.sh | ||
WASI
Build a C++26 program for the wasm32-wasi target and run it in a browser.
Prerequisites
- A WASI sysroot with the exception-enabled libc++,
lib/wasm32-wasip1/eh/from wasi-sdk 33 or later: wasm builds compile C++ exceptions and link those libraries. The Flatpak bundles one, whichcrafter-builduses as it is. Elsewhere, pointCRAFTER_BUILD_WASI_SYSROOTat a wasi-sdk sysroot, or setcfg.sysrootinproject.cpp. Arch'swasi-libc++packages have no such libraries, and the build stops with a message saying so. - For the browser: WebAssembly exception handling, in Chrome 137, Firefox 131, Safari 18.4 or newer.
Build
crafter-build
Output lands in bin/wasi-hello-wasm32-wasip1-native/:
wasi-hello.wasm— the compiled moduleindex.html+runtime.js— a minimal in-browser WASI shim, dropped in byEnableWasiBrowserRuntime(cfg)inproject.cpp. Stdout goes to the browser console.
Run in a browser
./serve.sh # any static file server works
Open http://localhost:8080/. The string from main() shows up in the
DevTools console.
Run in a standalone runtime
If you don't need the browser, drop the EnableWasiBrowserRuntime(cfg) line
from project.cpp and run the .wasm directly:
wasmtime bin/wasi-hello-wasm32-wasip1-native/wasi-hello.wasm