Skip to content
Oeiuwq Faith Blog OpenSource Porfolio

malcolmstill/zware

Zig WebAssembly Runtime Engine

malcolmstill/zware.json
{
"createdAt": "2021-02-01T04:27:54Z",
"defaultBranch": "master",
"description": "Zig WebAssembly Runtime Engine",
"fullName": "malcolmstill/zware",
"homepage": "",
"language": "Zig",
"name": "zware",
"pushedAt": "2025-10-06T17:45:59Z",
"stargazersCount": 362,
"topics": [
"wasm",
"webassembly",
"zig",
"zig-package",
"ziglang"
],
"updatedAt": "2025-11-17T19:11:15Z",
"url": "https://github.com/malcolmstill/zware"
}

zware

WebAssembly logo: a purple-blue square containing the uppercase letters W A. The square has a semicirclular notch on the top edge in the middle
Zig WebAssembly Runtime Engine

zware is a library for executing WebAssembly embedded in Zig programs.

From examples/fib:

const std = @import("std");
const zware = @import("zware");
const Store = zware.Store;
const Module = zware.Module;
const Instance = zware.Instance;
const GeneralPurposeAllocator = std.heap.GeneralPurposeAllocator;
var gpa = GeneralPurposeAllocator(.{}){};
pub fn main() !void {
defer _ = gpa.deinit();
const alloc = gpa.allocator();
const bytes = @embedFile("fib.wasm");
var store = Store.init(alloc);
defer store.deinit();
var module = Module.init(alloc, bytes);
defer module.deinit();
try module.decode();
var instance = Instance.init(alloc, &store, module);
try instance.instantiate();
defer instance.deinit();
const n = 39;
var in = [1]u64{n};
var out = [1]u64{0};
try instance.invoke("fib", in[0..], out[0..], .{});
const result: i32 = @bitCast(@as(u32, @truncate(out[0])));
std.debug.print("fib({}) = {}\n", .{ n, result });
}
  • Zig 0.15.1 (master)
  • None, zig generates static binaries:
Terminal window
zware git:(master) ldd fib
not a dynamic executable
  • Embed WebAssembly programs in other zig programs
  • Be fast enough to be useful
  • The project is very much alpha quality
  • WebAssembly 2.0 supported (apart from the vector / SIMD support which is WIP)
  • The WebAssembly official testsuite passes (not including SIMD tests)
  • Partial WASI support

Use zig build --help to see all the test targets, here’s a summary of the important ones:

Terminal window
zig build test # Run all the tests (includes unittest and testsuite)
zig build unittest # Run the library unittests
zig build testsuite # Run all the testsuite tests
zig build test-NAME # Run the NAME testsuite test, i.e. test-type

Yes, yes it does

https://github.com/malcolmstill/zware/assets/2567177/c9acdcb2-69e7-495f-b3f1-89cf6b807a43