From 05f034a3b6e7bd6712ef3b1e79b534a5966b2fd8 Mon Sep 17 00:00:00 2001 From: lodge Date: Sat, 25 Oct 2025 12:51:27 -0300 Subject: [PATCH] chore: updated build --- README.md | 8 ++++---- build.zig | 20 ++++++++++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4535e7d..05ad98b 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ The `examples/` directory contains several demonstrations: Demonstrates homomorphic integer addition using a full adder circuit: ```bash -build add_two_numbers -Doptimize=ReleaseFast -Dcpu=native +zig build add_two_numbers ``` This example adds two 16-bit numbers (402 + 304 = 706) entirely in the encrypted domain using homomorphic XOR, AND, and OR gates. See [examples/README.md](examples/README.md) for details. @@ -110,9 +110,9 @@ zig build test Run specific test modules: ```bash -zig test src/gates.zig --test-filter "gates all" -Doptimize=ReleaseFast -Dcpu=native -zig test src/utils.zig -Doptimize=ReleaseFast -Dcpu=native -zig test src/key.zig --test-filter "secret key" -Doptimize=ReleaseFast -Dcpu=native +zig test src/gates.zig --test-filter "gates all" +zig test src/utils.zig +zig test src/key.zig --test-filter "secret key" ``` **Note**: The full test suite includes cloud key generation which takes ~30 seconds. Use test filters to run faster subsets during development. diff --git a/build.zig b/build.zig index 240f579..074a1c4 100644 --- a/build.zig +++ b/build.zig @@ -1,8 +1,24 @@ const std = @import("std"); pub fn build(b: *std.Build) void { - const target = b.standardTargetOptions(.{}); - const optimize = b.standardOptimizeOption(.{}); + // Default to native CPU with all features for best performance + const target = b.standardTargetOptions(.{ + .default_target = .{ + .cpu_arch = null, // Use native architecture + .os_tag = null, // Use native OS + .abi = null, // Use native ABI + .cpu_model = .native, // Use native CPU model (enables CPU-specific optimizations) + }, + }); + + // Default to ReleaseFast for optimal performance + // TFHE is computationally intensive, so we want fast execution by default + // Can still override with -Doptimize=Debug for debugging + const optimize = b.option( + std.builtin.OptimizeMode, + "optimize", + "Prioritize performance, safety, or binary size (-O flag)", + ) orelse .ReleaseFast; // Create a module for the main source const main_module = b.addModule("main", .{