diff --git a/build.zig b/build.zig index c0ebf5407e..7dfc785ce3 100644 --- a/build.zig +++ b/build.zig @@ -168,6 +168,7 @@ pub fn build(b: *std.Build) !void { const tracy = b.option([]const u8, "tracy", "Enable Tracy integration. Supply path to Tracy source"); const tracy_callstack = b.option(bool, "tracy-callstack", "Include callstack information with Tracy data. Does nothing if -Dtracy is not provided") orelse (tracy != null); const tracy_allocation = b.option(bool, "tracy-allocation", "Include allocation information with Tracy data. Does nothing if -Dtracy is not provided") orelse (tracy != null); + 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; const force_gpa = b.option(bool, "force-gpa", "Force the compiler to use GeneralPurposeAllocator") orelse false; const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse (enable_llvm or only_c); const sanitize_thread = b.option(bool, "sanitize-thread", "Enable thread-sanitization") orelse false; @@ -350,6 +351,7 @@ pub fn build(b: *std.Build) !void { exe_options.addOption(bool, "enable_tracy", tracy != null); exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack); exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation); + exe_options.addOption(u32, "tracy_callstack_depth", tracy_callstack_depth); exe_options.addOption(bool, "value_tracing", value_tracing); if (tracy) |tracy_path| { const client_cpp = b.pathJoin( @@ -613,6 +615,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { exe_options.addOption(bool, "enable_tracy", false); exe_options.addOption(bool, "enable_tracy_callstack", false); exe_options.addOption(bool, "enable_tracy_allocation", false); + exe_options.addOption(u32, "tracy_callstack_depth", 0); exe_options.addOption(bool, "value_tracing", false); exe_options.addOption(DevEnv, "dev", .bootstrap); diff --git a/src/tracy.zig b/src/tracy.zig index 08774f9bd3..e473088922 100644 --- a/src/tracy.zig +++ b/src/tracy.zig @@ -5,9 +5,7 @@ const build_options = @import("build_options"); pub const enable = if (builtin.is_test) false else build_options.enable_tracy; pub const enable_allocation = enable and build_options.enable_tracy_allocation; pub const enable_callstack = enable and build_options.enable_tracy_callstack; - -// TODO: make this configurable -const callstack_depth = 10; +pub const callstack_depth = if (enable_callstack and build_options.tracy_callstack_depth > 0) build_options.tracy_callstack_depth else 10; const ___tracy_c_zone_context = extern struct { id: u32,