From 5b8cf6f66e367192090350c9129fa341edfc9343 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 16 Nov 2026 23:00:19 -0300 Subject: Compute abi.hash's layout half once per abi change, not in every compile The comptime walk over the shared types cost about half a second of every sketch library's compile. abi_hash.zig runs it at build time, once per change of the abi sources (watched like any input), and build.zig hands the number to host and sketches as the module abi_hash; abi.hash folds in the build as before. The value is the walk's own, computed for the build machine in Debug. --- build.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'build.zig') diff --git a/build.zig b/build.zig index 1933d92..5f464ab 100644 --- a/build.zig +++ b/build.zig @@ -44,7 +44,14 @@ pub fn build(b: *Build) void { b.installArtifact(gltf_generator); // Target-free: they compile for whatever imports them, native or wasm. - const abi = b.addModule("abi", .{ .root_source_file = b.path("src/abi.zig") }); + // abi.hash's layout half, computed by a program once per change of the + // abi sources rather than at comptime in every sketch's compile. + const abi_hash = b.addRunArtifact(b.addExecutable(.{ .name = "abi-hash", .root_module = b.createModule(.{ + .root_source_file = b.path("src/abi_hash.zig"), + .target = b.graph.host, + .imports = &.{.{ .name = "abi", .module = b.createModule(.{ .root_source_file = b.path("src/abi.zig") }) }}, + }) })).captureStdOut(.{ .basename = "abi_hash.zig" }); + const abi = b.addModule("abi", .{ .root_source_file = b.path("src/abi.zig"), .imports = &.{.{ .name = "abi_hash", .module = b.createModule(.{ .root_source_file = abi_hash }) }} }); const gpu = b.addModule("gpu", .{ .root_source_file = b.path("src/gpu/Executor.zig"), .imports = &.{.{ .name = "abi", .module = abi }} }); _ = b.addModule("gpu_scene", .{ .root_source_file = b.path("src/gpu/scene.zig"), .imports = &.{.{ .name = "abi", .module = abi }} }); // Embedders provide their existing SDL translation and device. -- cgit v1.3