authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-22 23:23:01-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-23 22:15:12-08:00
log0870f17501aa7d2eaaf2d774ccbc5d72291664ca
treebeaa280f67fa4ef4b03905e9f6b5fc3780ec8dc2
parentc05e2720a1acf0dc86e7f8a2661daae095d4d59b

fix aro and resinator compilation errors


6 files changed, 104 insertions(+), 102 deletions(-)

lib/compiler/aro/aro/Driver.zig+2-1
......@@ -134,8 +134,9 @@ strip: bool = false,
134134unwindlib: ?[]const u8 = null,
135135
136136pub fn deinit(d: *Driver) void {
137 const io = d.comp.io;
137138 for (d.link_objects.items[d.link_objects.items.len - d.temp_file_count ..]) |obj| {
138 std.fs.deleteFileAbsolute(obj) catch {};
139 Io.Dir.deleteFileAbsolute(io, obj) catch {};
139140 d.comp.gpa.free(obj);
140141 }
141142 d.inputs.deinit(d.comp.gpa);
lib/compiler/resinator/cli.zig+27-26
......@@ -125,8 +125,8 @@ pub const Diagnostics = struct {
125125 try self.errors.append(self.allocator, error_details);
126126 }
127127
128 pub fn renderToStderr(self: *Diagnostics, io: Io, args: []const []const u8) void {
129 const stderr = io.lockStderr(&.{}, null);
128 pub fn renderToStderr(self: *Diagnostics, io: Io, args: []const []const u8) Io.Cancelable!void {
129 const stderr = try io.lockStderr(&.{}, null);
130130 defer io.unlockStderr();
131131 self.renderToWriter(args, stderr.terminal()) catch return;
132132 }
......@@ -419,7 +419,7 @@ pub const Arg = struct {
419419 };
420420 }
421421
422 pub fn looksLikeFilepath(self: Arg) bool {
422 pub fn looksLikeFilepath(self: Arg, io: Io) bool {
423423 const meets_min_requirements = self.prefix == .slash and isSupportedInputExtension(std.fs.path.extension(self.full));
424424 if (!meets_min_requirements) return false;
425425
......@@ -438,7 +438,7 @@ pub const Arg = struct {
438438 // It's still possible for a file path to look like a /fo option but not actually
439439 // be one, e.g. `/foo/bar.rc`. As a last ditch effort to reduce false negatives,
440440 // check if the file path exists and, if so, then we ignore the 'could be /fo option'-ness
441 std.fs.accessAbsolute(self.full, .{}) catch return false;
441 Io.Dir.accessAbsolute(io, self.full, .{}) catch return false;
442442 return true;
443443 }
444444
......@@ -490,7 +490,7 @@ pub const ParseError = error{ParseError} || Allocator.Error;
490490
491491/// Note: Does not run `Options.maybeAppendRC` automatically. If that behavior is desired,
492492/// it must be called separately.
493pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagnostics) ParseError!Options {
493pub fn parse(allocator: Allocator, io: Io, args: []const []const u8, diagnostics: *Diagnostics) ParseError!Options {
494494 var options = Options{ .allocator = allocator };
495495 errdefer options.deinit();
496496
......@@ -530,7 +530,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn
530530 }
531531
532532 const args_remaining = args.len - arg_i;
533 if (args_remaining <= 2 and arg.looksLikeFilepath()) {
533 if (args_remaining <= 2 and arg.looksLikeFilepath(io)) {
534534 var err_details = Diagnostics.ErrorDetails{ .type = .note, .print_args = true, .arg_index = arg_i };
535535 try err_details.msg.appendSlice(allocator, "this argument was inferred to be a filepath, so argument parsing was terminated");
536536 try diagnostics.append(err_details);
......@@ -1344,41 +1344,42 @@ test parsePercent {
13441344 try std.testing.expectError(error.InvalidFormat, parsePercent("~1"));
13451345}
13461346
1347pub fn renderErrorMessage(writer: *std.Io.Writer, config: std.Io.tty.Config, err_details: Diagnostics.ErrorDetails, args: []const []const u8) !void {
1348 try config.setColor(writer, .dim);
1347pub fn renderErrorMessage(t: Io.Terminal, err_details: Diagnostics.ErrorDetails, args: []const []const u8) !void {
1348 const writer = t.writer;
1349 try t.setColor(.dim);
13491350 try writer.writeAll("<cli>");
1350 try config.setColor(writer, .reset);
1351 try config.setColor(writer, .bold);
1351 try t.setColor(.reset);
1352 try t.setColor(.bold);
13521353 try writer.writeAll(": ");
13531354 switch (err_details.type) {
13541355 .err => {
1355 try config.setColor(writer, .red);
1356 try t.setColor(.red);
13561357 try writer.writeAll("error: ");
13571358 },
13581359 .warning => {
1359 try config.setColor(writer, .yellow);
1360 try t.setColor(.yellow);
13601361 try writer.writeAll("warning: ");
13611362 },
13621363 .note => {
1363 try config.setColor(writer, .cyan);
1364 try t.setColor(.cyan);
13641365 try writer.writeAll("note: ");
13651366 },
13661367 }
1367 try config.setColor(writer, .reset);
1368 try config.setColor(writer, .bold);
1368 try t.setColor(.reset);
1369 try t.setColor(.bold);
13691370 try writer.writeAll(err_details.msg.items);
13701371 try writer.writeByte('\n');
1371 try config.setColor(writer, .reset);
1372 try t.setColor(.reset);
13721373
13731374 if (!err_details.print_args) {
13741375 try writer.writeByte('\n');
13751376 return;
13761377 }
13771378
1378 try config.setColor(writer, .dim);
1379 try t.setColor(.dim);
13791380 const prefix = " ... ";
13801381 try writer.writeAll(prefix);
1381 try config.setColor(writer, .reset);
1382 try t.setColor(.reset);
13821383
13831384 const arg_with_name = args[err_details.arg_index];
13841385 const prefix_slice = arg_with_name[0..err_details.arg_span.prefix_len];
......@@ -1389,15 +1390,15 @@ pub fn renderErrorMessage(writer: *std.Io.Writer, config: std.Io.tty.Config, err
13891390
13901391 try writer.writeAll(prefix_slice);
13911392 if (before_name_slice.len > 0) {
1392 try config.setColor(writer, .dim);
1393 try t.setColor(.dim);
13931394 try writer.writeAll(before_name_slice);
1394 try config.setColor(writer, .reset);
1395 try t.setColor(.reset);
13951396 }
13961397 try writer.writeAll(name_slice);
13971398 if (after_name_slice.len > 0) {
1398 try config.setColor(writer, .dim);
1399 try t.setColor(.dim);
13991400 try writer.writeAll(after_name_slice);
1400 try config.setColor(writer, .reset);
1401 try t.setColor(.reset);
14011402 }
14021403
14031404 var next_arg_len: usize = 0;
......@@ -1415,13 +1416,13 @@ pub fn renderErrorMessage(writer: *std.Io.Writer, config: std.Io.tty.Config, err
14151416 if (err_details.arg_span.value_offset >= arg_with_name.len) {
14161417 try writer.writeByte(' ');
14171418 }
1418 try config.setColor(writer, .dim);
1419 try t.setColor(.dim);
14191420 try writer.writeAll(" ...");
1420 try config.setColor(writer, .reset);
1421 try t.setColor(.reset);
14211422 }
14221423 try writer.writeByte('\n');
14231424
1424 try config.setColor(writer, .green);
1425 try t.setColor(.green);
14251426 try writer.splatByteAll(' ', prefix.len);
14261427 // Special case for when the option is *only* a prefix (e.g. invalid option: -)
14271428 if (err_details.arg_span.prefix_len == arg_with_name.len) {
......@@ -1447,7 +1448,7 @@ pub fn renderErrorMessage(writer: *std.Io.Writer, config: std.Io.tty.Config, err
14471448 }
14481449 }
14491450 try writer.writeByte('\n');
1450 try config.setColor(writer, .reset);
1451 try t.setColor(.reset);
14511452}
14521453
14531454fn testParse(args: []const []const u8) !Options {
lib/compiler/resinator/compile.zig+3-3
......@@ -96,7 +96,7 @@ pub fn compile(allocator: Allocator, io: Io, source: []const u8, writer: *std.Io
9696 var search_dirs: std.ArrayList(SearchDir) = .empty;
9797 defer {
9898 for (search_dirs.items) |*search_dir| {
99 search_dir.deinit(allocator);
99 search_dir.deinit(allocator, io);
100100 }
101101 search_dirs.deinit(allocator);
102102 }
......@@ -406,7 +406,7 @@ pub const Compiler = struct {
406406 // `/test.bin` relative to include paths and instead only treats it as
407407 // an absolute path.
408408 if (std.fs.path.isAbsolute(path)) {
409 const file = try utils.openFileNotDir(Io.Dir.cwd(), path, .{});
409 const file = try utils.openFileNotDir(Io.Dir.cwd(), io, path, .{});
410410 errdefer file.close(io);
411411
412412 if (self.dependencies) |dependencies| {
......@@ -418,7 +418,7 @@ pub const Compiler = struct {
418418
419419 var first_error: ?(std.Io.File.OpenError || std.Io.File.StatError) = null;
420420 for (self.search_dirs) |search_dir| {
421 if (utils.openFileNotDir(search_dir.dir, path, .{})) |file| {
421 if (utils.openFileNotDir(search_dir.dir, io, path, .{})) |file| {
422422 errdefer file.close(io);
423423
424424 if (self.dependencies) |dependencies| {
lib/compiler/resinator/errors.zig+35-35
......@@ -67,9 +67,9 @@ pub const Diagnostics = struct {
6767 return @intCast(index);
6868 }
6969
70 pub fn renderToStderr(self: *Diagnostics, cwd: Io.Dir, source: []const u8, source_mappings: ?SourceMappings) void {
70 pub fn renderToStderr(self: *Diagnostics, cwd: Io.Dir, source: []const u8, source_mappings: ?SourceMappings) Io.Cancelable!void {
7171 const io = self.io;
72 const stderr = io.lockStderr(&.{}, null);
72 const stderr = try io.lockStderr(&.{}, null);
7373 defer io.unlockStderr();
7474 for (self.errors.items) |err_details| {
7575 renderErrorMessage(io, stderr.terminal(), cwd, err_details, source, self.strings.items, source_mappings) catch return;
......@@ -901,8 +901,7 @@ const truncated_str = "<...truncated...>";
901901
902902pub fn renderErrorMessage(
903903 io: Io,
904 writer: *std.Io.Writer,
905 tty_config: std.Io.tty.Config,
904 t: Io.Terminal,
906905 cwd: Io.Dir,
907906 err_details: ErrorDetails,
908907 source: []const u8,
......@@ -927,36 +926,37 @@ pub fn renderErrorMessage(
927926
928927 const err_line = if (corresponding_span) |span| span.start_line else err_details.token.line_number;
929928
930 try tty_config.setColor(writer, .bold);
929 const writer = t.writer;
930 try t.setColor(.bold);
931931 if (corresponding_file) |file| {
932932 try writer.writeAll(file);
933933 } else {
934 try tty_config.setColor(writer, .dim);
934 try t.setColor(.dim);
935935 try writer.writeAll("<after preprocessor>");
936 try tty_config.setColor(writer, .reset);
937 try tty_config.setColor(writer, .bold);
936 try t.setColor(.reset);
937 try t.setColor(.bold);
938938 }
939939 try writer.print(":{d}:{d}: ", .{ err_line, column });
940940 switch (err_details.type) {
941941 .err => {
942 try tty_config.setColor(writer, .red);
942 try t.setColor(.red);
943943 try writer.writeAll("error: ");
944944 },
945945 .warning => {
946 try tty_config.setColor(writer, .yellow);
946 try t.setColor(.yellow);
947947 try writer.writeAll("warning: ");
948948 },
949949 .note => {
950 try tty_config.setColor(writer, .cyan);
950 try t.setColor(.cyan);
951951 try writer.writeAll("note: ");
952952 },
953953 .hint => unreachable,
954954 }
955 try tty_config.setColor(writer, .reset);
956 try tty_config.setColor(writer, .bold);
955 try t.setColor(.reset);
956 try t.setColor(.bold);
957957 try err_details.render(writer, source, strings);
958958 try writer.writeByte('\n');
959 try tty_config.setColor(writer, .reset);
959 try t.setColor(.reset);
960960
961961 if (!err_details.print_source_line) {
962962 try writer.writeByte('\n');
......@@ -983,20 +983,20 @@ pub fn renderErrorMessage(
983983
984984 try writer.writeAll(source_line_for_display.line);
985985 if (source_line_for_display.truncated) {
986 try tty_config.setColor(writer, .dim);
986 try t.setColor(.dim);
987987 try writer.writeAll(truncated_str);
988 try tty_config.setColor(writer, .reset);
988 try t.setColor(.reset);
989989 }
990990 try writer.writeByte('\n');
991991
992 try tty_config.setColor(writer, .green);
992 try t.setColor(.green);
993993 const num_spaces = truncated_visual_info.point_offset - truncated_visual_info.before_len;
994994 try writer.splatByteAll(' ', num_spaces);
995995 try writer.splatByteAll('~', truncated_visual_info.before_len);
996996 try writer.writeByte('^');
997997 try writer.splatByteAll('~', truncated_visual_info.after_len);
998998 try writer.writeByte('\n');
999 try tty_config.setColor(writer, .reset);
999 try t.setColor(.reset);
10001000
10011001 if (corresponding_span != null and corresponding_file != null) {
10021002 var worth_printing_lines: bool = true;
......@@ -1021,22 +1021,22 @@ pub fn renderErrorMessage(
10211021 break :blk null;
10221022 },
10231023 };
1024 defer if (corresponding_lines) |*cl| cl.deinit();
1024 defer if (corresponding_lines) |*cl| cl.deinit(io);
10251025
1026 try tty_config.setColor(writer, .bold);
1026 try t.setColor(.bold);
10271027 if (corresponding_file) |file| {
10281028 try writer.writeAll(file);
10291029 } else {
1030 try tty_config.setColor(writer, .dim);
1030 try t.setColor(.dim);
10311031 try writer.writeAll("<after preprocessor>");
1032 try tty_config.setColor(writer, .reset);
1033 try tty_config.setColor(writer, .bold);
1032 try t.setColor(.reset);
1033 try t.setColor(.bold);
10341034 }
10351035 try writer.print(":{d}:{d}: ", .{ err_line, column });
1036 try tty_config.setColor(writer, .cyan);
1036 try t.setColor(.cyan);
10371037 try writer.writeAll("note: ");
1038 try tty_config.setColor(writer, .reset);
1039 try tty_config.setColor(writer, .bold);
1038 try t.setColor(.reset);
1039 try t.setColor(.bold);
10401040 try writer.writeAll("this line originated from line");
10411041 if (corresponding_span.?.start_line != corresponding_span.?.end_line) {
10421042 try writer.print("s {}-{}", .{ corresponding_span.?.start_line, corresponding_span.?.end_line });
......@@ -1044,7 +1044,7 @@ pub fn renderErrorMessage(
10441044 try writer.print(" {}", .{corresponding_span.?.start_line});
10451045 }
10461046 try writer.print(" of file '{s}'\n", .{corresponding_file.?});
1047 try tty_config.setColor(writer, .reset);
1047 try t.setColor(.reset);
10481048
10491049 if (!worth_printing_lines) return;
10501050
......@@ -1055,21 +1055,21 @@ pub fn renderErrorMessage(
10551055 }) |display_line| {
10561056 try writer.writeAll(display_line.line);
10571057 if (display_line.truncated) {
1058 try tty_config.setColor(writer, .dim);
1058 try t.setColor(.dim);
10591059 try writer.writeAll(truncated_str);
1060 try tty_config.setColor(writer, .reset);
1060 try t.setColor(.reset);
10611061 }
10621062 try writer.writeByte('\n');
10631063 }
10641064 break :write_lines null;
10651065 };
10661066 if (write_lines_err) |err| {
1067 try tty_config.setColor(writer, .red);
1067 try t.setColor(.red);
10681068 try writer.writeAll(" | ");
1069 try tty_config.setColor(writer, .reset);
1070 try tty_config.setColor(writer, .dim);
1069 try t.setColor(.reset);
1070 try t.setColor(.dim);
10711071 try writer.print("unable to print line(s) from file: {s}\n", .{@errorName(err)});
1072 try tty_config.setColor(writer, .reset);
1072 try t.setColor(.reset);
10731073 }
10741074 try writer.writeByte('\n');
10751075 }
......@@ -1120,12 +1120,12 @@ const CorrespondingLines = struct {
11201120
11211121 var corresponding_lines = CorrespondingLines{
11221122 .span = corresponding_span,
1123 .file = try utils.openFileNotDir(cwd, corresponding_file, .{}),
1123 .file = try utils.openFileNotDir(cwd, io, corresponding_file, .{}),
11241124 .code_page = err_details.code_page,
11251125 .file_reader = undefined,
11261126 };
11271127 corresponding_lines.file_reader = corresponding_lines.file.reader(io, file_reader_buf);
1128 errdefer corresponding_lines.deinit();
1128 errdefer corresponding_lines.deinit(io);
11291129
11301130 try corresponding_lines.writeLineFromStreamVerbatim(
11311131 &corresponding_lines.file_reader.interface,
lib/compiler/resinator/main.zig+26-27
......@@ -64,18 +64,18 @@ pub fn main() !void {
6464 var options = options: {
6565 var cli_diagnostics = cli.Diagnostics.init(gpa);
6666 defer cli_diagnostics.deinit();
67 var options = cli.parse(gpa, cli_args, &cli_diagnostics) catch |err| switch (err) {
67 var options = cli.parse(gpa, io, cli_args, &cli_diagnostics) catch |err| switch (err) {
6868 error.ParseError => {
69 try error_handler.emitCliDiagnostics(gpa, cli_args, &cli_diagnostics);
69 try error_handler.emitCliDiagnostics(gpa, io, cli_args, &cli_diagnostics);
7070 std.process.exit(1);
7171 },
7272 else => |e| return e,
7373 };
74 try options.maybeAppendRC(Io.Dir.cwd());
74 try options.maybeAppendRC(io, Io.Dir.cwd());
7575
7676 if (!zig_integration) {
7777 // print any warnings/notes
78 cli_diagnostics.renderToStderr(io, cli_args);
78 try cli_diagnostics.renderToStderr(io, cli_args);
7979 // If there was something printed, then add an extra newline separator
8080 // so that there is a clear separation between the cli diagnostics and whatever
8181 // gets printed after
......@@ -193,7 +193,7 @@ pub fn main() !void {
193193 };
194194 },
195195 .filename => |input_filename| {
196 break :full_input Io.Dir.cwd().readFileAlloc(input_filename, gpa, .unlimited) catch |err| {
196 break :full_input Io.Dir.cwd().readFileAlloc(io, input_filename, gpa, .unlimited) catch |err| {
197197 try error_handler.emitMessage(gpa, io, .err, "unable to read input file path '{s}': {s}", .{ input_filename, @errorName(err) });
198198 std.process.exit(1);
199199 };
......@@ -206,7 +206,7 @@ pub fn main() !void {
206206 if (options.preprocess == .only) {
207207 switch (options.output_source) {
208208 .stdio => |output_file| {
209 try output_file.writeAll(full_input);
209 try output_file.writeStreamingAll(io, full_input);
210210 },
211211 .filename => |output_filename| {
212212 try Io.Dir.cwd().writeFile(io, .{ .sub_path = output_filename, .data = full_input });
......@@ -224,16 +224,16 @@ pub fn main() !void {
224224 .source = .{ .memory = .empty },
225225 }
226226 else if (options.input_format == .res)
227 IoStream.fromIoSource(options.input_source, .input) catch |err| {
227 IoStream.fromIoSource(io, options.input_source, .input) catch |err| {
228228 try error_handler.emitMessage(gpa, io, .err, "unable to read res file path '{s}': {s}", .{ options.input_source.filename, @errorName(err) });
229229 std.process.exit(1);
230230 }
231231 else
232 IoStream.fromIoSource(options.output_source, .output) catch |err| {
232 IoStream.fromIoSource(io, options.output_source, .output) catch |err| {
233233 try error_handler.emitMessage(gpa, io, .err, "unable to create output file '{s}': {s}", .{ options.output_source.filename, @errorName(err) });
234234 std.process.exit(1);
235235 };
236 defer res_stream.deinit(gpa);
236 defer res_stream.deinit(gpa, io);
237237
238238 const res_data = res_data: {
239239 if (options.input_format != .res) {
......@@ -269,7 +269,7 @@ pub fn main() !void {
269269 defer diagnostics.deinit();
270270
271271 var output_buffer: [4096]u8 = undefined;
272 var res_stream_writer = res_stream.source.writer(gpa, &output_buffer);
272 var res_stream_writer = res_stream.source.writer(gpa, io, &output_buffer);
273273 defer res_stream_writer.deinit(&res_stream.source);
274274 const output_buffered_stream = res_stream_writer.interface();
275275
......@@ -303,7 +303,7 @@ pub fn main() !void {
303303
304304 // print any warnings/notes
305305 if (!zig_integration) {
306 diagnostics.renderToStderr(io, Io.Dir.cwd(), final_input, mapping_results.mappings);
306 try diagnostics.renderToStderr(Io.Dir.cwd(), final_input, mapping_results.mappings);
307307 }
308308
309309 // write the depfile
......@@ -356,14 +356,14 @@ pub fn main() !void {
356356 };
357357 defer resources.deinit();
358358
359 var coff_stream = IoStream.fromIoSource(options.output_source, .output) catch |err| {
359 var coff_stream = IoStream.fromIoSource(io, options.output_source, .output) catch |err| {
360360 try error_handler.emitMessage(gpa, io, .err, "unable to create output file '{s}': {s}", .{ options.output_source.filename, @errorName(err) });
361361 std.process.exit(1);
362362 };
363 defer coff_stream.deinit(gpa);
363 defer coff_stream.deinit(gpa, io);
364364
365365 var coff_output_buffer: [4096]u8 = undefined;
366 var coff_output_buffered_stream = coff_stream.source.writer(gpa, &coff_output_buffer);
366 var coff_output_buffered_stream = coff_stream.source.writer(gpa, io, &coff_output_buffer);
367367
368368 var cvtres_diagnostics: cvtres.Diagnostics = .{ .none = {} };
369369 cvtres.writeCoff(gpa, coff_output_buffered_stream.interface(), resources.list.items, options.coff_options, &cvtres_diagnostics) catch |err| {
......@@ -413,22 +413,22 @@ const IoStream = struct {
413413
414414 pub const IoDirection = enum { input, output };
415415
416 pub fn fromIoSource(source: cli.Options.IoSource, io: IoDirection) !IoStream {
416 pub fn fromIoSource(io: Io, source: cli.Options.IoSource, io_direction: IoDirection) !IoStream {
417417 return .{
418418 .name = switch (source) {
419419 .filename => |filename| filename,
420 .stdio => switch (io) {
420 .stdio => switch (io_direction) {
421421 .input => "<stdin>",
422422 .output => "<stdout>",
423423 },
424424 },
425425 .intermediate = false,
426 .source = try Source.fromIoSource(source, io),
426 .source = try Source.fromIoSource(io, source, io_direction),
427427 };
428428 }
429429
430 pub fn deinit(self: *IoStream, allocator: Allocator) void {
431 self.source.deinit(allocator);
430 pub fn deinit(self: *IoStream, allocator: Allocator, io: Io) void {
431 self.source.deinit(allocator, io);
432432 }
433433
434434 pub fn cleanupAfterError(self: *IoStream, io: Io) void {
......@@ -450,11 +450,11 @@ const IoStream = struct {
450450 /// The source has been closed and any usage of the Source in this state is illegal (except deinit).
451451 closed: void,
452452
453 pub fn fromIoSource(source: cli.Options.IoSource, io: IoDirection) !Source {
453 pub fn fromIoSource(io: Io, source: cli.Options.IoSource, io_direction: IoDirection) !Source {
454454 switch (source) {
455455 .filename => |filename| return .{
456 .file = switch (io) {
457 .input => try openFileNotDir(Io.Dir.cwd(), filename, .{}),
456 .file = switch (io_direction) {
457 .input => try openFileNotDir(Io.Dir.cwd(), io, filename, .{}),
458458 .output => try Io.Dir.cwd().createFile(io, filename, .{}),
459459 },
460460 },
......@@ -641,7 +641,7 @@ fn getIncludePaths(
641641 };
642642 const target = std.zig.resolveTargetQueryOrFatal(io, target_query);
643643 const is_native_abi = target_query.isNativeAbi();
644 const detected_libc = std.zig.LibCDirs.detect(arena, zig_lib_dir, &target, is_native_abi, true, null) catch |err| switch (err) {
644 const detected_libc = std.zig.LibCDirs.detect(arena, io, zig_lib_dir, &target, is_native_abi, true, null) catch |err| switch (err) {
645645 error.OutOfMemory => |e| return e,
646646 else => return error.MingwIncludesNotFound,
647647 };
......@@ -672,7 +672,7 @@ const ErrorHandler = union(enum) {
672672
673673 try server.serveErrorBundle(error_bundle);
674674 },
675 .stderr => diagnostics.renderToStderr(io, args),
675 .stderr => return diagnostics.renderToStderr(io, args),
676676 }
677677 }
678678
......@@ -696,7 +696,7 @@ const ErrorHandler = union(enum) {
696696 },
697697 .stderr => {
698698 // aro errors have already been emitted
699 const stderr = io.lockStderr(&.{}, null);
699 const stderr = try io.lockStderr(&.{}, null);
700700 defer io.unlockStderr();
701701 try renderErrorMessage(stderr.terminal(), .err, "{s}", .{fail_msg});
702702 },
......@@ -706,7 +706,6 @@ const ErrorHandler = union(enum) {
706706 pub fn emitDiagnostics(
707707 self: *ErrorHandler,
708708 allocator: Allocator,
709 io: Io,
710709 cwd: Io.Dir,
711710 source: []const u8,
712711 diagnostics: *Diagnostics,
......@@ -719,7 +718,7 @@ const ErrorHandler = union(enum) {
719718
720719 try server.serveErrorBundle(error_bundle);
721720 },
722 .stderr => diagnostics.renderToStderr(io, cwd, source, mappings),
721 .stderr => return diagnostics.renderToStderr(cwd, source, mappings),
723722 }
724723 }
725724
lib/compiler/resinator/utils.zig+11-10
......@@ -92,31 +92,32 @@ pub const ErrorMessageType = enum { err, warning, note };
9292
9393/// Used for generic colored errors/warnings/notes, more context-specific error messages
9494/// are handled elsewhere.
95pub fn renderErrorMessage(writer: *std.Io.Writer, config: std.Io.tty.Config, msg_type: ErrorMessageType, comptime format: []const u8, args: anytype) !void {
95pub fn renderErrorMessage(t: Io.Terminal, msg_type: ErrorMessageType, comptime format: []const u8, args: anytype) !void {
96 const writer = t.writer;
9697 switch (msg_type) {
9798 .err => {
98 try config.setColor(writer, .bold);
99 try config.setColor(writer, .red);
99 try t.setColor(.bold);
100 try t.setColor(.red);
100101 try writer.writeAll("error: ");
101102 },
102103 .warning => {
103 try config.setColor(writer, .bold);
104 try config.setColor(writer, .yellow);
104 try t.setColor(.bold);
105 try t.setColor(.yellow);
105106 try writer.writeAll("warning: ");
106107 },
107108 .note => {
108 try config.setColor(writer, .reset);
109 try config.setColor(writer, .cyan);
109 try t.setColor(.reset);
110 try t.setColor(.cyan);
110111 try writer.writeAll("note: ");
111112 },
112113 }
113 try config.setColor(writer, .reset);
114 try t.setColor(.reset);
114115 if (msg_type == .err) {
115 try config.setColor(writer, .bold);
116 try t.setColor(.bold);
116117 }
117118 try writer.print(format, args);
118119 try writer.writeByte('\n');
119 try config.setColor(writer, .reset);
120 try t.setColor(.reset);
120121}
121122
122123pub fn isLineEndingPair(first: u8, second: u8) bool {