summaryrefslogtreecommitdiff
path: root/anim/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-12 04:45:57 -0300
committerGabriel Schneider <[email protected]>2026-11-12 07:03:05 -0300
commit4907e35bc45d12102d0e09380994814fc2e0a369 (patch)
tree7cfd90224653d73b63fbadaf2881fa0e6ba92860 /anim/build.zig
parentebdebe04a76f0302aeb24c1ac08fa9217b1a8257 (diff)
downloadcomputeranim-4907e35bc45d12102d0e09380994814fc2e0a369.tar.gz
computeranim-4907e35bc45d12102d0e09380994814fc2e0a369.zip
canim: the introduction, from the review
The introduction records the plain build (clang -O0, no instrumentation), so reverse's frame is the compiler's own push, mov and sub. The stack chapter says its convention once and keeps four free words over rsp so a push moves the pin and nothing else; reverse's rows stand under main's and are stepped, each touching its word, the call before the push, the aim drawn head first to the row it returns to. The close-up frames the bytes and the stack together with their 128 bytes marked. Nothing is named before it is shown; offsets are written in hex as the operands are; the dump folds into its tag; the map is announced before it is shown. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'anim/build.zig')
-rw-r--r--anim/build.zig13
1 files changed, 9 insertions, 4 deletions
diff --git a/anim/build.zig b/anim/build.zig
index 7022caa..2263c61 100644
--- a/anim/build.zig
+++ b/anim/build.zig
@@ -105,6 +105,8 @@ pub fn build(b: *std.Build) void {
/// code to follow down): `-no-pie` for short addresses, bound at
/// load (`-z now`: no resolver), with the canary the compiler puts in.
glibc: bool = false,
+ /// The compiler's command for a `glibc` build, in place of its own.
+ cc: ?[]const []const u8 = null,
/// Stops after `from` before the recording ends: main's return, not the exit's.
steps: ?[]const u8 = null,
/// Ends the recording at the first stop here (`--until`).
@@ -134,9 +136,12 @@ pub fn build(b: *std.Build) void {
// (the agent's and the runtime's first calls) run through.
.{ .name = "sort", .source = "sort.c", .by = "insn", .instr = "vars", .only = "sort,a", .from = "main" },
.{ .name = "list", .source = "list.c", .by = "insn", .instr = "vars", .only = "push,reverse,head", .from = "reverse", .alloc = true },
- // The introduction's: the same program from main's call of reverse
- // (its push of the way back, reverse's prologue) to line 22, past the load.
- .{ .name = "intro", .source = "list.c", .by = "insn", .instr = "vars", .only = "push,reverse,head", .from = "list.c:41", .until = "list.c:22", .alloc = true, .program = "list" },
+ // The introduction's: the same program as the compiler alone makes it
+ // (no tracer's calls in reverse; no red zone, so its prologue makes
+ // room for its locals: `push rbp; mov rbp, rsp; sub rsp, 0x18`; its
+ // locals named by the debug info), from main's call of reverse to
+ // line 22, past the load; `head` watched, the global the list hangs from.
+ .{ .name = "intro", .source = "list.c", .by = "insn", .glibc = true, .cc = &.{ "clang", "-O0", "-g", "-mno-red-zone", "-no-pie", "-fno-stack-protector", "-Wl,-z,now" }, .from = "list.c:41", .until = "list.c:22", .alloc = true, .watch = &.{"head"}, .program = "list" },
// `hello` again, built by Zig against musl, static: no PLT; musl's
// own source (`open.c`, `syscall_cp`) on the way down to the kernel.
.{ .name = "musl", .source = "hello.c", .by = "insn", .from = "main", .steps = "166", .reads = "note" },
@@ -158,7 +163,7 @@ pub fn build(b: *std.Build) void {
cc.addArg("-o");
program = cc.addOutputFileArg(r.name);
} else if (r.glibc) {
- const cc = b.addSystemCommand(&.{ "clang", "-O0", "-g", "-no-pie", "-fstack-protector-strong", "-Wl,-z,now" });
+ const cc = b.addSystemCommand(r.cc orelse &.{ "clang", "-O0", "-g", "-no-pie", "-fstack-protector-strong", "-Wl,-z,now" });
cc.addFileArg(source);
cc.addArg("-o");
program = cc.addOutputFileArg(r.name);