summaryrefslogtreecommitdiff
path: root/anim/build.zig
diff options
context:
space:
mode:
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);