Implement --native flag for standalone executables
Add `wafer build --native` to produce self-contained native executables. The approach appends AOT-precompiled WASM and metadata to a copy of the wafer binary itself, requiring no Rust toolchain at build time. On startup, the binary checks for an appended payload (8-byte "WAFEREXE" magic trailer). If found, it deserializes the precompiled module and runs it directly, skipping CLI argument parsing entirely. Uses wasmtime's Engine::precompile_module() for AOT compilation at build time and Module::deserialize() at runtime — instant startup with no JIT. Binary layout: [wafer binary][precompiled wasm][metadata json][trailer] Trailer: payload_len(u64 LE) + metadata_len(u64 LE) + "WAFEREXE" Also refactored runner.rs: extracted shared run_module() to avoid duplication between run_wasm_bytes() and run_precompiled_bytes(). Made serialize_metadata() public for CLI use.
This commit is contained in:
@@ -172,7 +172,7 @@ fn collect_external_calls(ops: &[IrOp], ir_ids: &HashSet<WordId>, host_ids: &mut
|
||||
}
|
||||
|
||||
/// Serialize export metadata to JSON (hand-rolled, no serde dependency).
|
||||
fn serialize_metadata(m: &ExportMetadata) -> String {
|
||||
pub fn serialize_metadata(m: &ExportMetadata) -> String {
|
||||
let mut s = String::from("{\n");
|
||||
let _ = writeln!(s, " \"version\": {},", m.version);
|
||||
match m.entry_table_index {
|
||||
|
||||
Reference in New Issue
Block a user