From a380608d79ec755e857a5b5e7bacc96e6720efd5 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 09:51:56 -0300 Subject: build: the text library is optimised in every mode: FreeType and HarfBuzz are not what a Debug build debugs, and at -O0 a layout cost four to six times as much (a screen of source text laid out and drawn a frame: 2.9 ms in a Debug host, 0.6 ms with this); a ReleaseSafe or ReleaseSmall build keeps its own mode; zig build test 192/192 steps, test-text 52/52, every picture as it was Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- build.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index ccec959..7e782c4 100644 --- a/build.zig +++ b/build.zig @@ -681,7 +681,11 @@ fn cModule(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.Optimi /// host links it, and so do a sketch's tests (`App.addTest`), which measure /// text with no host; a sketch's library never does. Null until the lazy /// packages are fetched. -fn textLibrary(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) ?*Build.Step.Compile { +fn textLibrary(b: *Build, target: Build.ResolvedTarget, mode: std.builtin.OptimizeMode) ?*Build.Step.Compile { + // FreeType and HarfBuzz are not what a Debug build debugs, and at -O0 a + // layout costs four to six times as much (a screen of source text laid + // out twice a frame: 2.9 ms against 0.6): optimised in every mode. + const optimize: std.builtin.OptimizeMode = if (mode == .debug) .ReleaseFast else mode; const freetype = (b.lazyDependency("freetype", .{ .target = target, .optimize = optimize, .@"enable-libpng" = false }) orelse return null).artifact("freetype"); const harfbuzz = b.lazyDependency("harfbuzz", .{}) orelse return null; const lib = b.addLibrary(.{ .name = "sketchbook-text", .linkage = .static, .root_module = b.createModule(.{ -- cgit v1.3