This project demonstrates the pattern:
- A program compiled to
wasm32-unknown-unknownthat uses V8 API symbols. - The V8 API is provided as imported functions at runtime.
- The wasm binary does not embed the V8 engine.
guest/tests/*.cpp: default test sources.guest/tests/manifest.json: default test registry used by host integration tests.guest/build-test-native.sh: builds native test binaries.guest/build-test-wasix.sh: builds WASIX test wasm modules.host/: Wasmer 7.0 runtime that resolves guest imports via reallibv8.dylib.host/tests/wasix_examples_compare.rs: compares native and WASIX outputs.
- Build one guest test (native + WASIX):
./guest/build-test-native.sh version_printf
./guest/build-test-wasix.sh version_printf- Run host (Rust 1.91+; this repo includes
rust-toolchain.toml):
cargo run -p v8_host -- target/wasm32-wasix/release/version_printf.wasm wasixExpected output:
V8_VERSION_STRING=14.5.201.9
wasix_exit_code=0
Guest tests use V8 public headers (v8-version.h, v8-version-string.h) and
compile to both native and WASIX artifacts. The host runs WASIX modules with
wasmer-wasix, and test assertions enforce native vs WASIX output parity.
Run:
cargo test -p v8_hostThis validates one default path:
- native stdout equals WASIX stdout for each test case.
The default test list is loaded from guest/tests/manifest.json, so adding a
new parity test is:
- add
guest/tests/<name>.cpp - add
<name>toguest/tests/manifest.json - run
cargo test -p v8_host
Current coverage set (easy -> medium):
version_printf(v8-version-string.h)version_numbers_printf(v8-version.h)version_string_printf(v8-version-string.h)getversion_signature_printf(v8::V8::GetVersionsignature contract)setflags_from_string_printf(v8::V8::SetFlagsFromStringruntime imports)
- No custom guest APIs: guest tests only call V8 headers APIs.
- Host import names: C++ mangled symbols (for example
_ZN2v82V810GetVersionEv) are bound inhost/src/lib.rs. - Pointer-return APIs: if an API returns host memory pointers, host trampolines copy stable bytes into guest memory and return a guest pointer.
- WASIX modules: use
wasmer-wasixrunner imports as the default runtime path.
Before moving to lifecycle APIs, keep these acceptance criteria:
cargo test -p v8_hostis fully green.- every new API test has deterministic native vs WASIX stdout parity.
- no flaky behavior across repeated runs.
Planned medium-difficulty next API family:
v8::V8::SetFlagsFromCommandLine(...)(argv pointer mapping and post-parse argc/argv validation).