| ... | ... | @@ -50,7 +50,6 @@ memory_blocked_steps: std.ArrayList(Configuration.Step.Index), |
| 50 | 50 | /// Allocated into `gpa`. |
| 51 | 51 | step_stack: std.AutoArrayHashMapUnmanaged(Configuration.Step.Index, void), |
| 52 | 52 | pkg_config: PkgConfig, |
| 53 | | debug_maker_leaks: bool, |
| 54 | 53 | |
| 55 | 54 | error_style: ErrorStyle, |
| 56 | 55 | multiline_errors: MultilineErrors, |
| ... | ... | @@ -73,8 +72,8 @@ pub fn main(init: process.Init.Minimal) !void { |
| 73 | 72 | // ...but we'll back our arena by `std.heap.page_allocator` for efficiency. |
| 74 | 73 | var arena_instance: std.heap.ArenaAllocator = .init(std.heap.page_allocator); |
| 75 | 74 | defer arena_instance.deinit(); |
| 75 | defer if (debugMakerLeaks()) log.debug("used {Bi} of arena", .{arena_instance.queryCapacity()}); |
| 76 | 76 | const arena = arena_instance.allocator(); |
| 77 | | defer log.info("used {Bi} of arena", .{arena_instance.queryCapacity()}); |
| 78 | 77 | |
| 79 | 78 | const args = try init.args.toSlice(arena); |
| 80 | 79 | |
| ... | ... | @@ -153,7 +152,6 @@ pub fn main(init: process.Init.Minimal) !void { |
| 153 | 152 | var debounce_interval_ms: u16 = 50; |
| 154 | 153 | var webui_listen: ?Io.net.IpAddress = null; |
| 155 | 154 | var debug_pkg_config = false; |
| 156 | | var debug_maker_leaks = false; |
| 157 | 155 | var run_args: ?[]const []const u8 = null; |
| 158 | 156 | |
| 159 | 157 | if (std.zig.EnvVar.ZIG_BUILD_ERROR_STYLE.get(&graph.environ_map)) |str| { |
| ... | ... | @@ -300,7 +298,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 300 | 298 | } else if (mem.cutPrefix(u8, arg, "--debug-rt=")) |rest| { |
| 301 | 299 | graph.debug_compiler_runtime_libs = std.meta.stringToEnum(std.builtin.OptimizeMode, rest) orelse |
| 302 | 300 | fatal("unrecognized optimization mode: {s}", .{rest}); |
| 303 | | } else if (mem.eql(u8, arg, "--debug-maker-leaks")) { |
| 301 | } else if (is_debug_mode and mem.eql(u8, arg, "--debug-maker-leaks")) { |
| 304 | 302 | debug_maker_leaks = true; |
| 305 | 303 | } else if (mem.eql(u8, arg, "--libc-runtimes") or mem.eql(u8, arg, "--glibc-runtimes")) { |
| 306 | 304 | // --glibc-runtimes was the old name of the flag; kept for compatibility for now. |
| ... | ... | @@ -543,7 +541,6 @@ pub fn main(init: process.Init.Minimal) !void { |
| 543 | 541 | .memory_blocked_steps = .empty, |
| 544 | 542 | .step_stack = .empty, |
| 545 | 543 | .pkg_config = .{ .debug = debug_pkg_config }, |
| 546 | | .debug_maker_leaks = debug_maker_leaks, |
| 547 | 544 | |
| 548 | 545 | .error_style = error_style, |
| 549 | 546 | .multiline_errors = multiline_errors, |
| ... | ... | @@ -1011,7 +1008,7 @@ fn makeStepNames( |
| 1011 | 1008 | }; |
| 1012 | 1009 | if (code == 0) { |
| 1013 | 1010 | removePoisonedConfiguration(io, maker.scanned_config); |
| 1014 | | if (builtin.mode == .Debug and maker.debug_maker_leaks) return deinit(maker); |
| 1011 | if (debugMakerLeaks()) return deinit(maker); |
| 1015 | 1012 | } |
| 1016 | 1013 | cleanup_task.await(io); // There is a defer above but an exit below. |
| 1017 | 1014 | _ = io.lockStderr(&.{}, graph.stderr_mode) catch {}; |
| ... | ... | @@ -2045,3 +2042,10 @@ fn removePoisonedConfiguration(io: Io, scanned_config: *const ScannedConfig) voi |
| 2045 | 2042 | log.warn("failed deleting poisoned configuration file {s}: {t}", .{ scanned_config.path, err }); |
| 2046 | 2043 | } |
| 2047 | 2044 | } |
| 2045 | |
| 2046 | const is_debug_mode = builtin.mode == .Debug; |
| 2047 | var debug_maker_leaks: bool = false; |
| 2048 | inline fn debugMakerLeaks() bool { |
| 2049 | if (!is_debug_mode) return false; |
| 2050 | return debug_maker_leaks; |
| 2051 | } |