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;...@@ -3,7 +3,7 @@ const fatal = std.process.fatal;
3const Allocator = std.mem.Allocator;3const Allocator = std.mem.Allocator;
4const Cache = std.Build.Cache;4const 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
8const EmitMode = enum {8const EmitMode = enum {
9 none,9 none,
...@@ -22,6 +22,7 @@ pub fn main() !void {...@@ -22,6 +22,7 @@ pub fn main() !void {
22 var opt_cc_zig: ?[]const u8 = null;22 var opt_cc_zig: ?[]const u8 = null;
23 var emit: EmitMode = .bin;23 var emit: EmitMode = .bin;
24 var debug_zcu = false;24 var debug_zcu = false;
25 var debug_link = false;
2526
26 var arg_it = try std.process.argsWithAllocator(arena);27 var arg_it = try std.process.argsWithAllocator(arena);
27 _ = arg_it.skip();28 _ = arg_it.skip();
...@@ -35,6 +36,8 @@ pub fn main() !void {...@@ -35,6 +36,8 @@ pub fn main() !void {
35 opt_lib_dir = arg_it.next() orelse fatal("expected arg after '--zig-lib-dir'\n{s}", .{usage});36 opt_lib_dir = arg_it.next() orelse fatal("expected arg after '--zig-lib-dir'\n{s}", .{usage});
36 } else if (std.mem.eql(u8, arg, "--debug-zcu")) {37 } else if (std.mem.eql(u8, arg, "--debug-zcu")) {
37 debug_zcu = true;38 debug_zcu = true;
39 } else if (std.mem.eql(u8, arg, "--debug-link")) {
40 debug_link = true;
38 } else if (std.mem.eql(u8, arg, "--zig-cc-binary")) {41 } else if (std.mem.eql(u8, arg, "--zig-cc-binary")) {
39 opt_cc_zig = arg_it.next() orelse fatal("expect arg after '--zig-cc-binary'\n{s}", .{usage});42 opt_cc_zig = arg_it.next() orelse fatal("expect arg after '--zig-cc-binary'\n{s}", .{usage});
40 } else {43 } else {
...@@ -98,6 +101,11 @@ pub fn main() !void {...@@ -98,6 +101,11 @@ pub fn main() !void {
98 if (debug_zcu) {101 if (debug_zcu) {
99 try child_args.appendSlice(arena, &.{ "--debug-log", "zcu" });102 try child_args.appendSlice(arena, &.{ "--debug-log", "zcu" });
100 }103 }
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
102 var child = std.process.Child.init(child_args.items, arena);110 var child = std.process.Child.init(child_args.items, arena);
103 child.stdin_behavior = .Pipe;111 child.stdin_behavior = .Pipe;
...@@ -131,7 +139,7 @@ pub fn main() !void {...@@ -131,7 +139,7 @@ pub fn main() !void {
131 .tmp_dir = tmp_dir,139 .tmp_dir = tmp_dir,
132 .tmp_dir_path = tmp_dir_path,140 .tmp_dir_path = tmp_dir_path,
133 .child = &child,141 .child = &child,
134 .allow_stderr = debug_zcu,142 .allow_stderr = debug_log_verbose,
135 .emit = emit,143 .emit = emit,
136 .cc_child_args = &cc_child_args,144 .cc_child_args = &cc_child_args,
137 };145 };
...@@ -148,7 +156,7 @@ pub fn main() !void {...@@ -148,7 +156,7 @@ pub fn main() !void {
148 var update_node = prog_node.start(update.name, 0);156 var update_node = prog_node.start(update.name, 0);
149 defer update_node.end();157 defer update_node.end();
150158
151 if (debug_zcu) {159 if (debug_log_verbose) {
152 std.log.info("=== START UPDATE '{s}' ===", .{update.name});160 std.log.info("=== START UPDATE '{s}' ===", .{update.name});
153 }161 }
154162