authorgravatar for techatrix@mailbox.orgTechatrix <techatrix@mailbox.org> 2026-08-07 21:42:18+02:00
committergravatar for techatrix@mailbox.orgTechatrix <techatrix@mailbox.org> 2026-08-29 00:45:49+02:00
log13cc8a4de6cc26a225b6c9a49bd95d85275d1c66
treecb2547d0d4b8485e2a204b5ecd2982ad006e2a8c
parent81be5b22a34424972c6b75201c510f5159f5d4f3
signature Signed by SSH key SHA256:HYC3SjXQcAt6uwv9pu/6OoVQ2rUH8rb5zKiUHSe9uxk

Maker: always detect gpa leaks in debug mode

The build runner used to run in debug mode and had leaks so `--debug-maker-leaks` was needed to opt into reporting them. Since the leaks are now fixed in the maker which runs in release mode by default, `--debug-maker-leaks` becomes unnecessary in favor of just `ZIG_DEBUG_CMD`.

1 files changed, 2 insertions(+), 14 deletions(-)

lib/compiler/Maker.zig+2-14
...@@ -163,7 +163,6 @@ pub fn main(init: process.Init.Minimal) !void {...@@ -163,7 +163,6 @@ pub fn main(init: process.Init.Minimal) !void {
163163
164 var arena_instance: std.heap.ArenaAllocator = .init(std.heap.page_allocator);164 var arena_instance: std.heap.ArenaAllocator = .init(std.heap.page_allocator);
165 defer arena_instance.deinit();165 defer arena_instance.deinit();
166 defer if (debugMakerLeaks()) log.debug("used {Bi} of arena", .{arena_instance.queryCapacity()});
167 const arena = arena_instance.allocator();166 const arena = arena_instance.allocator();
168167
169 const args = try init.args.toSlice(arena);168 const args = try init.args.toSlice(arena);
...@@ -444,8 +443,6 @@ pub fn main(init: process.Init.Minimal) !void {...@@ -444,8 +443,6 @@ pub fn main(init: process.Init.Minimal) !void {
444 } else if (mem.cutPrefix(u8, arg, "--debug-rt=")) |rest| {443 } else if (mem.cutPrefix(u8, arg, "--debug-rt=")) |rest| {
445 graph.debug_compiler_runtime_libs = stringToEnum(std.lang.Optimize, rest) orelse444 graph.debug_compiler_runtime_libs = stringToEnum(std.lang.Optimize, rest) orelse
446 fatal("unrecognized optimization mode: {s}", .{rest});445 fatal("unrecognized optimization mode: {s}", .{rest});
447 } else if (is_debug_mode and mem.eql(u8, arg, "--debug-maker-leaks")) {
448 debug_maker_leaks = true;
449 } else if (mem.eql(u8, arg, "--libc-runtimes") or mem.eql(u8, arg, "--glibc-runtimes")) {446 } else if (mem.eql(u8, arg, "--libc-runtimes") or mem.eql(u8, arg, "--glibc-runtimes")) {
450 // --glibc-runtimes was the old name of the flag; kept for compatibility for now.447 // --glibc-runtimes was the old name of the flag; kept for compatibility for now.
451 graph.libc_runtimes_dir = nextArgOrFatal(args, &arg_i);448 graph.libc_runtimes_dir = nextArgOrFatal(args, &arg_i);
...@@ -819,10 +816,7 @@ pub fn main(init: process.Init.Minimal) !void {...@@ -819,10 +816,7 @@ pub fn main(init: process.Init.Minimal) !void {
819 .message => |payload| {816 .message => |payload| {
820 const header: Client.Message.Header = try payload;817 const header: Client.Message.Header = try payload;
821 switch (header.tag) {818 switch (header.tag) {
822 .exit => {819 .exit => return cleanExit(io, &scanned_config),
823 cleanExit(io, &scanned_config);
824 process.exit(0);
825 },
826 .bsp_build_steps => {820 .bsp_build_steps => {
827 // Cancel existing file watching821 // Cancel existing file watching
828 select.cancelDiscard();822 select.cancelDiscard();
...@@ -2550,8 +2544,7 @@ fn makeSteps(...@@ -2550,8 +2544,7 @@ fn makeSteps(
2550 break :code 2; // failure; do not print build command2544 break :code 2; // failure; do not print build command
2551 };2545 };
2552 if (code == 0) {2546 if (code == 0) {
2553 removePoisonedConfiguration(io, maker.scanned_config);2547 return cleanExit(io, maker.scanned_config);
2554 if (debugMakerLeaks()) return;
2555 }2548 }
2556 cleanup_task.await(io); // There is a defer above but an exit below.2549 cleanup_task.await(io); // There is a defer above but an exit below.
2557 _ = io.lockStderr(&.{}, graph.stderr_mode) catch {};2550 _ = io.lockStderr(&.{}, graph.stderr_mode) catch {};
...@@ -3639,11 +3632,6 @@ fn removePoisonedConfiguration(io: Io, scanned_config: *const ScannedConfig) voi...@@ -3639,11 +3632,6 @@ fn removePoisonedConfiguration(io: Io, scanned_config: *const ScannedConfig) voi
3639 }3632 }
3640}3633}
36413634
3642inline fn debugMakerLeaks() bool {
3643 if (!is_debug_mode) return false;
3644 return debug_maker_leaks;
3645}
3646
3647const BuildRoot = struct {3635const BuildRoot = struct {
3648 directory: Cache.Directory,3636 directory: Cache.Directory,
3649 close_directory: bool,3637 close_directory: bool,