summaryrefslogtreecommitdiff
path: root/build/llvm.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 12:09:27 -0300
committerGabriel Schneider <[email protected]>2026-11-10 12:15:20 -0300
commita7504c6bb2ec9e906891e42bc3df28b276e67143 (patch)
treec13e680499badf341b17960341386b8199637671 /build/llvm.zig
parent937b6314c4cd6fa73daeac308fbfcf69b89add56 (diff)
downloadcomputeranim-a7504c6bb2ec9e906891e42bc3df28b276e67143.tar.gz
computeranim-a7504c6bb2ec9e906891e42bc3df28b276e67143.zip
the backends together: a ring under the debugger, strings that do not collide
ztrace record and dbg take --ring, --preload and --alloc: the target gets the ring ztrace run gives it, and the debugger drains it while the target runs (polling for the stop, so a full ring cannot hold both) and before it reports a stop. A program compiled by ztrace cc, with the agent preloaded, stopped at breakpoints, is one recording in order; test-together checks it. Recording such a program showed the debugger's file names and the pass's strings both counted from 1: event.stringId (a hash, top bit set) is now what every producer without a table of its own uses.
Diffstat (limited to 'build/llvm.zig')
-rw-r--r--build/llvm.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/build/llvm.zig b/build/llvm.zig
index a3e93cc..b346f13 100644
--- a/build/llvm.zig
+++ b/build/llvm.zig
@@ -4,7 +4,8 @@
const std = @import("std");
const Ctx = @import("../build.zig").Ctx;
-pub fn add(ctx: Ctx) void {
+/// Returns the instrumented list program, for what tests it with other backends.
+pub fn add(ctx: Ctx) std.Build.LazyPath {
const b = ctx.b;
// The runtime runs inside the target at every event: optimized whatever
@@ -33,6 +34,7 @@ pub fn add(ctx: Ctx) void {
// A recording by name: its source, how clang optimizes it (-O2 is the
// optimizer going over what the pass put in), what `ztrace cc` is told.
const Target = struct { []const u8, []const u8, []const u8, []const []const u8 };
+ var list: std.Build.LazyPath = undefined;
for ([_]Target{
.{ "fib", "fib", "-O0", &.{} },
.{ "sort", "sort", "-O0", &.{} },
@@ -57,6 +59,7 @@ pub fn add(ctx: Ctx) void {
cc.addArg("-o");
const program = cc.addOutputFileArg(b.fmt("instr_{s}", .{name}));
options.addOptionPath(b.fmt("{s}_program", .{name}), program);
+ if (std.mem.eql(u8, name, "list")) list = program;
const run = b.addRunArtifact(ctx.exe);
run.addArgs(&.{ "run", "-o" });
@@ -95,4 +98,5 @@ pub fn add(ctx: Ctx) void {
bench.addArtifactArg(rt);
bench.addDirectoryArg(b.path("targets"));
b.step("bench-llvm", "Measure the cost of compiler instrumentation").dependOn(&bench.step);
+ return list;
}