Skip to content

Installation

RequirementVersion
Zig compiler0.15.1+ (minimum 0.15.0 per build.zig.zon)
OSLinux (x86_64, aarch64) or macOS (aarch64, x86_64)

ZigBolt has zero external dependencies. Everything is implemented in pure Zig.

Terminal window
git clone https://github.com/suenot/zigbolt.git
cd zigbolt
zig build
Terminal window
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:

Terminal window
zig build test -Doptimize=ReleaseFast

ZigBolt builds with -OReleaseFast for benchmarks to enable maximum optimization.

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:

Terminal window
zig build
# Output: zig-out/lib/libzigbolt.so (Linux) or libzigbolt.dylib (macOS),
# plus the static archive zig-out/lib/libzigbolt.a

All 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:

LanguageDirectorySetup
Cbindings/cmake (or CMake); pass ZIGBOLT_LIB_PATH=/path/to/zig-out/lib if needed
Rustbindings/rustcargo build; override the library location with ZIGBOLT_LIB_PATH
Pythonbindings/pythonpip install .; finds the library via ZIGBOLT_LIB_PATH or a sibling zig-out/lib
Gobindings/gogo build ./... (cgo); defaults to the sibling zig-out/lib, override with CGO_LDFLAGS
TypeScript / Node.jsbindings/tsnpm 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 functions
extern 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;
}
import ctypes
lib = ctypes.CDLL("./zig-out/lib/libzigbolt.dylib")
lib.zigbolt_version_major.restype = ctypes.c_uint32
lib.zigbolt_version_minor.restype = ctypes.c_uint32
lib.zigbolt_version_patch.restype = ctypes.c_uint32
print(f"ZigBolt v{lib.zigbolt_version_major()}.{lib.zigbolt_version_minor()}.{lib.zigbolt_version_patch()}")
  • Shared memory via shm_open + mmap
  • Best performance with isolcpus and nohz_full kernel 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)