authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-16 17:26:41-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-16 23:07:34-07:00
logddc399440dd8bcb814c288e43a30f873bfbaca39
tree26cb2159324d7f2f74b9e89d7f817ceb0819e7f7
parente82f7d380013c318bfd5a918cc20d796a3882d6e

build.zig: expose valgrind flag

Allows to enable Valgrind integrations in release builds, sometimes useful in combination with tooling.

1 files changed, 4 insertions(+), 0 deletions(-)

build.zig+4
......@@ -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(.{