Installation
Requirements
Section titled “Requirements”| Requirement | Version |
|---|---|
| Zig compiler | 0.15.1+ (minimum 0.15.0 per build.zig.zon) |
| OS | Linux (x86_64, aarch64) or macOS (aarch64, x86_64) |
ZigBolt has zero external dependencies. Everything is implemented in pure Zig.
Building from Source
Section titled “Building from Source”git clone https://github.com/suenot/zigbolt.gitcd zigboltzig buildBuild Targets
Section titled “Build Targets”zig build # Build all targets (FFI shared + static library, benchmarks)zig build test # Run all unit tests (494 tests)zig build bench # Run the full benchmark suite (bench/run_all.zig)The test suite passes in both Debug and ReleaseFast:
zig build test -Doptimize=ReleaseFastBuild Options
Section titled “Build Options”ZigBolt builds with -OReleaseFast for benchmarks to enable maximum optimization.
Using as a Zig Package
Section titled “Using as a Zig Package”Add ZigBolt as a dependency in your build.zig.zon:
.{ // Zig 0.15 requires an enum-literal name and a fingerprint // (generated by `zig init`; keep yours, do not copy this one). .name = .my_trading_system, .version = "0.1.0", .fingerprint = 0x1234567890abcdef, // replace with your own .minimum_zig_version = "0.15.0", .dependencies = .{ .zigbolt = .{ .url = "https://github.com/suenot/zigbolt/archive/v0.2.1.tar.gz", // .hash = "..." — fill in from `zig fetch` }, }, .paths = .{ "build.zig", "build.zig.zon", "src" },}Then in your build.zig:
const zigbolt = b.dependency("zigbolt", .{ .target = target, .optimize = optimize,});exe.root_module.addImport("zigbolt", zigbolt.module("zigbolt"));FFI & Language Bindings (C / Rust / Python / Go / TypeScript)
Section titled “FFI & Language Bindings (C / Rust / Python / Go / TypeScript)”Build the shared library:
zig build# Output: zig-out/lib/libzigbolt.so (Linux) or libzigbolt.dylib (macOS),# plus the static archive zig-out/lib/libzigbolt.aAll five language bindings build and pass smoke tests against this library
(each reports version 0.2.1). They live in the repository’s bindings/
directory:
| Language | Directory | Setup |
|---|---|---|
| C | bindings/c | make (or CMake); pass ZIGBOLT_LIB_PATH=/path/to/zig-out/lib if needed |
| Rust | bindings/rust | cargo build; override the library location with ZIGBOLT_LIB_PATH |
| Python | bindings/python | pip install .; finds the library via ZIGBOLT_LIB_PATH or a sibling zig-out/lib |
| Go | bindings/go | go build ./... (cgo); defaults to the sibling zig-out/lib, override with CGO_LDFLAGS |
| TypeScript / Node.js | bindings/ts | npm install; set ZIGBOLT_LIB_PATH if needed |
The ZIGBOLT_LIB_PATH environment variable is shared across the bindings
that locate the library at build/run time. It may point at the library file
itself or at the directory that contains it (for example
/path/to/zigbolt/zig-out/lib).
#include <stdint.h>
// Declare ZigBolt C-ABI functionsextern void* zigbolt_ipc_create(const char* name, uint32_t term_length);extern int32_t zigbolt_publish(void* handle, const uint8_t* data, uint32_t len, int32_t msg_type_id);extern void zigbolt_ipc_destroy(void* handle);
int main() { void* ch = zigbolt_ipc_create("/my-channel", 1 << 20); uint8_t data[] = {1, 2, 3, 4}; zigbolt_publish(ch, data, sizeof(data), 1); zigbolt_ipc_destroy(ch); return 0;}Python
Section titled “Python”import ctypes
lib = ctypes.CDLL("./zig-out/lib/libzigbolt.dylib")
lib.zigbolt_version_major.restype = ctypes.c_uint32lib.zigbolt_version_minor.restype = ctypes.c_uint32lib.zigbolt_version_patch.restype = ctypes.c_uint32
print(f"ZigBolt v{lib.zigbolt_version_major()}.{lib.zigbolt_version_minor()}.{lib.zigbolt_version_patch()}")Platform Notes
Section titled “Platform Notes”- Shared memory via
shm_open+mmap - Best performance with
isolcpusandnohz_fullkernel parameters - io_uring support planned for future versions
- Shared memory via
shm_open+mmap - Hugepages not available (gracefully falls back to regular pages)
- Cache line size: 128 bytes (Apple Silicon)