summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/agent.zig4
-rw-r--r--build/llvm.zig6
2 files changed, 8 insertions, 2 deletions
diff --git a/build/agent.zig b/build/agent.zig
index 3fea2e2..c1e1dcc 100644
--- a/build/agent.zig
+++ b/build/agent.zig
@@ -4,7 +4,8 @@ const std = @import("std");
const Ctx = @import("../build.zig").Ctx;
const Compile = std.Build.Step.Compile;
-pub fn add(ctx: Ctx) void {
+/// Returns the library to preload, for what tests it with other backends.
+pub fn add(ctx: Ctx) *Compile {
const b = ctx.b;
const imports: []const std.Build.Module.Import = &.{.{ .name = "ztrace", .module = ctx.ztrace }};
@@ -163,6 +164,7 @@ pub fn add(ctx: Ctx) void {
}
bench_step.dependOn(before.?);
for ([_]*Compile{ api, api_static, api_zig }) |exe| b.installArtifact(exe);
+ return libs[0];
}
const Recording = struct { run: *std.Build.Step.Run, file: std.Build.LazyPath };
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;
}