diff --git a/build.zig b/build.zig index 11fe66e..3f07d63 100644 --- a/build.zig +++ b/build.zig @@ -42,6 +42,9 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); + if (optimize == .ReleaseFast) { + main_exe.linkLibC(); + } main_exe.root_module.addImport("httpz", httpz.module("httpz")); main_exe.root_module.addImport("metrics", metrics.module("metrics")); main_exe.root_module.addImport("zul", zul.module("zul")); diff --git a/src/main.zig b/src/main.zig index 442cf93..6d01443 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,3 +1,4 @@ +const builtin = @import("builtin"); const std = @import("std"); const log = std.log.scoped(.main); const zul = @import("zul"); @@ -37,10 +38,10 @@ pub fn logHandler( } pub fn main() !void { - var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + var gpa: std.heap.GeneralPurposeAllocator(.{}) = .{}; defer _ = gpa.deinit(); - const allocator = gpa.allocator(); + const allocator = if (builtin.mode == .ReleaseFast and !builtin.is_test) std.heap.c_allocator else gpa.allocator(); var args = try zul.CommandLineArgs.parse(allocator); defer args.deinit();