| author | |
| committer | |
| log | a5b719e9eb0a196a43a88af8f62c897d1ecfa04f |
| tree | c16e729ed99629d26e529dd48f2fee668fbfd030 |
| parent | 608145c2f07d90c46cdaa8bc2013f31b965a5b8b |
17 files changed, 67 insertions(+), 71 deletions(-)
lib/compiler/aro/aro/Diagnostics.zig+5-5| ... | @@ -541,11 +541,11 @@ fn addMessage(d: *Diagnostics, msg: Message) Compilation.Error!void { | ... | @@ -541,11 +541,11 @@ fn addMessage(d: *Diagnostics, msg: Message) Compilation.Error!void { |
| 541 | 541 | ||
| 542 | switch (d.output) { | 542 | switch (d.output) { |
| 543 | .ignore => {}, | 543 | .ignore => {}, |
| 544 | .to_writer => |writer| { | 544 | .to_writer => |t| { |
| 545 | var config = writer.color; | 545 | var new_mode = t.mode; |
| 546 | if (d.color == false) config = .no_color; | 546 | if (d.color == false) new_mode = .no_color; |
| 547 | if (d.color == true and config == .no_color) config = .escape_codes; | 547 | if (d.color == true and new_mode == .no_color) new_mode = .escape_codes; |
| 548 | msg.write(writer.writer, config, d.details) catch { | 548 | msg.write(.{ .writer = t.writer, .mode = new_mode }, d.details) catch { |
| 549 | return error.FatalError; | 549 | return error.FatalError; |
| 550 | }; | 550 | }; |
| 551 | }, | 551 | }, |
lib/std/Io/Dir.zig+1-1| ... | @@ -1739,7 +1739,7 @@ pub fn setFilePermissions( | ... | @@ -1739,7 +1739,7 @@ pub fn setFilePermissions( |
| 1739 | new_permissions: File.Permissions, | 1739 | new_permissions: File.Permissions, |
| 1740 | options: SetFilePermissionsOptions, | 1740 | options: SetFilePermissionsOptions, |
| 1741 | ) SetFilePermissionsError!void { | 1741 | ) SetFilePermissionsError!void { |
| 1742 | return io.vtable.dirSetFilePermissions(io.userdata, sub_path, dir, new_permissions, options); | 1742 | return io.vtable.dirSetFilePermissions(io.userdata, dir, sub_path, new_permissions, options); |
| 1743 | } | 1743 | } |
| 1744 | 1744 | ||
| 1745 | pub const SetOwnerError = File.SetOwnerError; | 1745 | pub const SetOwnerError = File.SetOwnerError; |
lib/std/Io/Threaded.zig+1-1| ... | @@ -10139,7 +10139,7 @@ fn initLockedStderr( | ... | @@ -10139,7 +10139,7 @@ fn initLockedStderr( |
| 10139 | t.stderr_writer.interface.buffer = buffer; | 10139 | t.stderr_writer.interface.buffer = buffer; |
| 10140 | return .{ | 10140 | return .{ |
| 10141 | .file_writer = &t.stderr_writer, | 10141 | .file_writer = &t.stderr_writer, |
| 10142 | .terminal_mode = t.stderr_mode, | 10142 | .terminal_mode = terminal_mode orelse t.stderr_mode, |
| 10143 | }; | 10143 | }; |
| 10144 | } | 10144 | } |
| 10145 | 10145 |
lib/std/zig/llvm/Builder.zig+2-2| ... | @@ -9576,10 +9576,10 @@ pub fn asmValue( | ... | @@ -9576,10 +9576,10 @@ pub fn asmValue( |
| 9576 | return (try self.asmConst(ty, info, assembly, constraints)).toValue(); | 9576 | return (try self.asmConst(ty, info, assembly, constraints)).toValue(); |
| 9577 | } | 9577 | } |
| 9578 | 9578 | ||
| 9579 | pub fn dump(b: *Builder) void { | 9579 | pub fn dump(b: *Builder, io: Io) void { |
| 9580 | var buffer: [4000]u8 = undefined; | 9580 | var buffer: [4000]u8 = undefined; |
| 9581 | const stderr: Io.File = .stderr(); | 9581 | const stderr: Io.File = .stderr(); |
| 9582 | b.printToFile(stderr, &buffer) catch {}; | 9582 | b.printToFile(io, stderr, &buffer) catch {}; |
| 9583 | } | 9583 | } |
| 9584 | 9584 | ||
| 9585 | pub fn printToFilePath(b: *Builder, io: Io, dir: Io.Dir, path: []const u8) !void { | 9585 | pub fn printToFilePath(b: *Builder, io: Io, dir: Io.Dir, path: []const u8) !void { |
src/Compilation.zig+13-19| ... | @@ -2101,6 +2101,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, | ... | @@ -2101,6 +2101,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, |
| 2101 | error.Canceled => |e| return e, | 2101 | error.Canceled => |e| return e, |
| 2102 | else => {}, | 2102 | else => {}, |
| 2103 | }, | 2103 | }, |
| 2104 | error.OutOfMemory => |e| return e, | ||
| 2104 | }; | 2105 | }; |
| 2105 | } | 2106 | } |
| 2106 | } | 2107 | } |
| ... | @@ -2708,7 +2709,7 @@ fn printVerboseLlvmCpuFeatures( | ... | @@ -2708,7 +2709,7 @@ fn printVerboseLlvmCpuFeatures( |
| 2708 | root_name: []const u8, | 2709 | root_name: []const u8, |
| 2709 | target: *const std.Target, | 2710 | target: *const std.Target, |
| 2710 | cf: [*:0]const u8, | 2711 | cf: [*:0]const u8, |
| 2711 | ) Writer.Error!void { | 2712 | ) (Writer.Error || Allocator.Error)!void { |
| 2712 | try w.print("compilation: {s}\n", .{root_name}); | 2713 | try w.print("compilation: {s}\n", .{root_name}); |
| 2713 | try w.print(" target: {s}\n", .{try target.zigTriple(arena)}); | 2714 | try w.print(" target: {s}\n", .{try target.zigTriple(arena)}); |
| 2714 | try w.print(" cpu: {s}\n", .{target.cpu.model.name}); | 2715 | try w.print(" cpu: {s}\n", .{target.cpu.model.name}); |
| ... | @@ -3113,7 +3114,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE | ... | @@ -3113,7 +3114,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE |
| 3113 | 3114 | ||
| 3114 | if (build_options.enable_debug_extensions and comp.verbose_intern_pool) { | 3115 | if (build_options.enable_debug_extensions and comp.verbose_intern_pool) { |
| 3115 | std.debug.print("intern pool stats for '{s}':\n", .{comp.root_name}); | 3116 | std.debug.print("intern pool stats for '{s}':\n", .{comp.root_name}); |
| 3116 | zcu.intern_pool.dump(io); | 3117 | zcu.intern_pool.dump(); |
| 3117 | } | 3118 | } |
| 3118 | 3119 | ||
| 3119 | if (build_options.enable_debug_extensions and comp.verbose_generic_instances) { | 3120 | if (build_options.enable_debug_extensions and comp.verbose_generic_instances) { |
| ... | @@ -3320,11 +3321,8 @@ pub fn resolveEmitPathFlush( | ... | @@ -3320,11 +3321,8 @@ pub fn resolveEmitPathFlush( |
| 3320 | }, | 3321 | }, |
| 3321 | } | 3322 | } |
| 3322 | } | 3323 | } |
| 3323 | fn flush( | 3324 | |
| 3324 | comp: *Compilation, | 3325 | fn flush(comp: *Compilation, arena: Allocator, tid: Zcu.PerThread.Id) (Io.Cancelable || Allocator.Error)!void { |
| 3325 | arena: Allocator, | ||
| 3326 | tid: Zcu.PerThread.Id, | ||
| 3327 | ) Allocator.Error!void { | ||
| 3328 | const io = comp.io; | 3326 | const io = comp.io; |
| 3329 | if (comp.zcu) |zcu| { | 3327 | if (comp.zcu) |zcu| { |
| 3330 | if (zcu.llvm_object) |llvm_object| { | 3328 | if (zcu.llvm_object) |llvm_object| { |
| ... | @@ -3390,7 +3388,7 @@ fn flush( | ... | @@ -3390,7 +3388,7 @@ fn flush( |
| 3390 | // This is needed before reading the error flags. | 3388 | // This is needed before reading the error flags. |
| 3391 | lf.flush(arena, tid, comp.link_prog_node) catch |err| switch (err) { | 3389 | lf.flush(arena, tid, comp.link_prog_node) catch |err| switch (err) { |
| 3392 | error.LinkFailure => {}, // Already reported. | 3390 | error.LinkFailure => {}, // Already reported. |
| 3393 | error.OutOfMemory => return error.OutOfMemory, | 3391 | error.OutOfMemory, error.Canceled => |e| return e, |
| 3394 | }; | 3392 | }; |
| 3395 | } | 3393 | } |
| 3396 | if (comp.zcu) |zcu| { | 3394 | if (comp.zcu) |zcu| { |
| ... | @@ -3614,6 +3612,7 @@ fn emitFromCObject( | ... | @@ -3614,6 +3612,7 @@ fn emitFromCObject( |
| 3614 | new_ext: []const u8, | 3612 | new_ext: []const u8, |
| 3615 | unresolved_emit_path: []const u8, | 3613 | unresolved_emit_path: []const u8, |
| 3616 | ) Allocator.Error!void { | 3614 | ) Allocator.Error!void { |
| 3615 | const io = comp.io; | ||
| 3617 | // The dirname and stem (i.e. everything but the extension), of the sub path of the C object. | 3616 | // The dirname and stem (i.e. everything but the extension), of the sub path of the C object. |
| 3618 | // We'll append `new_ext` to it to get the path to the right thing (asm, LLVM IR, etc). | 3617 | // We'll append `new_ext` to it to get the path to the right thing (asm, LLVM IR, etc). |
| 3619 | const c_obj_dir_and_stem: []const u8 = p: { | 3618 | const c_obj_dir_and_stem: []const u8 = p: { |
| ... | @@ -3623,23 +3622,18 @@ fn emitFromCObject( | ... | @@ -3623,23 +3622,18 @@ fn emitFromCObject( |
| 3623 | }; | 3622 | }; |
| 3624 | const src_path: Cache.Path = .{ | 3623 | const src_path: Cache.Path = .{ |
| 3625 | .root_dir = c_obj_path.root_dir, | 3624 | .root_dir = c_obj_path.root_dir, |
| 3626 | .sub_path = try std.fmt.allocPrint(arena, "{s}{s}", .{ | 3625 | .sub_path = try std.fmt.allocPrint(arena, "{s}{s}", .{ c_obj_dir_and_stem, new_ext }), |
| 3627 | c_obj_dir_and_stem, | ||
| 3628 | new_ext, | ||
| 3629 | }), | ||
| 3630 | }; | 3626 | }; |
| 3631 | const emit_path = comp.resolveEmitPath(unresolved_emit_path); | 3627 | const emit_path = comp.resolveEmitPath(unresolved_emit_path); |
| 3632 | 3628 | ||
| 3633 | src_path.root_dir.handle.copyFile( | 3629 | Io.Dir.copyFile( |
| 3630 | src_path.root_dir.handle, | ||
| 3634 | src_path.sub_path, | 3631 | src_path.sub_path, |
| 3635 | emit_path.root_dir.handle, | 3632 | emit_path.root_dir.handle, |
| 3636 | emit_path.sub_path, | 3633 | emit_path.sub_path, |
| 3634 | io, | ||
| 3637 | .{}, | 3635 | .{}, |
| 3638 | ) catch |err| log.err("unable to copy '{f}' to '{f}': {s}", .{ | 3636 | ) catch |err| log.err("unable to copy '{f}' to '{f}': {t}", .{ src_path, emit_path, err }); |
| 3639 | src_path, | ||
| 3640 | emit_path, | ||
| 3641 | @errorName(err), | ||
| 3642 | }); | ||
| 3643 | } | 3637 | } |
| 3644 | 3638 | ||
| 3645 | /// Having the file open for writing is problematic as far as executing the | 3639 | /// Having the file open for writing is problematic as far as executing the |
| ... | @@ -7787,7 +7781,7 @@ pub fn lockAndSetMiscFailure( | ... | @@ -7787,7 +7781,7 @@ pub fn lockAndSetMiscFailure( |
| 7787 | 7781 | ||
| 7788 | pub fn dumpArgv(io: Io, argv: []const []const u8) Io.Cancelable!void { | 7782 | pub fn dumpArgv(io: Io, argv: []const []const u8) Io.Cancelable!void { |
| 7789 | var buffer: [64]u8 = undefined; | 7783 | var buffer: [64]u8 = undefined; |
| 7790 | const stderr = try io.lockStderr(&buffer); | 7784 | const stderr = try io.lockStderr(&buffer, null); |
| 7791 | defer io.unlockStderr(); | 7785 | defer io.unlockStderr(); |
| 7792 | const w = &stderr.file_writer.interface; | 7786 | const w = &stderr.file_writer.interface; |
| 7793 | return dumpArgvWriter(w, argv) catch |err| switch (err) { | 7787 | return dumpArgvWriter(w, argv) catch |err| switch (err) { |
src/InternPool.zig+13-13| ... | @@ -11167,16 +11167,16 @@ pub fn mutateVarInit(ip: *InternPool, io: Io, index: Index, init_index: Index) v | ... | @@ -11167,16 +11167,16 @@ pub fn mutateVarInit(ip: *InternPool, io: Io, index: Index, init_index: Index) v |
| 11167 | @atomicStore(u32, &extra_items[item.data + std.meta.fieldIndex(Tag.Variable, "init").?], @intFromEnum(init_index), .release); | 11167 | @atomicStore(u32, &extra_items[item.data + std.meta.fieldIndex(Tag.Variable, "init").?], @intFromEnum(init_index), .release); |
| 11168 | } | 11168 | } |
| 11169 | 11169 | ||
| 11170 | pub fn dump(ip: *const InternPool, io: Io) Io.Cancelable!void { | 11170 | pub fn dump(ip: *const InternPool) void { |
| 11171 | var buffer: [4096]u8 = undefined; | 11171 | var buffer: [4096]u8 = undefined; |
| 11172 | const stderr = try io.lockStderr(&buffer, null); | 11172 | const stderr = std.debug.lockStderr(&buffer); |
| 11173 | defer io.unlockStderr(); | 11173 | defer std.debug.unlockStderr(); |
| 11174 | const w = &stderr.file_writer.interface; | 11174 | const w = &stderr.file_writer.interface; |
| 11175 | try dumpStatsFallible(ip, w, std.heap.page_allocator); | 11175 | dumpStatsFallible(ip, w, std.heap.page_allocator) catch return; |
| 11176 | try dumpAllFallible(ip, w); | 11176 | dumpAllFallible(ip, w) catch return; |
| 11177 | } | 11177 | } |
| 11178 | 11178 | ||
| 11179 | fn dumpStatsFallible(ip: *const InternPool, w: *Io.Writer, arena: Allocator) anyerror!void { | 11179 | fn dumpStatsFallible(ip: *const InternPool, w: *Io.Writer, arena: Allocator) !void { |
| 11180 | var items_len: usize = 0; | 11180 | var items_len: usize = 0; |
| 11181 | var extra_len: usize = 0; | 11181 | var extra_len: usize = 0; |
| 11182 | var limbs_len: usize = 0; | 11182 | var limbs_len: usize = 0; |
| ... | @@ -11429,9 +11429,9 @@ fn dumpStatsFallible(ip: *const InternPool, w: *Io.Writer, arena: Allocator) any | ... | @@ -11429,9 +11429,9 @@ fn dumpStatsFallible(ip: *const InternPool, w: *Io.Writer, arena: Allocator) any |
| 11429 | }; | 11429 | }; |
| 11430 | counts.sort(SortContext{ .map = &counts }); | 11430 | counts.sort(SortContext{ .map = &counts }); |
| 11431 | const len = @min(50, counts.count()); | 11431 | const len = @min(50, counts.count()); |
| 11432 | w.print(" top 50 tags:\n", .{}); | 11432 | try w.print(" top 50 tags:\n", .{}); |
| 11433 | for (counts.keys()[0..len], counts.values()[0..len]) |tag, stats| { | 11433 | for (counts.keys()[0..len], counts.values()[0..len]) |tag, stats| { |
| 11434 | w.print(" {t}: {d} occurrences, {d} total bytes\n", .{ tag, stats.count, stats.bytes }); | 11434 | try w.print(" {t}: {d} occurrences, {d} total bytes\n", .{ tag, stats.count, stats.bytes }); |
| 11435 | } | 11435 | } |
| 11436 | } | 11436 | } |
| 11437 | 11437 | ||
| ... | @@ -11534,12 +11534,12 @@ fn dumpAllFallible(ip: *const InternPool, w: *Io.Writer) anyerror!void { | ... | @@ -11534,12 +11534,12 @@ fn dumpAllFallible(ip: *const InternPool, w: *Io.Writer) anyerror!void { |
| 11534 | } | 11534 | } |
| 11535 | } | 11535 | } |
| 11536 | 11536 | ||
| 11537 | pub fn dumpGenericInstances(ip: *const InternPool, io: Io, allocator: Allocator) Io.Cancelable!void { | 11537 | pub fn dumpGenericInstances(ip: *const InternPool, allocator: Allocator) void { |
| 11538 | var buffer: [4096]u8 = undefined; | 11538 | var buffer: [4096]u8 = undefined; |
| 11539 | const stderr_writer = try io.lockStderr(&buffer, null); | 11539 | const stderr = std.debug.lockStderr(&buffer); |
| 11540 | defer io.unlockStderr(); | 11540 | defer std.debug.unlockStderr(); |
| 11541 | const w = &stderr_writer.interface; | 11541 | const w = &stderr.file_writer.interface; |
| 11542 | try ip.dumpGenericInstancesFallible(allocator, w); | 11542 | ip.dumpGenericInstancesFallible(allocator, w) catch return; |
| 11543 | } | 11543 | } |
| 11544 | 11544 | ||
| 11545 | pub fn dumpGenericInstancesFallible(ip: *const InternPool, allocator: Allocator, w: *Io.Writer) !void { | 11545 | pub fn dumpGenericInstancesFallible(ip: *const InternPool, allocator: Allocator, w: *Io.Writer) !void { |
src/Package/Fetch.zig+6-9| ... | @@ -1682,18 +1682,18 @@ fn hashFileFallible(io: Io, dir: Io.Dir, hashed_file: *HashedFile) HashedFile.Er | ... | @@ -1682,18 +1682,18 @@ fn hashFileFallible(io: Io, dir: Io.Dir, hashed_file: *HashedFile) HashedFile.Er |
| 1682 | hasher.update(&.{ 0, 0 }); | 1682 | hasher.update(&.{ 0, 0 }); |
| 1683 | var file_header: FileHeader = .{}; | 1683 | var file_header: FileHeader = .{}; |
| 1684 | while (true) { | 1684 | while (true) { |
| 1685 | const bytes_read = try file.read(&buf); | 1685 | const bytes_read = try file.readPositional(io, &.{&buf}, file_size); |
| 1686 | if (bytes_read == 0) break; | 1686 | if (bytes_read == 0) break; |
| 1687 | file_size += bytes_read; | 1687 | file_size += bytes_read; |
| 1688 | hasher.update(buf[0..bytes_read]); | 1688 | hasher.update(buf[0..bytes_read]); |
| 1689 | file_header.update(buf[0..bytes_read]); | 1689 | file_header.update(buf[0..bytes_read]); |
| 1690 | } | 1690 | } |
| 1691 | if (file_header.isExecutable()) { | 1691 | if (file_header.isExecutable()) { |
| 1692 | try setExecutable(file); | 1692 | try setExecutable(io, file); |
| 1693 | } | 1693 | } |
| 1694 | }, | 1694 | }, |
| 1695 | .link => { | 1695 | .link => { |
| 1696 | const link_name = try dir.readLink(io, hashed_file.fs_path, &buf); | 1696 | const link_name = buf[0..try dir.readLink(io, hashed_file.fs_path, &buf)]; |
| 1697 | if (fs.path.sep != canonical_sep) { | 1697 | if (fs.path.sep != canonical_sep) { |
| 1698 | // Package hashes are intended to be consistent across | 1698 | // Package hashes are intended to be consistent across |
| 1699 | // platforms which means we must normalize path separators | 1699 | // platforms which means we must normalize path separators |
| ... | @@ -1711,12 +1711,9 @@ fn deleteFileFallible(io: Io, dir: Io.Dir, deleted_file: *DeletedFile) DeletedFi | ... | @@ -1711,12 +1711,9 @@ fn deleteFileFallible(io: Io, dir: Io.Dir, deleted_file: *DeletedFile) DeletedFi |
| 1711 | try dir.deleteFile(io, deleted_file.fs_path); | 1711 | try dir.deleteFile(io, deleted_file.fs_path); |
| 1712 | } | 1712 | } |
| 1713 | 1713 | ||
| 1714 | fn setExecutable(file: Io.File) !void { | 1714 | fn setExecutable(io: Io, file: Io.File) !void { |
| 1715 | if (!Io.File.Permissions.has_executable_bit) return; | 1715 | if (!Io.File.Permissions.has_executable_bit) return; |
| 1716 | 1716 | try file.setPermissions(io, .executable_file); | |
| 1717 | const S = std.posix.S; | ||
| 1718 | const mode = Io.File.default_mode | S.IXUSR | S.IXGRP | S.IXOTH; | ||
| 1719 | try file.chmod(mode); | ||
| 1720 | } | 1717 | } |
| 1721 | 1718 | ||
| 1722 | const DeletedFile = struct { | 1719 | const DeletedFile = struct { |
| ... | @@ -1738,7 +1735,7 @@ const HashedFile = struct { | ... | @@ -1738,7 +1735,7 @@ const HashedFile = struct { |
| 1738 | 1735 | ||
| 1739 | const Error = | 1736 | const Error = |
| 1740 | Io.File.OpenError || | 1737 | Io.File.OpenError || |
| 1741 | Io.File.Reader.Error || | 1738 | Io.File.ReadPositionalError || |
| 1742 | Io.File.StatError || | 1739 | Io.File.StatError || |
| 1743 | Io.File.SetPermissionsError || | 1740 | Io.File.SetPermissionsError || |
| 1744 | Io.Dir.ReadLinkError; | 1741 | Io.Dir.ReadLinkError; |
src/codegen/aarch64/Select.zig+1-1| ... | @@ -11280,7 +11280,7 @@ pub fn dumpValues(isel: *Select, which: enum { only_referenced, all }) void { | ... | @@ -11280,7 +11280,7 @@ pub fn dumpValues(isel: *Select, which: enum { only_referenced, all }) void { |
| 11280 | 11280 | ||
| 11281 | errdefer |err| @panic(@errorName(err)); | 11281 | errdefer |err| @panic(@errorName(err)); |
| 11282 | 11282 | ||
| 11283 | const locked_stderr = std.debug.lockStderr(&.{}, null); | 11283 | const locked_stderr = std.debug.lockStderr(&.{}); |
| 11284 | defer std.debug.unlockStderr(); | 11284 | defer std.debug.unlockStderr(); |
| 11285 | const stderr = &locked_stderr.file_writer.interface; | 11285 | const stderr = &locked_stderr.file_writer.interface; |
| 11286 | 11286 |
src/codegen/llvm.zig+9-9| ... | @@ -965,10 +965,10 @@ pub const Object = struct { | ... | @@ -965,10 +965,10 @@ pub const Object = struct { |
| 965 | const context, const module = emit: { | 965 | const context, const module = emit: { |
| 966 | if (options.pre_ir_path) |path| { | 966 | if (options.pre_ir_path) |path| { |
| 967 | if (std.mem.eql(u8, path, "-")) { | 967 | if (std.mem.eql(u8, path, "-")) { |
| 968 | o.builder.dump(); | 968 | o.builder.dump(io); |
| 969 | } else { | 969 | } else { |
| 970 | o.builder.printToFilePath(Io.Dir.cwd(), path) catch |err| { | 970 | o.builder.printToFilePath(io, Io.Dir.cwd(), path) catch |err| { |
| 971 | log.err("failed printing LLVM module to \"{s}\": {s}", .{ path, @errorName(err) }); | 971 | log.err("failed printing LLVM module to \"{s}\": {t}", .{ path, err }); |
| 972 | }; | 972 | }; |
| 973 | } | 973 | } |
| 974 | } | 974 | } |
| ... | @@ -982,12 +982,12 @@ pub const Object = struct { | ... | @@ -982,12 +982,12 @@ pub const Object = struct { |
| 982 | 982 | ||
| 983 | if (options.pre_bc_path) |path| { | 983 | if (options.pre_bc_path) |path| { |
| 984 | var file = Io.Dir.cwd().createFile(io, path, .{}) catch |err| | 984 | var file = Io.Dir.cwd().createFile(io, path, .{}) catch |err| |
| 985 | return diags.fail("failed to create '{s}': {s}", .{ path, @errorName(err) }); | 985 | return diags.fail("failed to create '{s}': {t}", .{ path, err }); |
| 986 | defer file.close(io); | 986 | defer file.close(io); |
| 987 | 987 | ||
| 988 | const ptr: [*]const u8 = @ptrCast(bitcode.ptr); | 988 | const ptr: [*]const u8 = @ptrCast(bitcode.ptr); |
| 989 | file.writeAll(ptr[0..(bitcode.len * 4)]) catch |err| | 989 | file.writeStreamingAll(io, ptr[0..(bitcode.len * 4)]) catch |err| |
| 990 | return diags.fail("failed to write to '{s}': {s}", .{ path, @errorName(err) }); | 990 | return diags.fail("failed to write to '{s}': {t}", .{ path, err }); |
| 991 | } | 991 | } |
| 992 | 992 | ||
| 993 | if (options.asm_path == null and options.bin_path == null and | 993 | if (options.asm_path == null and options.bin_path == null and |
| ... | @@ -995,12 +995,12 @@ pub const Object = struct { | ... | @@ -995,12 +995,12 @@ pub const Object = struct { |
| 995 | 995 | ||
| 996 | if (options.post_bc_path) |path| { | 996 | if (options.post_bc_path) |path| { |
| 997 | var file = Io.Dir.cwd().createFile(io, path, .{}) catch |err| | 997 | var file = Io.Dir.cwd().createFile(io, path, .{}) catch |err| |
| 998 | return diags.fail("failed to create '{s}': {s}", .{ path, @errorName(err) }); | 998 | return diags.fail("failed to create '{s}': {t}", .{ path, err }); |
| 999 | defer file.close(io); | 999 | defer file.close(io); |
| 1000 | 1000 | ||
| 1001 | const ptr: [*]const u8 = @ptrCast(bitcode.ptr); | 1001 | const ptr: [*]const u8 = @ptrCast(bitcode.ptr); |
| 1002 | file.writeAll(ptr[0..(bitcode.len * 4)]) catch |err| | 1002 | file.writeStreamingAll(io, ptr[0..(bitcode.len * 4)]) catch |err| |
| 1003 | return diags.fail("failed to write to '{s}': {s}", .{ path, @errorName(err) }); | 1003 | return diags.fail("failed to write to '{s}': {t}", .{ path, err }); |
| 1004 | } | 1004 | } |
| 1005 | 1005 | ||
| 1006 | if (!build_options.have_llvm or !comp.config.use_lib_llvm) { | 1006 | if (!build_options.have_llvm or !comp.config.use_lib_llvm) { |
src/libs/mingw.zig+1| ... | @@ -345,6 +345,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { | ... | @@ -345,6 +345,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { |
| 345 | if (msg.kind == .@"fatal error" or msg.kind == .@"error") { | 345 | if (msg.kind == .@"fatal error" or msg.kind == .@"error") { |
| 346 | msg.write(stderr.terminal(), true) catch |err| switch (err) { | 346 | msg.write(stderr.terminal(), true) catch |err| switch (err) { |
| 347 | error.WriteFailed => return stderr.file_writer.err.?, | 347 | error.WriteFailed => return stderr.file_writer.err.?, |
| 348 | error.Unexpected => |e| return e, | ||
| 348 | }; | 349 | }; |
| 349 | return error.AroPreprocessorFailed; | 350 | return error.AroPreprocessorFailed; |
| 350 | } | 351 | } |
src/link.zig+1-2| ... | @@ -900,10 +900,9 @@ pub const File = struct { | ... | @@ -900,10 +900,9 @@ pub const File = struct { |
| 900 | } | 900 | } |
| 901 | } | 901 | } |
| 902 | 902 | ||
| 903 | pub const FlushError = error{ | 903 | pub const FlushError = Io.Cancelable || Allocator.Error || error{ |
| 904 | /// Indicates an error will be present in `Compilation.link_diags`. | 904 | /// Indicates an error will be present in `Compilation.link_diags`. |
| 905 | LinkFailure, | 905 | LinkFailure, |
| 906 | OutOfMemory, | ||
| 907 | }; | 906 | }; |
| 908 | 907 | ||
| 909 | /// Commit pending changes and write headers. Takes into account final output mode. | 908 | /// Commit pending changes and write headers. Takes into account final output mode. |
src/link/Elf.zig+3-2| ... | @@ -748,9 +748,10 @@ pub fn flush(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std | ... | @@ -748,9 +748,10 @@ pub fn flush(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std |
| 748 | defer tracy.end(); | 748 | defer tracy.end(); |
| 749 | 749 | ||
| 750 | const comp = self.base.comp; | 750 | const comp = self.base.comp; |
| 751 | const io = comp.io; | ||
| 751 | const diags = &comp.link_diags; | 752 | const diags = &comp.link_diags; |
| 752 | 753 | ||
| 753 | if (comp.verbose_link) Compilation.dump_argv(self.dump_argv_list.items); | 754 | if (comp.verbose_link) try Compilation.dumpArgv(io, self.dump_argv_list.items); |
| 754 | 755 | ||
| 755 | const sub_prog_node = prog_node.start("ELF Flush", 0); | 756 | const sub_prog_node = prog_node.start("ELF Flush", 0); |
| 756 | defer sub_prog_node.end(); | 757 | defer sub_prog_node.end(); |
| ... | @@ -758,7 +759,7 @@ pub fn flush(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std | ... | @@ -758,7 +759,7 @@ pub fn flush(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std |
| 758 | return flushInner(self, arena, tid) catch |err| switch (err) { | 759 | return flushInner(self, arena, tid) catch |err| switch (err) { |
| 759 | error.OutOfMemory => return error.OutOfMemory, | 760 | error.OutOfMemory => return error.OutOfMemory, |
| 760 | error.LinkFailure => return error.LinkFailure, | 761 | error.LinkFailure => return error.LinkFailure, |
| 761 | else => |e| return diags.fail("ELF flush failed: {s}", .{@errorName(e)}), | 762 | else => |e| return diags.fail("ELF flush failed: {t}", .{e}), |
| 762 | }; | 763 | }; |
| 763 | } | 764 | } |
| 764 | 765 |
src/link/Lld.zig+1-1| ... | @@ -1588,7 +1588,7 @@ fn spawnLld(comp: *Compilation, arena: Allocator, argv: []const []const u8) !voi | ... | @@ -1588,7 +1588,7 @@ fn spawnLld(comp: *Compilation, arena: Allocator, argv: []const []const u8) !voi |
| 1588 | 1588 | ||
| 1589 | if (comp.verbose_link) { | 1589 | if (comp.verbose_link) { |
| 1590 | // Skip over our own name so that the LLD linker name is the first argv item. | 1590 | // Skip over our own name so that the LLD linker name is the first argv item. |
| 1591 | Compilation.dump_argv(argv[1..]); | 1591 | try Compilation.dumpArgv(io, argv[1..]); |
| 1592 | } | 1592 | } |
| 1593 | 1593 | ||
| 1594 | // If possible, we run LLD as a child process because it does not always | 1594 | // If possible, we run LLD as a child process because it does not always |
src/link/MachO.zig+5-3| ... | @@ -618,14 +618,16 @@ pub fn flush( | ... | @@ -618,14 +618,16 @@ pub fn flush( |
| 618 | }; | 618 | }; |
| 619 | const emit = self.base.emit; | 619 | const emit = self.base.emit; |
| 620 | invalidateKernelCache(emit.root_dir.handle, emit.sub_path) catch |err| switch (err) { | 620 | invalidateKernelCache(emit.root_dir.handle, emit.sub_path) catch |err| switch (err) { |
| 621 | else => |e| return diags.fail("failed to invalidate kernel cache: {s}", .{@errorName(e)}), | 621 | else => |e| return diags.fail("failed to invalidate kernel cache: {t}", .{e}), |
| 622 | }; | 622 | }; |
| 623 | } | 623 | } |
| 624 | } | 624 | } |
| 625 | 625 | ||
| 626 | /// --verbose-link output | 626 | /// --verbose-link output |
| 627 | fn dumpArgv(self: *MachO, comp: *Compilation) !void { | 627 | fn dumpArgv(self: *MachO, comp: *Compilation) !void { |
| 628 | const gpa = self.base.comp.gpa; | 628 | const gpa = comp.gpa; |
| 629 | const io = comp.io; | ||
| 630 | |||
| 629 | var arena_allocator = std.heap.ArenaAllocator.init(gpa); | 631 | var arena_allocator = std.heap.ArenaAllocator.init(gpa); |
| 630 | defer arena_allocator.deinit(); | 632 | defer arena_allocator.deinit(); |
| 631 | const arena = arena_allocator.allocator(); | 633 | const arena = arena_allocator.allocator(); |
| ... | @@ -820,7 +822,7 @@ fn dumpArgv(self: *MachO, comp: *Compilation) !void { | ... | @@ -820,7 +822,7 @@ fn dumpArgv(self: *MachO, comp: *Compilation) !void { |
| 820 | if (comp.ubsan_rt_obj) |obj| try argv.append(try obj.full_object_path.toString(arena)); | 822 | if (comp.ubsan_rt_obj) |obj| try argv.append(try obj.full_object_path.toString(arena)); |
| 821 | } | 823 | } |
| 822 | 824 | ||
| 823 | Compilation.dump_argv(argv.items); | 825 | try Compilation.dumpArgv(io, argv.items); |
| 824 | } | 826 | } |
| 825 | 827 | ||
| 826 | /// TODO delete this, libsystem must be resolved when setting up the compilation pipeline | 828 | /// TODO delete this, libsystem must be resolved when setting up the compilation pipeline |
src/link/MappedFile.zig+2-2| ... | @@ -476,8 +476,8 @@ pub const Node = extern struct { | ... | @@ -476,8 +476,8 @@ pub const Node = extern struct { |
| 476 | return n; | 476 | return n; |
| 477 | }, | 477 | }, |
| 478 | .streaming, | 478 | .streaming, |
| 479 | .streaming_reading, | 479 | .streaming_simple, |
| 480 | .positional_reading, | 480 | .positional_simple, |
| 481 | .failure, | 481 | .failure, |
| 482 | => { | 482 | => { |
| 483 | const dest = limit.slice(interface.unusedCapacitySlice()); | 483 | const dest = limit.slice(interface.unusedCapacitySlice()); |
src/link/Queue.zig+1| ... | @@ -175,6 +175,7 @@ fn runLinkTasks(q: *Queue, comp: *Compilation) void { | ... | @@ -175,6 +175,7 @@ fn runLinkTasks(q: *Queue, comp: *Compilation) void { |
| 175 | lf.post_prelink = true; | 175 | lf.post_prelink = true; |
| 176 | } else |err| switch (err) { | 176 | } else |err| switch (err) { |
| 177 | error.OutOfMemory => comp.link_diags.setAllocFailure(), | 177 | error.OutOfMemory => comp.link_diags.setAllocFailure(), |
| 178 | error.Canceled => @panic("TODO"), | ||
| 178 | error.LinkFailure => {}, | 179 | error.LinkFailure => {}, |
| 179 | } | 180 | } |
| 180 | } | 181 | } |
src/link/Wasm.zig+2-1| ... | @@ -3828,8 +3828,9 @@ pub fn flush( | ... | @@ -3828,8 +3828,9 @@ pub fn flush( |
| 3828 | const comp = wasm.base.comp; | 3828 | const comp = wasm.base.comp; |
| 3829 | const diags = &comp.link_diags; | 3829 | const diags = &comp.link_diags; |
| 3830 | const gpa = comp.gpa; | 3830 | const gpa = comp.gpa; |
| 3831 | const io = comp.io; | ||
| 3831 | 3832 | ||
| 3832 | if (comp.verbose_link) Compilation.dump_argv(wasm.dump_argv_list.items); | 3833 | if (comp.verbose_link) try Compilation.dumpArgv(io, wasm.dump_argv_list.items); |
| 3833 | 3834 | ||
| 3834 | if (wasm.base.zcu_object_basename) |raw| { | 3835 | if (wasm.base.zcu_object_basename) |raw| { |
| 3835 | const zcu_obj_path: Path = try comp.resolveEmitPathFlush(arena, .temp, raw); | 3836 | const zcu_obj_path: Path = try comp.resolveEmitPathFlush(arena, .temp, raw); |