authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-09-25 16:31:56+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-09-25 17:54:50+02:00
log1c2048ebcc810490cc5eb5168589edafe727fec0
tree93f6fb52103e4ec97bf46f0927235d64488934bf
parent50074a835a60736eae7aad7680654096ef3e50af

incr-check: add --debug-link flag for verbose linker logging


1 files changed, 11 insertions(+), 3 deletions(-)

tools/incr-check.zig+11-3
......@@ -3,7 +3,7 @@ const fatal = std.process.fatal;
33const Allocator = std.mem.Allocator;
44const Cache = std.Build.Cache;
55
6const usage = "usage: incr-check <zig binary path> <input file> [--zig-lib-dir lib] [--debug-zcu] [--emit none|bin|c] [--zig-cc-binary /path/to/zig]";
6const usage = "usage: incr-check <zig binary path> <input file> [--zig-lib-dir lib] [--debug-zcu] [--debug-link] [--emit none|bin|c] [--zig-cc-binary /path/to/zig]";
77
88const EmitMode = enum {
99 none,
......@@ -22,6 +22,7 @@ pub fn main() !void {
2222 var opt_cc_zig: ?[]const u8 = null;
2323 var emit: EmitMode = .bin;
2424 var debug_zcu = false;
25 var debug_link = false;
2526
2627 var arg_it = try std.process.argsWithAllocator(arena);
2728 _ = arg_it.skip();
......@@ -35,6 +36,8 @@ pub fn main() !void {
3536 opt_lib_dir = arg_it.next() orelse fatal("expected arg after '--zig-lib-dir'\n{s}", .{usage});
3637 } else if (std.mem.eql(u8, arg, "--debug-zcu")) {
3738 debug_zcu = true;
39 } else if (std.mem.eql(u8, arg, "--debug-link")) {
40 debug_link = true;
3841 } else if (std.mem.eql(u8, arg, "--zig-cc-binary")) {
3942 opt_cc_zig = arg_it.next() orelse fatal("expect arg after '--zig-cc-binary'\n{s}", .{usage});
4043 } else {
......@@ -98,6 +101,11 @@ pub fn main() !void {
98101 if (debug_zcu) {
99102 try child_args.appendSlice(arena, &.{ "--debug-log", "zcu" });
100103 }
104 if (debug_link) {
105 try child_args.appendSlice(arena, &.{ "--debug-log", "link", "--debug-log", "link_state", "--debug-log", "link_relocs" });
106 }
107
108 const debug_log_verbose = debug_zcu or debug_link;
101109
102110 var child = std.process.Child.init(child_args.items, arena);
103111 child.stdin_behavior = .Pipe;
......@@ -131,7 +139,7 @@ pub fn main() !void {
131139 .tmp_dir = tmp_dir,
132140 .tmp_dir_path = tmp_dir_path,
133141 .child = &child,
134 .allow_stderr = debug_zcu,
142 .allow_stderr = debug_log_verbose,
135143 .emit = emit,
136144 .cc_child_args = &cc_child_args,
137145 };
......@@ -148,7 +156,7 @@ pub fn main() !void {
148156 var update_node = prog_node.start(update.name, 0);
149157 defer update_node.end();
150158
151 if (debug_zcu) {
159 if (debug_log_verbose) {
152160 std.log.info("=== START UPDATE '{s}' ===", .{update.name});
153161 }
154162