diff --git a/build.zig b/build.zig index 3ce7cc24c2..0afbe9171a 100644 --- a/build.zig +++ b/build.zig @@ -131,6 +131,7 @@ pub fn build(b: *Builder) !void { const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse enable_llvm; const strip = b.option(bool, "strip", "Omit debug information") orelse false; const use_zig0 = b.option(bool, "zig0", "Bootstrap using zig0") orelse false; + 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; const mem_leak_frames: u32 = b.option(u32, "mem-leak-frames", "How many stack frames to print when a memory leak occurs. Tests get 2x this amount.") orelse blk: { if (strip) break :blk @as(u32, 0); @@ -353,6 +354,7 @@ pub fn build(b: *Builder) !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(bool, "value_tracing", value_tracing); exe_options.addOption(bool, "is_stage1", is_stage1); exe_options.addOption(bool, "omit_stage2", omit_stage2); if (tracy) |tracy_path| { @@ -402,6 +404,7 @@ pub fn build(b: *Builder) !void { test_cases_options.addOption(bool, "enable_rosetta", b.enable_rosetta); test_cases_options.addOption(bool, "enable_darling", b.enable_darling); test_cases_options.addOption(u32, "mem_leak_frames", mem_leak_frames * 2); + test_cases_options.addOption(bool, "value_tracing", value_tracing); test_cases_options.addOption(?[]const u8, "glibc_runtimes_dir", b.glibc_runtimes_dir); test_cases_options.addOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); test_cases_options.addOption(std.SemanticVersion, "semver", semver); diff --git a/ci/azure/build.zig b/ci/azure/build.zig index 4596233bd8..12197fdf07 100644 --- a/ci/azure/build.zig +++ b/ci/azure/build.zig @@ -99,6 +99,7 @@ pub fn build(b: *Builder) !void { 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; const strip = b.option(bool, "strip", "Omit debug information") orelse false; + 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; const mem_leak_frames: u32 = b.option(u32, "mem-leak-frames", "How many stack frames to print when a memory leak occurs. Tests get 2x this amount.") orelse blk: { if (strip) break :blk @as(u32, 0); @@ -303,6 +304,7 @@ pub fn build(b: *Builder) !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(bool, "value_tracing", value_tracing); exe_options.addOption(bool, "is_stage1", is_stage1); exe_options.addOption(bool, "omit_stage2", omit_stage2); if (tracy) |tracy_path| { diff --git a/src/Module.zig b/src/Module.zig index 602b91a5ba..f03ba77a39 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -2531,7 +2531,7 @@ const TracedOffset = struct { x: i32, trace: std.debug.Trace = .{}, - const want_tracing = std.debug.Trace.enabled; + const want_tracing = build_options.value_tracing; }; /// Resolving a source location into a byte offset may require doing work diff --git a/src/config.zig.in b/src/config.zig.in index f193fddb20..104c3ed8eb 100644 --- a/src/config.zig.in +++ b/src/config.zig.in @@ -8,6 +8,7 @@ pub const semver = @import("std").SemanticVersion.parse(version) catch unreachab pub const enable_logging: bool = @ZIG_ENABLE_LOGGING_BOOL@; pub const enable_link_snapshots: bool = false; pub const enable_tracy = false; +pub const value_tracing = false; pub const is_stage1 = true; pub const skip_non_native = false; pub const omit_stage2: bool = @ZIG_OMIT_STAGE2_BOOL@;