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 {
168168 const tracy = b.option([]const u8, "tracy", "Enable Tracy integration. Supply path to Tracy source");
169169 const tracy_callstack = b.option(bool, "tracy-callstack", "Include callstack information with Tracy data. Does nothing if -Dtracy is not provided") orelse (tracy != null);
170170 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;
171172 const force_gpa = b.option(bool, "force-gpa", "Force the compiler to use GeneralPurposeAllocator") orelse false;
172173 const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse (enable_llvm or only_c);
173174 const sanitize_thread = b.option(bool, "sanitize-thread", "Enable thread-sanitization") orelse false;
......@@ -350,6 +351,7 @@ pub fn build(b: *std.Build) !void {
350351 exe_options.addOption(bool, "enable_tracy", tracy != null);
351352 exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack);
352353 exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);
354 exe_options.addOption(u32, "tracy_callstack_depth", tracy_callstack_depth);
353355 exe_options.addOption(bool, "value_tracing", value_tracing);
354356 if (tracy) |tracy_path| {
355357 const client_cpp = b.pathJoin(
......@@ -613,6 +615,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
613615 exe_options.addOption(bool, "enable_tracy", false);
614616 exe_options.addOption(bool, "enable_tracy_callstack", false);
615617 exe_options.addOption(bool, "enable_tracy_allocation", false);
618 exe_options.addOption(u32, "tracy_callstack_depth", 0);
616619 exe_options.addOption(bool, "value_tracing", false);
617620 exe_options.addOption(DevEnv, "dev", .bootstrap);
618621
src/tracy.zig+1-3
......@@ -5,9 +5,7 @@ const build_options = @import("build_options");
55pub const enable = if (builtin.is_test) false else build_options.enable_tracy;
66pub const enable_allocation = enable and build_options.enable_tracy_allocation;
77pub const enable_callstack = enable and build_options.enable_tracy_callstack;
8
9// TODO: make this configurable
10const callstack_depth = 10;
8pub const callstack_depth = if (enable_callstack and build_options.tracy_callstack_depth > 0) build_options.tracy_callstack_depth else 10;
119
1210const ___tracy_c_zone_context = extern struct {
1311 id: u32,