Repository navigation
ariadne_wasm: the WAMR backend, so arix's guests run where there is no wasmtime (G3) - #1592
Merged
Merged
Conversation
…o wasmtime (G3) arix and ariglx run a document's WebAssembly guests on wasmtime, which cvcpkg publishes for Linux, macOS and Windows only. This adds the backend the roadmap plans for the rest (ARIADNE_SCRIPTING_HOSTS.md, phase G3): guest_runtime.h on WAMR's wasm-c-api, which cvcpkg builds for FreeBSD, OpenBSD, NetBSD and Haiku (cy-pca/cvcpkg#648). cvc_find_ariadne_wasm takes WAMR where it finds no wasmtime, and -DCVC_ARIADNE_WASM_RUNTIME=wamr forces it where wasmtime is there too. wasmtime stays the default wherever it exists. WAMR can't pause a running call, so a guest pauses by Asyncify, as in the browser. The host's imports start and stop the unwind and the rewind by calling the guest's own Asyncify exports from inside the import. The slices, the waits, the unwind room and its overrun follow browser_runtime.cpp. A guest that wasn't transformed at install is transformed as it loads, as wasmtime meters one. WAT text is read as a binary, the gas pass meters it, then binaryen's Asyncify runs around its ari imports. That is binaryen in process (wasm_transform.cpp, the cvcpkg binaryen package), on its C++ API, because the C API exits the process on bad WAT and keeps its pass options process-wide. Without binaryen the backend takes only transformed guests, as the browser does. Each instance has a store of its own and imports with environments, so no table of natives is registered anywhere. A module is loaded once per memory cap and shared into each instance's store. The memory cap is the module's own maximum, lowered by cap_memory. wamr_load.cpp asks WAMR's native loader whether a binary loads and what it holds; its header and the wasm-c-api's can't share a file. WAMR differs from wasmtime in places the backend has to cover: - WAMR runs a start function while it instantiates, before the wasm-c-api has wired the host's imports. So the start section becomes an export (start_as_export, wasm_binary.h), which runs once the imports are there, on the start's own gas. - The transform's -O1 drops an import nothing calls. So a guest's imports are checked as it was written, by the browser's imports_match, which moves to wasm_binary.cpp for both. - A host callback's result vector arrives empty but for its size. - A host trap's text is cut at 107 bytes, so the backend keeps the whole text. - wasm_instance_new adds a host heap page to the guest's memory, so instances are made with no heap. - The c-api's vectors made uninitialized count no elements. - wasm_extern_as_func casts whatever it is given. The engine's tests run on WAMR with binaryen: ariadne_wasm_test (WAT guests), ariadne_wasm_transform_test (with the browser's unwind-room cases and its import-type messages), and arix_wasm_block, arix_wasi_stubs and ari_wasm_needs_arix. ci.yml's new wasm-wamr job runs them on Linux with WAMR forced on. It installs wamr and binaryen from the catalog. Three test guests change for every backend: - The gas tests' loop gains the guest ABI's memory and ari_alloc. A backend that pauses by Asyncify takes its unwind room from them. - The WASI guest's 1024 iovecs move to the top of its page. The room moves its heap, and its output then landed on them. - The GC type the gas pass refuses is bytes. binaryen writes no type that nothing uses. The client guests' cases turn the frame budget off. A ServerDocument's step doesn't advance the app's pump frame, so a budget once spent stays spent. On WAMR's interpreter it was spent before the last two guests ran. The arix recipe gains freebsd, openbsd and netbsd rows, on wamr and binaryen there instead of wasmtime. Haiku has no row because it has no python312. ariglx gets no BSD rows yet: its pycvc-gl-cp312 needs vtk-python-cp312, which has no BSD build.
cvcpkg's binaryen has no netbsd row (cy-pca/cvcpkg#648): NetBSD's base libstdc++ is GCC 10's, older than binaryen 129 needs. arix there runs on WAMR without it, taking guests transformed at install.
This was referenced Nov 27, 2026
Merged
… recipes The job installed wamr and binaryen from cvcpkg.org, which has wamr only at cvc.3 (with WAMR's own WASI, which takes a guest's WASI imports from the host) and no binaryen until cy-pca/cvcpkg#648 is published, so it failed at its install step. It now checks out that PR's recipes at a pinned commit and builds both with cvcpkg build, then installs python312 from the catalog. Once #648 is published the step goes back to cvcpkg install.
transfix
added a commit
to cy-pca/cvcpkg
that referenced
this pull request
Nov 28, 2026
…s there (#648) wamr 2.4.4+cvc.4 gains freebsd, openbsd, netbsd and haiku rows (WAMR's freebsd platform layer, software bounds checks, no SIMD; no MAP_32BIT off FreeBSD; on NetBSD no mremap, renamed popcount32/64 and PROT_MPROTECT for PaX). On every platform it builds without WAMR's own WASI and with reference types, bulk memory, tail calls and extended constants on. The windows bundle now ships the static libiwasm.lib, not iwasm.exe's import library. test.sh runs a wasm-c-api check: host re-entry, memory grow, host trap. binaryen 129 (new): static library, C++20 headers under include/binaryen, and wasm-opt, wasm-as and wasm-dis, for linux, macos, freebsd, openbsd, haiku and windows (no netbsd: base libstdc++ is too old). Both are for libcvc's WAMR guest runtime (transfix/libcvc#1592).
cy-pca/cvcpkg#648 is merged and published, so the job no longer builds them from that PR's recipes. wamr is pinned at 2.4.4+cvc.4: cvc.3 has WAMR's own WASI on.
arix's freebsd, openbsd and netbsd rows run its wasm guests on WAMR, so the tag's fleet DAG submits it with the rest of the family's BSD columns.
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.
Phase G3 of
ARIADNE_SCRIPTING_HOSTS.md: a WAMR backend behindguest_runtime.h. With it,arix(and laterariglx) can run a document's wasm guests on FreeBSD, OpenBSD, NetBSD and Haiku, where cvcpkg has no wasmtime. Its packages came in cy-pca/cvcpkg#648 (merged, on cvcpkg.org):wamrcvc.4 with BSD and Haiku rows, and a newbinaryen129.Selecting a runtime
cvc_find_ariadne_wasmtakes WAMR where it finds no wasmtime.-DCVC_ARIADNE_WASM_RUNTIME=wamrforces WAMR,=wasmtimerequires wasmtime, andautois the default.wamr_runtime.cpp, on WAMR's wasm-c-api:browser_runtime.cppdoes. The imports call the guest's ownasyncify_*exports from inside the import, which WAMR allows on the same execution environment.wasm_transform.cpp, its C++ API). Without binaryen the backend runs only transformed guests, like the browser.-O1drops an import nothing calls. So imports are judged as the guest was written, byimports_match, now shared with the browser inwasm_binary.cpp.wasm_instance_newadds a heap page.wasm_extern_as_funcis an unchecked cast.wamr_load.cpp: the native loader's validation text, and whether a binary is already metered and transformed.wasm_export.handwasm_c_api.hcan't share a file.Tests
CVC_ARIADNE_WASM_RUNTIME=wamr, wamr cvc.4 and binaryen 129 built from physics: draw a world in a scene graph between its last two states (P6a) #648's recipes:ariadne_wasm_test: 48 of 48;ariadne_wasm_transform_test: 21 of 21, including the browser's unwind-room cases and its import-type messages, which now also run on WAMR;arix_wasm_block,arix_wasi_stubsandari_wasm_needs_arix: 3 of 3.wasm-wamrjob runs the same set on Linux with WAMR forced on. It installswamr==2.4.4+cvc.4andbinaryenfrom cvcpkg.org (wamr on the BSDs and Haiku, and binaryen 129, for libcvc's wasm guests there cy-pca/cvcpkg#648, merged and published). wamr is pinned because cvc.3 has WAMR's own WASI on.ari_alloc, which an Asyncify backend takes its unwind room from.Found on the way (not fixed here)
ServerDocument'sstepdoesn't advance the app's pump frame (starts_frameruns only when group 0 has live processes). So a client guest's 8 ms frame budget (wasm_frame_budget), once spent, stays spent.WasmClientGuestTest's last two guests never got a slice. The fixture now turns the budget off, with a comment, and the pump bug itself is a follow-up.Recipes
arixgains freebsd, openbsd and netbsd rows, on wamr and binaryen instead of wasmtime.arixthere runs guests transformed at install, and no.wat.fleet-bsd-haikujob (from The libcvc family on FreeBSD, OpenBSD and NetBSD, built by the cvcpkg.org fleet on each tag #1581) now listsarix, so the next tag's fleet DAG builds those rows.ariglxgets no BSD rows yet:pycvc-gl-cp312needsvtk-python-cp312, which has no BSD build.Not to merge without Joe's OK.