Skip to content

Commit ddc3994

Browse files
committed
build.zig: expose valgrind flag
Allows to enable Valgrind integrations in release builds, sometimes useful in combination with tooling.
1 parent e82f7d3 commit ddc3994

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

build.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ pub fn build(b: *std.Build) !void {
174174
const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse (enable_llvm or only_c);
175175
const sanitize_thread = b.option(bool, "sanitize-thread", "Enable thread-sanitization") orelse false;
176176
const strip = b.option(bool, "strip", "Omit debug information");
177+
const valgrind = b.option(bool, "valgrind", "Enable valgrind integration");
177178
const pie = b.option(bool, "pie", "Produce a Position Independent Executable");
178179
const value_tracing = b.option(bool, "value-tracing", "Enable extra state tracking to help troubleshoot bugs in the compiler (using the std.debug.Trace API)") orelse false;
179180

@@ -187,6 +188,7 @@ pub fn build(b: *std.Build) !void {
187188
.optimize = optimize,
188189
.target = target,
189190
.strip = strip,
191+
.valgrind = valgrind,
190192
.sanitize_thread = sanitize_thread,
191193
.single_threaded = single_threaded,
192194
});
@@ -607,6 +609,7 @@ const AddCompilerStepOptions = struct {
607609
optimize: std.builtin.OptimizeMode,
608610
target: std.Build.ResolvedTarget,
609611
strip: ?bool = null,
612+
valgrind: ?bool = null,
610613
sanitize_thread: ?bool = null,
611614
single_threaded: ?bool = null,
612615
};
@@ -622,6 +625,7 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St
622625
.sanitize_thread = options.sanitize_thread,
623626
.single_threaded = options.single_threaded,
624627
});
628+
exe.root_module.valgrind = options.valgrind;
625629
exe.stack_size = stack_size;
626630

627631
const aro_module = b.createModule(.{

0 commit comments

Comments
 (0)