| ... | @@ -3,7 +3,7 @@ const fatal = std.process.fatal; | ... | @@ -3,7 +3,7 @@ const fatal = std.process.fatal; |
| 3 | const Allocator = std.mem.Allocator; | 3 | const Allocator = std.mem.Allocator; |
| 4 | const Cache = std.Build.Cache; | 4 | const Cache = std.Build.Cache; |
| 5 | | 5 | |
| 6 | const 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]"; | 6 | const 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]"; |
| 7 | | 7 | |
| 8 | const EmitMode = enum { | 8 | const 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; |
| 25 | | 26 | |
| 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; |
| 101 | | 109 | |
| 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(); |
| 150 | | 158 | |
| 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 | } |
| 154 | | 162 | |