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 {...@@ -174,6 +174,7 @@ pub fn build(b: *std.Build) !void {
174 const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse (enable_llvm or only_c);174 const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse (enable_llvm or only_c);
175 const sanitize_thread = b.option(bool, "sanitize-thread", "Enable thread-sanitization") orelse false;175 const sanitize_thread = b.option(bool, "sanitize-thread", "Enable thread-sanitization") orelse false;
176 const strip = b.option(bool, "strip", "Omit debug information");176 const strip = b.option(bool, "strip", "Omit debug information");
177 const valgrind = b.option(bool, "valgrind", "Enable valgrind integration");
177 const pie = b.option(bool, "pie", "Produce a Position Independent Executable");178 const pie = b.option(bool, "pie", "Produce a Position Independent Executable");
178 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;179 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 {...@@ -187,6 +188,7 @@ pub fn build(b: *std.Build) !void {
187 .optimize = optimize,188 .optimize = optimize,
188 .target = target,189 .target = target,
189 .strip = strip,190 .strip = strip,
191 .valgrind = valgrind,
190 .sanitize_thread = sanitize_thread,192 .sanitize_thread = sanitize_thread,
191 .single_threaded = single_threaded,193 .single_threaded = single_threaded,
192 });194 });
...@@ -607,6 +609,7 @@ const AddCompilerStepOptions = struct {...@@ -607,6 +609,7 @@ const AddCompilerStepOptions = struct {
607 optimize: std.builtin.OptimizeMode,609 optimize: std.builtin.OptimizeMode,
608 target: std.Build.ResolvedTarget,610 target: std.Build.ResolvedTarget,
609 strip: ?bool = null,611 strip: ?bool = null,
612 valgrind: ?bool = null,
610 sanitize_thread: ?bool = null,613 sanitize_thread: ?bool = null,
611 single_threaded: ?bool = null,614 single_threaded: ?bool = null,
612};615};
...@@ -622,6 +625,7 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St...@@ -622,6 +625,7 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St
622 .sanitize_thread = options.sanitize_thread,625 .sanitize_thread = options.sanitize_thread,
623 .single_threaded = options.single_threaded,626 .single_threaded = options.single_threaded,
624 });627 });
628 exe.root_module.valgrind = options.valgrind;
625 exe.stack_size = stack_size;629 exe.stack_size = stack_size;
626630
627 const aro_module = b.createModule(.{631 const aro_module = b.createModule(.{