authorgravatar for 32079903+JustinBraben@users.noreply.github.comJustin Braben <32079903+JustinBraben@users.noreply.github.com> 2024-11-29 13:13:06-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-11-29 12:13:06-08:00
log07cd488d4216742b2a29af95e330728a0f83627f
treee55ef22c910932845a0dd0bfe28903c46eff1252
parent97b8d662e63ae90bc7b8bb29221e8b79bca5bfbe
signaturebadge-check Signed by PGP key B5690EEEBB952194

Add build option to set tracy-callstack-depth in `build.zig` (#21990)


2 files changed, 4 insertions(+), 3 deletions(-)

build.zig+3
...@@ -168,6 +168,7 @@ pub fn build(b: *std.Build) !void {...@@ -168,6 +168,7 @@ pub fn build(b: *std.Build) !void {
168 const tracy = b.option([]const u8, "tracy", "Enable Tracy integration. Supply path to Tracy source");168 const tracy = b.option([]const u8, "tracy", "Enable Tracy integration. Supply path to Tracy source");
169 const tracy_callstack = b.option(bool, "tracy-callstack", "Include callstack information with Tracy data. Does nothing if -Dtracy is not provided") orelse (tracy != null);169 const tracy_callstack = b.option(bool, "tracy-callstack", "Include callstack information with Tracy data. Does nothing if -Dtracy is not provided") orelse (tracy != null);
170 const tracy_allocation = b.option(bool, "tracy-allocation", "Include allocation information with Tracy data. Does nothing if -Dtracy is not provided") orelse (tracy != null);170 const tracy_allocation = b.option(bool, "tracy-allocation", "Include allocation information with Tracy data. Does nothing if -Dtracy is not provided") orelse (tracy != null);
171 const tracy_callstack_depth: u32 = b.option(u32, "tracy-callstack-depth", "Declare callstack depth for Tracy data. Does nothing if -Dtracy_callstack is not provided") orelse 10;
171 const force_gpa = b.option(bool, "force-gpa", "Force the compiler to use GeneralPurposeAllocator") orelse false;172 const force_gpa = b.option(bool, "force-gpa", "Force the compiler to use GeneralPurposeAllocator") orelse false;
172 const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse (enable_llvm or only_c);173 const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse (enable_llvm or only_c);
173 const sanitize_thread = b.option(bool, "sanitize-thread", "Enable thread-sanitization") orelse false;174 const sanitize_thread = b.option(bool, "sanitize-thread", "Enable thread-sanitization") orelse false;
...@@ -350,6 +351,7 @@ pub fn build(b: *std.Build) !void {...@@ -350,6 +351,7 @@ pub fn build(b: *std.Build) !void {
350 exe_options.addOption(bool, "enable_tracy", tracy != null);351 exe_options.addOption(bool, "enable_tracy", tracy != null);
351 exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack);352 exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack);
352 exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);353 exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);
354 exe_options.addOption(u32, "tracy_callstack_depth", tracy_callstack_depth);
353 exe_options.addOption(bool, "value_tracing", value_tracing);355 exe_options.addOption(bool, "value_tracing", value_tracing);
354 if (tracy) |tracy_path| {356 if (tracy) |tracy_path| {
355 const client_cpp = b.pathJoin(357 const client_cpp = b.pathJoin(
...@@ -613,6 +615,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {...@@ -613,6 +615,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
613 exe_options.addOption(bool, "enable_tracy", false);615 exe_options.addOption(bool, "enable_tracy", false);
614 exe_options.addOption(bool, "enable_tracy_callstack", false);616 exe_options.addOption(bool, "enable_tracy_callstack", false);
615 exe_options.addOption(bool, "enable_tracy_allocation", false);617 exe_options.addOption(bool, "enable_tracy_allocation", false);
618 exe_options.addOption(u32, "tracy_callstack_depth", 0);
616 exe_options.addOption(bool, "value_tracing", false);619 exe_options.addOption(bool, "value_tracing", false);
617 exe_options.addOption(DevEnv, "dev", .bootstrap);620 exe_options.addOption(DevEnv, "dev", .bootstrap);
618621
src/tracy.zig+1-3
...@@ -5,9 +5,7 @@ const build_options = @import("build_options");...@@ -5,9 +5,7 @@ const build_options = @import("build_options");
5pub const enable = if (builtin.is_test) false else build_options.enable_tracy;5pub const enable = if (builtin.is_test) false else build_options.enable_tracy;
6pub const enable_allocation = enable and build_options.enable_tracy_allocation;6pub const enable_allocation = enable and build_options.enable_tracy_allocation;
7pub const enable_callstack = enable and build_options.enable_tracy_callstack;7pub const enable_callstack = enable and build_options.enable_tracy_callstack;
88pub const callstack_depth = if (enable_callstack and build_options.tracy_callstack_depth > 0) build_options.tracy_callstack_depth else 10;
9// TODO: make this configurable
10const callstack_depth = 10;
119
12const ___tracy_c_zone_context = extern struct {10const ___tracy_c_zone_context = extern struct {
13 id: u32,11 id: u32,