| author | |
| committer | |
| log | 49d8723408233ac1c8942eca0a52ca12188040ce |
| tree | 047a8af4189c44dfb51c4f8de503ea8af0c45fa6 |
| parent | 10c9fa0e080763faa1d952f635deb8e4cc1a23e2 |
3 files changed, 11 insertions(+), 1 deletions(-)
build.zig+2| ... | ... | @@ -111,6 +111,7 @@ pub fn build(b: *Builder) !void { |
| 111 | 111 | |
| 112 | 112 | const tracy = b.option([]const u8, "tracy", "Enable Tracy integration. Supply path to Tracy source"); |
| 113 | 113 | const tracy_callstack = b.option(bool, "tracy-callstack", "Include callstack information with Tracy data. Does nothing if -Dtracy is not provided") orelse false; |
| 114 | const tracy_allocation = b.option(bool, "tracy-allocation", "Include allocation information with Tracy data. Does nothing if -Dtracy is not provided") orelse false; | |
| 114 | 115 | const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse enable_llvm; |
| 115 | 116 | const strip = b.option(bool, "strip", "Omit debug information") orelse false; |
| 116 | 117 | |
| ... | ... | @@ -266,6 +267,7 @@ pub fn build(b: *Builder) !void { |
| 266 | 267 | exe_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots); |
| 267 | 268 | exe_options.addOption(bool, "enable_tracy", tracy != null); |
| 268 | 269 | exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack); |
| 270 | exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation); | |
| 269 | 271 | exe_options.addOption(bool, "is_stage1", is_stage1); |
| 270 | 272 | exe_options.addOption(bool, "omit_stage2", omit_stage2); |
| 271 | 273 | if (tracy) |tracy_path| { |
src/main.zig+7| ... | ... | @@ -10,6 +10,7 @@ const ArrayList = std.ArrayList; |
| 10 | 10 | const Ast = std.zig.Ast; |
| 11 | 11 | const warn = std.log.warn; |
| 12 | 12 | |
| 13 | const tracy = @import("tracy.zig"); | |
| 13 | 14 | const Compilation = @import("Compilation.zig"); |
| 14 | 15 | const link = @import("link.zig"); |
| 15 | 16 | const Package = @import("Package.zig"); |
| ... | ... | @@ -155,6 +156,12 @@ pub fn main() anyerror!void { |
| 155 | 156 | const arena = &arena_instance.allocator; |
| 156 | 157 | |
| 157 | 158 | const args = try process.argsAlloc(arena); |
| 159 | ||
| 160 | if (tracy.enable_allocation) { | |
| 161 | var gpa_tracy = tracy.tracyAllocator(gpa); | |
| 162 | return mainArgs(&gpa_tracy.allocator, arena, args); | |
| 163 | } | |
| 164 | ||
| 158 | 165 | return mainArgs(gpa, arena, args); |
| 159 | 166 | } |
| 160 | 167 |
src/tracy.zig+2-1| ... | ... | @@ -2,7 +2,8 @@ const std = @import("std"); |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | 3 | |
| 4 | 4 | pub const enable = if (builtin.is_test) false else @import("build_options").enable_tracy; |
| 5 | const enable_callstack = @import("build_options").enable_tracy_callstack; | |
| 5 | pub const enable_allocation = enable and @import("build_options").enable_tracy_allocation; | |
| 6 | pub const enable_callstack = enable and @import("build_options").enable_tracy_callstack; | |
| 6 | 7 | |
| 7 | 8 | // TODO: make this configurable |
| 8 | 9 | const callstack_depth = 10; |