| author | |
| committer | |
| log | 16bd2e137e56f842a9ff5e015425f9e08eeb97fd |
| tree | 4a4b46fd3eeeb52fa964f8753515e8c0ca4a6781 |
| parent | 4458e423bf2d2cf485031d1f527e407bfc9113df |
23 files changed, 177 insertions(+), 156 deletions(-)
lib/compiler/aro/aro/Diagnostics.zig+1-1| ... | ... | @@ -24,7 +24,7 @@ pub const Message = struct { |
| 24 | 24 | @"fatal error", |
| 25 | 25 | }; |
| 26 | 26 | |
| 27 | pub fn write(msg: Message, w: *std.Io.Writer, config: std.Io.tty.Config, details: bool) std.Io.tty.Config.SetColorError!void { | |
| 27 | pub fn write(msg: Message, w: *std.Io.Writer, config: std.Io.File.Writer.Mode, details: bool) std.Io.tty.Config.SetColorError!void { | |
| 28 | 28 | try config.setColor(w, .bold); |
| 29 | 29 | if (msg.location) |loc| { |
| 30 | 30 | try w.print("{s}:{d}:{d}: ", .{ loc.path, loc.line_no, loc.col }); |
lib/compiler/aro/aro/Preprocessor.zig+4-2| ... | ... | @@ -1065,11 +1065,13 @@ fn fatalNotFound(pp: *Preprocessor, tok: TokenWithExpansionLocs, filename: []con |
| 1065 | 1065 | |
| 1066 | 1066 | fn verboseLog(pp: *Preprocessor, raw: RawToken, comptime fmt: []const u8, args: anytype) void { |
| 1067 | 1067 | @branchHint(.cold); |
| 1068 | const source = pp.comp.getSource(raw.source); | |
| 1068 | const comp = pp.comp; | |
| 1069 | const io = comp.io; | |
| 1070 | const source = comp.getSource(raw.source); | |
| 1069 | 1071 | const line_col = source.lineCol(.{ .id = raw.source, .line = raw.line, .byte_offset = raw.start }); |
| 1070 | 1072 | |
| 1071 | 1073 | var stderr_buf: [4096]u8 = undefined; |
| 1072 | var stderr = Io.File.stderr().writer(&stderr_buf); | |
| 1074 | var stderr = Io.File.stderr().writer(io, &stderr_buf); | |
| 1073 | 1075 | const w = &stderr.interface; |
| 1074 | 1076 | |
| 1075 | 1077 | w.print("{s}:{d}:{d}: ", .{ source.path, line_col.line_no, line_col.col }) catch return; |
lib/std/Build/Cache/Path.zig+2-1| ... | ... | @@ -106,6 +106,7 @@ pub fn statFile(p: Path, io: Io, sub_path: []const u8) !Io.Dir.Stat { |
| 106 | 106 | |
| 107 | 107 | pub fn atomicFile( |
| 108 | 108 | p: Path, |
| 109 | io: Io, | |
| 109 | 110 | sub_path: []const u8, |
| 110 | 111 | options: Io.Dir.AtomicFileOptions, |
| 111 | 112 | buf: *[fs.max_path_bytes]u8, |
| ... | ... | @@ -115,7 +116,7 @@ pub fn atomicFile( |
| 115 | 116 | p.sub_path, sub_path, |
| 116 | 117 | }) catch return error.NameTooLong; |
| 117 | 118 | }; |
| 118 | return p.root_dir.handle.atomicFile(joined_path, options); | |
| 119 | return p.root_dir.handle.atomicFile(io, joined_path, options); | |
| 119 | 120 | } |
| 120 | 121 | |
| 121 | 122 | pub fn access(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.AccessOptions) !void { |
lib/std/Io/Dir.zig+1-1| ... | ... | @@ -1645,7 +1645,7 @@ pub fn copyFile( |
| 1645 | 1645 | .permissions = permissions, |
| 1646 | 1646 | .write_buffer = &buffer, |
| 1647 | 1647 | }); |
| 1648 | defer atomic_file.deinit(io); | |
| 1648 | defer atomic_file.deinit(); | |
| 1649 | 1649 | |
| 1650 | 1650 | _ = atomic_file.file_writer.interface.sendFileAll(&file_reader, .unlimited) catch |err| switch (err) { |
| 1651 | 1651 | error.ReadFailed => return file_reader.err.?, |
lib/std/crypto/Certificate/Bundle.zig+2-1| ... | ... | @@ -202,7 +202,7 @@ pub const AddCertsFromDirError = AddCertsFromFilePathError; |
| 202 | 202 | |
| 203 | 203 | pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp, iterable_dir: Io.Dir) AddCertsFromDirError!void { |
| 204 | 204 | var it = iterable_dir.iterate(); |
| 205 | while (try it.next()) |entry| { | |
| 205 | while (try it.next(io)) |entry| { | |
| 206 | 206 | switch (entry.kind) { |
| 207 | 207 | .file, .sym_link => {}, |
| 208 | 208 | else => continue, |
| ... | ... | @@ -243,6 +243,7 @@ pub fn addCertsFromFilePath( |
| 243 | 243 | |
| 244 | 244 | pub const AddCertsFromFileError = Allocator.Error || |
| 245 | 245 | Io.File.Reader.Error || |
| 246 | Io.File.Reader.SizeError || | |
| 246 | 247 | ParseCertError || |
| 247 | 248 | std.base64.Error || |
| 248 | 249 | error{ CertificateAuthorityBundleTooBig, MissingEndCertificateMarker, Streaming }; |
lib/std/fs/test.zig+1-1| ... | ... | @@ -1598,7 +1598,7 @@ test "AtomicFile" { |
| 1598 | 1598 | |
| 1599 | 1599 | { |
| 1600 | 1600 | var buffer: [100]u8 = undefined; |
| 1601 | var af = try ctx.dir.atomicFile(test_out_file, .{ .write_buffer = &buffer }); | |
| 1601 | var af = try ctx.dir.atomicFile(io, test_out_file, .{ .write_buffer = &buffer }); | |
| 1602 | 1602 | defer af.deinit(); |
| 1603 | 1603 | try af.file_writer.interface.writeAll(test_content); |
| 1604 | 1604 | try af.finish(); |
lib/std/zig.zig+1-1| ... | ... | @@ -648,7 +648,7 @@ pub fn printAstErrorsToStderr(gpa: Allocator, io: Io, tree: Ast, path: []const u |
| 648 | 648 | |
| 649 | 649 | var error_bundle = try wip_errors.toOwnedBundle(""); |
| 650 | 650 | defer error_bundle.deinit(gpa); |
| 651 | error_bundle.renderToStderr(io, .{}, color); | |
| 651 | return error_bundle.renderToStderr(io, .{}, color); | |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | pub fn putAstErrorsIntoBundle( |
lib/std/zig/ErrorBundle.zig+2-2| ... | ... | @@ -162,14 +162,14 @@ pub const RenderOptions = struct { |
| 162 | 162 | include_log_text: bool = true, |
| 163 | 163 | }; |
| 164 | 164 | |
| 165 | pub const RenderToStderrError = Io.Cancelable || Io.File.Writer.Mode.SetColorError; | |
| 165 | pub const RenderToStderrError = Io.Cancelable || Io.File.Writer.Error; | |
| 166 | 166 | |
| 167 | 167 | pub fn renderToStderr(eb: ErrorBundle, io: Io, options: RenderOptions, color: std.zig.Color) RenderToStderrError!void { |
| 168 | 168 | var buffer: [256]u8 = undefined; |
| 169 | 169 | const stderr = try io.lockStderrWriter(&buffer); |
| 170 | 170 | defer io.unlockStderrWriter(); |
| 171 | 171 | renderToWriter(eb, options, &stderr.interface, color.getTtyConf(stderr.mode)) catch |err| switch (err) { |
| 172 | error.WriteFailed => return stderr.interface.err.?, | |
| 172 | error.WriteFailed => return stderr.err.?, | |
| 173 | 173 | else => |e| return e, |
| 174 | 174 | }; |
| 175 | 175 | } |
lib/std/zig/LibCDirs.zig+11-8| ... | ... | @@ -1,3 +1,11 @@ |
| 1 | const LibCDirs = @This(); | |
| 2 | const builtin = @import("builtin"); | |
| 3 | ||
| 4 | const std = @import("../std.zig"); | |
| 5 | const Io = std.Io; | |
| 6 | const LibCInstallation = std.zig.LibCInstallation; | |
| 7 | const Allocator = std.mem.Allocator; | |
| 8 | ||
| 1 | 9 | libc_include_dir_list: []const []const u8, |
| 2 | 10 | libc_installation: ?*const LibCInstallation, |
| 3 | 11 | libc_framework_dir_list: []const []const u8, |
| ... | ... | @@ -14,6 +22,7 @@ pub const DarwinSdkLayout = enum { |
| 14 | 22 | |
| 15 | 23 | pub fn detect( |
| 16 | 24 | arena: Allocator, |
| 25 | io: Io, | |
| 17 | 26 | zig_lib_dir: []const u8, |
| 18 | 27 | target: *const std.Target, |
| 19 | 28 | is_native_abi: bool, |
| ... | ... | @@ -38,7 +47,7 @@ pub fn detect( |
| 38 | 47 | // using the system libc installation. |
| 39 | 48 | if (is_native_abi and !target.isMinGW()) { |
| 40 | 49 | const libc = try arena.create(LibCInstallation); |
| 41 | libc.* = LibCInstallation.findNative(.{ .allocator = arena, .target = target }) catch |err| switch (err) { | |
| 50 | libc.* = LibCInstallation.findNative(arena, io, .{ .target = target }) catch |err| switch (err) { | |
| 42 | 51 | error.CCompilerExitCode, |
| 43 | 52 | error.CCompilerCrashed, |
| 44 | 53 | error.CCompilerCannotFindHeaders, |
| ... | ... | @@ -75,7 +84,7 @@ pub fn detect( |
| 75 | 84 | |
| 76 | 85 | if (use_system_abi) { |
| 77 | 86 | const libc = try arena.create(LibCInstallation); |
| 78 | libc.* = try LibCInstallation.findNative(.{ .allocator = arena, .verbose = true, .target = target }); | |
| 87 | libc.* = try LibCInstallation.findNative(arena, io, .{ .verbose = true, .target = target }); | |
| 79 | 88 | return detectFromInstallation(arena, target, libc); |
| 80 | 89 | } |
| 81 | 90 | |
| ... | ... | @@ -265,9 +274,3 @@ fn libCGenericName(target: *const std.Target) [:0]const u8 { |
| 265 | 274 | => unreachable, |
| 266 | 275 | } |
| 267 | 276 | } |
| 268 | ||
| 269 | const LibCDirs = @This(); | |
| 270 | const builtin = @import("builtin"); | |
| 271 | const std = @import("../std.zig"); | |
| 272 | const LibCInstallation = std.zig.LibCInstallation; | |
| 273 | const Allocator = std.mem.Allocator; |
lib/std/zig/LibCInstallation.zig+3-3| ... | ... | @@ -204,7 +204,7 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib |
| 204 | 204 | try self.findNativeIncludeDirWindows(gpa, io, args, sdk); |
| 205 | 205 | try self.findNativeCrtDirWindows(gpa, io, args.target, sdk); |
| 206 | 206 | } else if (is_haiku) { |
| 207 | try self.findNativeIncludeDirPosix(args); | |
| 207 | try self.findNativeIncludeDirPosix(gpa, io, args); | |
| 208 | 208 | try self.findNativeGccDirHaiku(gpa, io, args); |
| 209 | 209 | self.crt_dir = try gpa.dupeZ(u8, "/system/develop/lib"); |
| 210 | 210 | } else if (builtin.target.os.tag == .illumos) { |
| ... | ... | @@ -213,7 +213,7 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib |
| 213 | 213 | self.sys_include_dir = try gpa.dupeZ(u8, "/usr/include"); |
| 214 | 214 | self.crt_dir = try gpa.dupeZ(u8, "/usr/lib/64"); |
| 215 | 215 | } else if (std.process.can_spawn) { |
| 216 | try self.findNativeIncludeDirPosix(args); | |
| 216 | try self.findNativeIncludeDirPosix(gpa, io, args); | |
| 217 | 217 | switch (builtin.target.os.tag) { |
| 218 | 218 | .freebsd, .netbsd, .openbsd, .dragonfly => self.crt_dir = try gpa.dupeZ(u8, "/usr/lib"), |
| 219 | 219 | .linux => try self.findNativeCrtDirPosix(gpa, io, args), |
| ... | ... | @@ -335,7 +335,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar |
| 335 | 335 | defer search_dir.close(io); |
| 336 | 336 | |
| 337 | 337 | if (self.include_dir == null) { |
| 338 | if (search_dir.access(include_dir_example_file, .{})) |_| { | |
| 338 | if (search_dir.access(io, include_dir_example_file, .{})) |_| { | |
| 339 | 339 | self.include_dir = try gpa.dupeZ(u8, search_path); |
| 340 | 340 | } else |err| switch (err) { |
| 341 | 341 | error.FileNotFound => {}, |
src/Builtin.zig+1-1| ... | ... | @@ -343,7 +343,7 @@ pub fn updateFileOnDisk(file: *File, comp: *Compilation) !void { |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | // `make_path` matters because the dir hasn't actually been created yet. |
| 346 | var af = try root_dir.atomicFile(sub_path, .{ .make_path = true, .write_buffer = &.{} }); | |
| 346 | var af = try root_dir.atomicFile(io, sub_path, .{ .make_path = true, .write_buffer = &.{} }); | |
| 347 | 347 | defer af.deinit(); |
| 348 | 348 | try af.file_writer.interface.writeAll(file.source.?); |
| 349 | 349 | af.finish() catch |err| switch (err) { |
src/Compilation.zig+68-70| ... | ... | @@ -771,8 +771,8 @@ pub const Directories = struct { |
| 771 | 771 | const zig_lib: Cache.Directory = d: { |
| 772 | 772 | if (override_zig_lib) |path| break :d openUnresolved(arena, io, cwd, path, .@"zig lib"); |
| 773 | 773 | if (wasi) break :d openWasiPreopen(wasi_preopens, "/lib"); |
| 774 | break :d introspect.findZigLibDirFromSelfExe(arena, cwd, self_exe_path) catch |err| { | |
| 775 | fatal("unable to find zig installation directory '{s}': {s}", .{ self_exe_path, @errorName(err) }); | |
| 774 | break :d introspect.findZigLibDirFromSelfExe(arena, io, cwd, self_exe_path) catch |err| { | |
| 775 | fatal("unable to find zig installation directory '{s}': {t}", .{ self_exe_path, err }); | |
| 776 | 776 | }; |
| 777 | 777 | }; |
| 778 | 778 | |
| ... | ... | @@ -780,7 +780,7 @@ pub const Directories = struct { |
| 780 | 780 | if (override_global_cache) |path| break :d openUnresolved(arena, io, cwd, path, .@"global cache"); |
| 781 | 781 | if (wasi) break :d openWasiPreopen(wasi_preopens, "/cache"); |
| 782 | 782 | const path = introspect.resolveGlobalCacheDir(arena) catch |err| { |
| 783 | fatal("unable to resolve zig cache directory: {s}", .{@errorName(err)}); | |
| 783 | fatal("unable to resolve zig cache directory: {t}", .{err}); | |
| 784 | 784 | }; |
| 785 | 785 | break :d openUnresolved(arena, io, cwd, path, .@"global cache"); |
| 786 | 786 | }; |
| ... | ... | @@ -789,7 +789,7 @@ pub const Directories = struct { |
| 789 | 789 | .override => |path| openUnresolved(arena, io, cwd, path, .@"local cache"), |
| 790 | 790 | .search => d: { |
| 791 | 791 | const maybe_path = introspect.resolveSuitableLocalCacheDir(arena, io, cwd) catch |err| { |
| 792 | fatal("unable to resolve zig cache directory: {s}", .{@errorName(err)}); | |
| 792 | fatal("unable to resolve zig cache directory: {t}", .{err}); | |
| 793 | 793 | }; |
| 794 | 794 | const path = maybe_path orelse break :d global_cache; |
| 795 | 795 | break :d openUnresolved(arena, io, cwd, path, .@"local cache"); |
| ... | ... | @@ -919,8 +919,8 @@ pub const CrtFile = struct { |
| 919 | 919 | lock: Cache.Lock, |
| 920 | 920 | full_object_path: Cache.Path, |
| 921 | 921 | |
| 922 | pub fn deinit(self: *CrtFile, gpa: Allocator) void { | |
| 923 | self.lock.release(); | |
| 922 | pub fn deinit(self: *CrtFile, gpa: Allocator, io: Io) void { | |
| 923 | self.lock.release(io); | |
| 924 | 924 | gpa.free(self.full_object_path.sub_path); |
| 925 | 925 | self.* = undefined; |
| 926 | 926 | } |
| ... | ... | @@ -1317,7 +1317,7 @@ pub const CObject = struct { |
| 1317 | 1317 | }; |
| 1318 | 1318 | |
| 1319 | 1319 | /// Returns if there was failure. |
| 1320 | pub fn clearStatus(self: *CObject, gpa: Allocator) bool { | |
| 1320 | pub fn clearStatus(self: *CObject, gpa: Allocator, io: Io) bool { | |
| 1321 | 1321 | switch (self.status) { |
| 1322 | 1322 | .new => return false, |
| 1323 | 1323 | .failure, .failure_retryable => { |
| ... | ... | @@ -1326,15 +1326,15 @@ pub const CObject = struct { |
| 1326 | 1326 | }, |
| 1327 | 1327 | .success => |*success| { |
| 1328 | 1328 | gpa.free(success.object_path.sub_path); |
| 1329 | success.lock.release(); | |
| 1329 | success.lock.release(io); | |
| 1330 | 1330 | self.status = .new; |
| 1331 | 1331 | return false; |
| 1332 | 1332 | }, |
| 1333 | 1333 | } |
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | pub fn destroy(self: *CObject, gpa: Allocator) void { | |
| 1337 | _ = self.clearStatus(gpa); | |
| 1336 | pub fn destroy(self: *CObject, gpa: Allocator, io: Io) void { | |
| 1337 | _ = self.clearStatus(gpa, io); | |
| 1338 | 1338 | gpa.destroy(self); |
| 1339 | 1339 | } |
| 1340 | 1340 | }; |
| ... | ... | @@ -1364,7 +1364,7 @@ pub const Win32Resource = struct { |
| 1364 | 1364 | }, |
| 1365 | 1365 | |
| 1366 | 1366 | /// Returns true if there was failure. |
| 1367 | pub fn clearStatus(self: *Win32Resource, gpa: Allocator) bool { | |
| 1367 | pub fn clearStatus(self: *Win32Resource, gpa: Allocator, io: Io) bool { | |
| 1368 | 1368 | switch (self.status) { |
| 1369 | 1369 | .new => return false, |
| 1370 | 1370 | .failure, .failure_retryable => { |
| ... | ... | @@ -1373,15 +1373,15 @@ pub const Win32Resource = struct { |
| 1373 | 1373 | }, |
| 1374 | 1374 | .success => |*success| { |
| 1375 | 1375 | gpa.free(success.res_path); |
| 1376 | success.lock.release(); | |
| 1376 | success.lock.release(io); | |
| 1377 | 1377 | self.status = .new; |
| 1378 | 1378 | return false; |
| 1379 | 1379 | }, |
| 1380 | 1380 | } |
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | pub fn destroy(self: *Win32Resource, gpa: Allocator) void { | |
| 1384 | _ = self.clearStatus(gpa); | |
| 1383 | pub fn destroy(self: *Win32Resource, gpa: Allocator, io: Io) void { | |
| 1384 | _ = self.clearStatus(gpa, io); | |
| 1385 | 1385 | gpa.destroy(self); |
| 1386 | 1386 | } |
| 1387 | 1387 | }; |
| ... | ... | @@ -1610,9 +1610,9 @@ const CacheUse = union(CacheMode) { |
| 1610 | 1610 | /// Prevents other processes from clobbering files in the output directory. |
| 1611 | 1611 | lock: ?Cache.Lock, |
| 1612 | 1612 | |
| 1613 | fn releaseLock(whole: *Whole) void { | |
| 1613 | fn releaseLock(whole: *Whole, io: Io) void { | |
| 1614 | 1614 | if (whole.lock) |*lock| { |
| 1615 | lock.release(); | |
| 1615 | lock.release(io); | |
| 1616 | 1616 | whole.lock = null; |
| 1617 | 1617 | } |
| 1618 | 1618 | } |
| ... | ... | @@ -1634,7 +1634,7 @@ const CacheUse = union(CacheMode) { |
| 1634 | 1634 | }, |
| 1635 | 1635 | .whole => |whole| { |
| 1636 | 1636 | assert(whole.tmp_artifact_directory == null); |
| 1637 | whole.releaseLock(); | |
| 1637 | whole.releaseLock(io); | |
| 1638 | 1638 | }, |
| 1639 | 1639 | } |
| 1640 | 1640 | } |
| ... | ... | @@ -1903,13 +1903,17 @@ pub const CreateDiagnostic = union(enum) { |
| 1903 | 1903 | return error.CreateFail; |
| 1904 | 1904 | } |
| 1905 | 1905 | }; |
| 1906 | pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, options: CreateOptions) error{ | |
| 1906 | ||
| 1907 | pub const CreateError = error{ | |
| 1907 | 1908 | OutOfMemory, |
| 1909 | Canceled, | |
| 1908 | 1910 | Unexpected, |
| 1909 | 1911 | CurrentWorkingDirectoryUnlinked, |
| 1910 | 1912 | /// An error has been stored to `diag`. |
| 1911 | 1913 | CreateFail, |
| 1912 | }!*Compilation { | |
| 1914 | }; | |
| 1915 | ||
| 1916 | pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, options: CreateOptions) CreateError!*Compilation { | |
| 1913 | 1917 | const output_mode = options.config.output_mode; |
| 1914 | 1918 | const is_dyn_lib = switch (output_mode) { |
| 1915 | 1919 | .Obj, .Exe => false, |
| ... | ... | @@ -1957,6 +1961,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, |
| 1957 | 1961 | |
| 1958 | 1962 | const libc_dirs = std.zig.LibCDirs.detect( |
| 1959 | 1963 | arena, |
| 1964 | io, | |
| 1960 | 1965 | options.dirs.zig_lib.path.?, |
| 1961 | 1966 | target, |
| 1962 | 1967 | options.root_mod.resolved_target.is_native_abi, |
| ... | ... | @@ -2701,7 +2706,7 @@ pub fn destroy(comp: *Compilation) void { |
| 2701 | 2706 | |
| 2702 | 2707 | if (comp.bin_file) |lf| lf.destroy(); |
| 2703 | 2708 | if (comp.zcu) |zcu| zcu.deinit(); |
| 2704 | comp.cache_use.deinit(); | |
| 2709 | comp.cache_use.deinit(io); | |
| 2705 | 2710 | |
| 2706 | 2711 | for (&comp.work_queues) |*work_queue| work_queue.deinit(gpa); |
| 2707 | 2712 | comp.c_object_work_queue.deinit(gpa); |
| ... | ... | @@ -2714,36 +2719,36 @@ pub fn destroy(comp: *Compilation) void { |
| 2714 | 2719 | var it = comp.crt_files.iterator(); |
| 2715 | 2720 | while (it.next()) |entry| { |
| 2716 | 2721 | gpa.free(entry.key_ptr.*); |
| 2717 | entry.value_ptr.deinit(gpa); | |
| 2722 | entry.value_ptr.deinit(gpa, io); | |
| 2718 | 2723 | } |
| 2719 | 2724 | comp.crt_files.deinit(gpa); |
| 2720 | 2725 | } |
| 2721 | if (comp.libcxx_static_lib) |*crt_file| crt_file.deinit(gpa); | |
| 2722 | if (comp.libcxxabi_static_lib) |*crt_file| crt_file.deinit(gpa); | |
| 2723 | if (comp.libunwind_static_lib) |*crt_file| crt_file.deinit(gpa); | |
| 2724 | if (comp.tsan_lib) |*crt_file| crt_file.deinit(gpa); | |
| 2725 | if (comp.ubsan_rt_lib) |*crt_file| crt_file.deinit(gpa); | |
| 2726 | if (comp.ubsan_rt_obj) |*crt_file| crt_file.deinit(gpa); | |
| 2727 | if (comp.zigc_static_lib) |*crt_file| crt_file.deinit(gpa); | |
| 2728 | if (comp.compiler_rt_lib) |*crt_file| crt_file.deinit(gpa); | |
| 2729 | if (comp.compiler_rt_obj) |*crt_file| crt_file.deinit(gpa); | |
| 2730 | if (comp.compiler_rt_dyn_lib) |*crt_file| crt_file.deinit(gpa); | |
| 2731 | if (comp.fuzzer_lib) |*crt_file| crt_file.deinit(gpa); | |
| 2726 | if (comp.libcxx_static_lib) |*crt_file| crt_file.deinit(gpa, io); | |
| 2727 | if (comp.libcxxabi_static_lib) |*crt_file| crt_file.deinit(gpa, io); | |
| 2728 | if (comp.libunwind_static_lib) |*crt_file| crt_file.deinit(gpa, io); | |
| 2729 | if (comp.tsan_lib) |*crt_file| crt_file.deinit(gpa, io); | |
| 2730 | if (comp.ubsan_rt_lib) |*crt_file| crt_file.deinit(gpa, io); | |
| 2731 | if (comp.ubsan_rt_obj) |*crt_file| crt_file.deinit(gpa, io); | |
| 2732 | if (comp.zigc_static_lib) |*crt_file| crt_file.deinit(gpa, io); | |
| 2733 | if (comp.compiler_rt_lib) |*crt_file| crt_file.deinit(gpa, io); | |
| 2734 | if (comp.compiler_rt_obj) |*crt_file| crt_file.deinit(gpa, io); | |
| 2735 | if (comp.compiler_rt_dyn_lib) |*crt_file| crt_file.deinit(gpa, io); | |
| 2736 | if (comp.fuzzer_lib) |*crt_file| crt_file.deinit(gpa, io); | |
| 2732 | 2737 | |
| 2733 | 2738 | if (comp.glibc_so_files) |*glibc_file| { |
| 2734 | glibc_file.deinit(gpa); | |
| 2739 | glibc_file.deinit(gpa, io); | |
| 2735 | 2740 | } |
| 2736 | 2741 | |
| 2737 | 2742 | if (comp.freebsd_so_files) |*freebsd_file| { |
| 2738 | freebsd_file.deinit(gpa); | |
| 2743 | freebsd_file.deinit(gpa, io); | |
| 2739 | 2744 | } |
| 2740 | 2745 | |
| 2741 | 2746 | if (comp.netbsd_so_files) |*netbsd_file| { |
| 2742 | netbsd_file.deinit(gpa); | |
| 2747 | netbsd_file.deinit(gpa, io); | |
| 2743 | 2748 | } |
| 2744 | 2749 | |
| 2745 | 2750 | for (comp.c_object_table.keys()) |key| { |
| 2746 | key.destroy(gpa); | |
| 2751 | key.destroy(gpa, io); | |
| 2747 | 2752 | } |
| 2748 | 2753 | comp.c_object_table.deinit(gpa); |
| 2749 | 2754 | |
| ... | ... | @@ -2753,7 +2758,7 @@ pub fn destroy(comp: *Compilation) void { |
| 2753 | 2758 | comp.failed_c_objects.deinit(gpa); |
| 2754 | 2759 | |
| 2755 | 2760 | for (comp.win32_resource_table.keys()) |key| { |
| 2756 | key.destroy(gpa); | |
| 2761 | key.destroy(gpa, io); | |
| 2757 | 2762 | } |
| 2758 | 2763 | comp.win32_resource_table.deinit(gpa); |
| 2759 | 2764 | |
| ... | ... | @@ -2906,7 +2911,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE |
| 2906 | 2911 | .whole => |whole| { |
| 2907 | 2912 | assert(comp.bin_file == null); |
| 2908 | 2913 | // We are about to obtain this lock, so here we give other processes a chance first. |
| 2909 | whole.releaseLock(); | |
| 2914 | whole.releaseLock(io); | |
| 2910 | 2915 | |
| 2911 | 2916 | man = comp.cache_parent.obtain(); |
| 2912 | 2917 | whole.cache_manifest = &man; |
| ... | ... | @@ -3092,17 +3097,12 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE |
| 3092 | 3097 | } |
| 3093 | 3098 | |
| 3094 | 3099 | if (build_options.enable_debug_extensions and comp.verbose_intern_pool) { |
| 3095 | std.debug.print("intern pool stats for '{s}':\n", .{ | |
| 3096 | comp.root_name, | |
| 3097 | }); | |
| 3098 | zcu.intern_pool.dump(); | |
| 3100 | std.debug.print("intern pool stats for '{s}':\n", .{comp.root_name}); | |
| 3101 | zcu.intern_pool.dump(io); | |
| 3099 | 3102 | } |
| 3100 | 3103 | |
| 3101 | 3104 | if (build_options.enable_debug_extensions and comp.verbose_generic_instances) { |
| 3102 | std.debug.print("generic instances for '{s}:0x{x}':\n", .{ | |
| 3103 | comp.root_name, | |
| 3104 | @intFromPtr(zcu), | |
| 3105 | }); | |
| 3105 | std.debug.print("generic instances for '{s}:0x{x}':\n", .{ comp.root_name, @intFromPtr(zcu) }); | |
| 3106 | 3106 | zcu.intern_pool.dumpGenericInstances(gpa); |
| 3107 | 3107 | } |
| 3108 | 3108 | } |
| ... | ... | @@ -3680,6 +3680,7 @@ pub fn saveState(comp: *Compilation) !void { |
| 3680 | 3680 | const lf = comp.bin_file orelse return; |
| 3681 | 3681 | |
| 3682 | 3682 | const gpa = comp.gpa; |
| 3683 | const io = comp.io; | |
| 3683 | 3684 | |
| 3684 | 3685 | var bufs = std.array_list.Managed([]const u8).init(gpa); |
| 3685 | 3686 | defer bufs.deinit(); |
| ... | ... | @@ -3900,7 +3901,7 @@ pub fn saveState(comp: *Compilation) !void { |
| 3900 | 3901 | // Using an atomic file prevents a crash or power failure from corrupting |
| 3901 | 3902 | // the previous incremental compilation state. |
| 3902 | 3903 | var write_buffer: [1024]u8 = undefined; |
| 3903 | var af = try lf.emit.root_dir.handle.atomicFile(basename, .{ .write_buffer = &write_buffer }); | |
| 3904 | var af = try lf.emit.root_dir.handle.atomicFile(io, basename, .{ .write_buffer = &write_buffer }); | |
| 3904 | 3905 | defer af.deinit(); |
| 3905 | 3906 | try af.file_writer.interface.writeVecAll(bufs.items); |
| 3906 | 3907 | try af.finish(); |
| ... | ... | @@ -4258,8 +4259,8 @@ pub fn getAllErrorsAlloc(comp: *Compilation) error{OutOfMemory}!ErrorBundle { |
| 4258 | 4259 | // However, we haven't reported any such error. |
| 4259 | 4260 | // This is a compiler bug. |
| 4260 | 4261 | print_ctx: { |
| 4261 | const stderr = try io.lockStderrWriter(&.{}); | |
| 4262 | defer io.unlockStderrWriter(); | |
| 4262 | const stderr = std.debug.lockStderrWriter(&.{}); | |
| 4263 | defer std.debug.unlockStderrWriter(); | |
| 4263 | 4264 | const w = &stderr.interface; |
| 4264 | 4265 | w.writeAll("referenced transitive analysis errors, but none actually emitted\n") catch break :print_ctx; |
| 4265 | 4266 | w.print("{f} [transitive failure]\n", .{zcu.fmtAnalUnit(failed_unit)}) catch break :print_ctx; |
| ... | ... | @@ -5219,13 +5220,10 @@ fn processOneJob( |
| 5219 | 5220 | } |
| 5220 | 5221 | } |
| 5221 | 5222 | |
| 5222 | fn createDepFile( | |
| 5223 | comp: *Compilation, | |
| 5224 | depfile: []const u8, | |
| 5225 | binfile: Cache.Path, | |
| 5226 | ) anyerror!void { | |
| 5223 | fn createDepFile(comp: *Compilation, depfile: []const u8, binfile: Cache.Path) anyerror!void { | |
| 5224 | const io = comp.io; | |
| 5227 | 5225 | var buf: [4096]u8 = undefined; |
| 5228 | var af = try Io.Dir.cwd().atomicFile(depfile, .{ .write_buffer = &buf }); | |
| 5226 | var af = try Io.Dir.cwd().atomicFile(io, depfile, .{ .write_buffer = &buf }); | |
| 5229 | 5227 | defer af.deinit(); |
| 5230 | 5228 | |
| 5231 | 5229 | comp.writeDepFile(binfile, &af.file_writer.interface) catch return af.file_writer.err.?; |
| ... | ... | @@ -5280,13 +5278,8 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void { |
| 5280 | 5278 | |
| 5281 | 5279 | for (&[_][]const u8{ "docs/main.js", "docs/index.html" }) |sub_path| { |
| 5282 | 5280 | const basename = fs.path.basename(sub_path); |
| 5283 | comp.dirs.zig_lib.handle.copyFile(sub_path, out_dir, basename, .{}) catch |err| { | |
| 5284 | comp.lockAndSetMiscFailure(.docs_copy, "unable to copy {s}: {s}", .{ | |
| 5285 | sub_path, | |
| 5286 | @errorName(err), | |
| 5287 | }); | |
| 5288 | return; | |
| 5289 | }; | |
| 5281 | comp.dirs.zig_lib.handle.copyFile(sub_path, out_dir, basename, io, .{}) catch |err| | |
| 5282 | return comp.lockAndSetMiscFailure(.docs_copy, "unable to copy {s}: {t}", .{ sub_path, err }); | |
| 5290 | 5283 | } |
| 5291 | 5284 | |
| 5292 | 5285 | var tar_file = out_dir.createFile(io, "sources.tar", .{}) catch |err| { |
| ... | ... | @@ -5350,7 +5343,7 @@ fn docsCopyModule( |
| 5350 | 5343 | |
| 5351 | 5344 | var buffer: [1024]u8 = undefined; |
| 5352 | 5345 | |
| 5353 | while (try walker.next()) |entry| { | |
| 5346 | while (try walker.next(io)) |entry| { | |
| 5354 | 5347 | switch (entry.kind) { |
| 5355 | 5348 | .file => { |
| 5356 | 5349 | if (!std.mem.endsWith(u8, entry.basename, ".zig")) continue; |
| ... | ... | @@ -5505,7 +5498,7 @@ fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) SubU |
| 5505 | 5498 | try comp.updateSubCompilation(sub_compilation, .docs_wasm, prog_node); |
| 5506 | 5499 | |
| 5507 | 5500 | var crt_file = try sub_compilation.toCrtFile(); |
| 5508 | defer crt_file.deinit(gpa); | |
| 5501 | defer crt_file.deinit(gpa, io); | |
| 5509 | 5502 | |
| 5510 | 5503 | const docs_bin_file = crt_file.full_object_path; |
| 5511 | 5504 | assert(docs_bin_file.sub_path.len > 0); // emitted binary is not a directory |
| ... | ... | @@ -5521,10 +5514,12 @@ fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) SubU |
| 5521 | 5514 | }; |
| 5522 | 5515 | defer out_dir.close(io); |
| 5523 | 5516 | |
| 5524 | crt_file.full_object_path.root_dir.handle.copyFile( | |
| 5517 | Io.Dir.copyFile( | |
| 5518 | crt_file.full_object_path.root_dir.handle, | |
| 5525 | 5519 | crt_file.full_object_path.sub_path, |
| 5526 | 5520 | out_dir, |
| 5527 | 5521 | "main.wasm", |
| 5522 | io, | |
| 5528 | 5523 | .{}, |
| 5529 | 5524 | ) catch |err| { |
| 5530 | 5525 | comp.lockAndSetMiscFailure(.docs_copy, "unable to copy '{f}' to '{f}': {t}", .{ |
| ... | ... | @@ -5758,7 +5753,7 @@ pub fn translateC( |
| 5758 | 5753 | try argv.appendSlice(comp.global_cc_argv); |
| 5759 | 5754 | try argv.appendSlice(owner_mod.cc_argv); |
| 5760 | 5755 | try argv.appendSlice(&.{ source_path, "-o", translated_path }); |
| 5761 | if (comp.verbose_cimport) dumpArgv(io, argv.items); | |
| 5756 | if (comp.verbose_cimport) try dumpArgv(io, argv.items); | |
| 5762 | 5757 | } |
| 5763 | 5758 | |
| 5764 | 5759 | var stdout: []u8 = undefined; |
| ... | ... | @@ -6153,7 +6148,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr |
| 6153 | 6148 | const gpa = comp.gpa; |
| 6154 | 6149 | const io = comp.io; |
| 6155 | 6150 | |
| 6156 | if (c_object.clearStatus(gpa)) { | |
| 6151 | if (c_object.clearStatus(gpa, io)) { | |
| 6157 | 6152 | // There was previous failure. |
| 6158 | 6153 | comp.mutex.lockUncancelable(io); |
| 6159 | 6154 | defer comp.mutex.unlock(io); |
| ... | ... | @@ -6500,7 +6495,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 |
| 6500 | 6495 | defer arena_allocator.deinit(); |
| 6501 | 6496 | const arena = arena_allocator.allocator(); |
| 6502 | 6497 | |
| 6503 | if (win32_resource.clearStatus(comp.gpa)) { | |
| 6498 | if (win32_resource.clearStatus(comp.gpa, io)) { | |
| 6504 | 6499 | // There was previous failure. |
| 6505 | 6500 | comp.mutex.lockUncancelable(io); |
| 6506 | 6501 | defer comp.mutex.unlock(io); |
| ... | ... | @@ -6768,7 +6763,7 @@ fn spawnZigRc( |
| 6768 | 6763 | // Just in case there's a failure that didn't send an ErrorBundle (e.g. an error return trace) |
| 6769 | 6764 | const stderr = poller.reader(.stderr); |
| 6770 | 6765 | |
| 6771 | const term = child.wait() catch |err| { | |
| 6766 | const term = child.wait(io) catch |err| { | |
| 6772 | 6767 | return comp.failWin32Resource(win32_resource, "unable to wait for {s} rc: {s}", .{ argv[0], @errorName(err) }); |
| 6773 | 6768 | }; |
| 6774 | 6769 | |
| ... | ... | @@ -7781,7 +7776,10 @@ pub fn dumpArgv(io: Io, argv: []const []const u8) Io.Cancelable!void { |
| 7781 | 7776 | defer io.unlockStderrWriter(); |
| 7782 | 7777 | const w = &stderr.interface; |
| 7783 | 7778 | return dumpArgvWriter(w, argv) catch |err| switch (err) { |
| 7784 | error.WriteFailed => return stderr.err.?, | |
| 7779 | error.WriteFailed => switch (stderr.err.?) { | |
| 7780 | error.Canceled => return error.Canceled, | |
| 7781 | else => return, | |
| 7782 | }, | |
| 7785 | 7783 | }; |
| 7786 | 7784 | } |
| 7787 | 7785 |
src/Package/Fetch.zig+16-21| ... | ... | @@ -501,7 +501,7 @@ fn runResource( |
| 501 | 501 | .path = tmp_directory_path, |
| 502 | 502 | .handle = handle: { |
| 503 | 503 | const dir = cache_root.handle.makeOpenPath(io, tmp_dir_sub_path, .{ |
| 504 | .iterate = true, | |
| 504 | .open_options = .{ .iterate = true }, | |
| 505 | 505 | }) catch |err| { |
| 506 | 506 | try eb.addRootErrorMessage(.{ |
| 507 | 507 | .msg = try eb.printString("unable to create temporary directory '{s}': {t}", .{ |
| ... | ... | @@ -525,7 +525,7 @@ fn runResource( |
| 525 | 525 | // https://github.com/ziglang/zig/issues/17095 |
| 526 | 526 | pkg_path.root_dir.handle.close(io); |
| 527 | 527 | pkg_path.root_dir.handle = cache_root.handle.makeOpenPath(io, tmp_dir_sub_path, .{ |
| 528 | .iterate = true, | |
| 528 | .open_options = .{ .iterate = true }, | |
| 529 | 529 | }) catch @panic("btrfs workaround failed"); |
| 530 | 530 | } |
| 531 | 531 | |
| ... | ... | @@ -1334,7 +1334,7 @@ fn unzip( |
| 1334 | 1334 | f.location_tok, |
| 1335 | 1335 | try eb.printString("failed writing temporary zip file: {t}", .{err}), |
| 1336 | 1336 | ); |
| 1337 | break :b zip_file_writer.moveToReader(io); | |
| 1337 | break :b zip_file_writer.moveToReader(); | |
| 1338 | 1338 | }; |
| 1339 | 1339 | |
| 1340 | 1340 | var diagnostics: std.zip.Diagnostics = .{ .allocator = f.arena.allocator() }; |
| ... | ... | @@ -1376,7 +1376,7 @@ fn unpackGitPack(f: *Fetch, out_dir: Io.Dir, resource: *Resource.Git) anyerror!U |
| 1376 | 1376 | const fetch_reader = &resource.fetch_stream.reader; |
| 1377 | 1377 | _ = try fetch_reader.streamRemaining(&pack_file_writer.interface); |
| 1378 | 1378 | try pack_file_writer.interface.flush(); |
| 1379 | break :b pack_file_writer.moveToReader(io); | |
| 1379 | break :b pack_file_writer.moveToReader(); | |
| 1380 | 1380 | }; |
| 1381 | 1381 | |
| 1382 | 1382 | var index_file = try pack_dir.createFile(io, "pkg.idx", .{ .read = true }); |
| ... | ... | @@ -1421,26 +1421,21 @@ fn recursiveDirectoryCopy(f: *Fetch, dir: Io.Dir, tmp_dir: Io.Dir) anyerror!void |
| 1421 | 1421 | // Recursive directory copy. |
| 1422 | 1422 | var it = try dir.walk(gpa); |
| 1423 | 1423 | defer it.deinit(); |
| 1424 | while (try it.next()) |entry| { | |
| 1424 | while (try it.next(io)) |entry| { | |
| 1425 | 1425 | switch (entry.kind) { |
| 1426 | 1426 | .directory => {}, // omit empty directories |
| 1427 | 1427 | .file => { |
| 1428 | dir.copyFile( | |
| 1429 | entry.path, | |
| 1430 | tmp_dir, | |
| 1431 | entry.path, | |
| 1432 | .{}, | |
| 1433 | ) catch |err| switch (err) { | |
| 1428 | dir.copyFile(entry.path, tmp_dir, entry.path, io, .{}) catch |err| switch (err) { | |
| 1434 | 1429 | error.FileNotFound => { |
| 1435 | 1430 | if (fs.path.dirname(entry.path)) |dirname| try tmp_dir.makePath(io, dirname); |
| 1436 | try dir.copyFile(entry.path, tmp_dir, entry.path, .{}); | |
| 1431 | try dir.copyFile(entry.path, tmp_dir, entry.path, io, .{}); | |
| 1437 | 1432 | }, |
| 1438 | 1433 | else => |e| return e, |
| 1439 | 1434 | }; |
| 1440 | 1435 | }, |
| 1441 | 1436 | .sym_link => { |
| 1442 | 1437 | var buf: [fs.max_path_bytes]u8 = undefined; |
| 1443 | const link_name = try dir.readLink(io, entry.path, &buf); | |
| 1438 | const link_name = buf[0..try dir.readLink(io, entry.path, &buf)]; | |
| 1444 | 1439 | // TODO: if this would create a symlink to outside |
| 1445 | 1440 | // the destination directory, fail with an error instead. |
| 1446 | 1441 | tmp_dir.symLink(io, link_name, entry.path, .{}) catch |err| switch (err) { |
| ... | ... | @@ -1524,7 +1519,7 @@ fn computeHash(f: *Fetch, pkg_path: Cache.Path, filter: Filter) RunError!Compute |
| 1524 | 1519 | var group: Io.Group = .init; |
| 1525 | 1520 | defer group.wait(io); |
| 1526 | 1521 | |
| 1527 | while (walker.next() catch |err| { | |
| 1522 | while (walker.next(io) catch |err| { | |
| 1528 | 1523 | try eb.addRootErrorMessage(.{ .msg = try eb.printString( |
| 1529 | 1524 | "unable to walk temporary directory '{f}': {s}", |
| 1530 | 1525 | .{ pkg_path, @errorName(err) }, |
| ... | ... | @@ -1575,7 +1570,7 @@ fn computeHash(f: *Fetch, pkg_path: Cache.Path, filter: Filter) RunError!Compute |
| 1575 | 1570 | .failure = undefined, // to be populated by the worker |
| 1576 | 1571 | .size = undefined, // to be populated by the worker |
| 1577 | 1572 | }; |
| 1578 | group.async(io, workerHashFile, .{ root_dir, hashed_file }); | |
| 1573 | group.async(io, workerHashFile, .{ io, root_dir, hashed_file }); | |
| 1579 | 1574 | try all_files.append(hashed_file); |
| 1580 | 1575 | } |
| 1581 | 1576 | } |
| ... | ... | @@ -1643,7 +1638,7 @@ fn computeHash(f: *Fetch, pkg_path: Cache.Path, filter: Filter) RunError!Compute |
| 1643 | 1638 | assert(!f.job_queue.recursive); |
| 1644 | 1639 | // Print something to stdout that can be text diffed to figure out why |
| 1645 | 1640 | // the package hash is different. |
| 1646 | dumpHashInfo(all_files.items) catch |err| { | |
| 1641 | dumpHashInfo(io, all_files.items) catch |err| { | |
| 1647 | 1642 | std.debug.print("unable to write to stdout: {s}\n", .{@errorName(err)}); |
| 1648 | 1643 | std.process.exit(1); |
| 1649 | 1644 | }; |
| ... | ... | @@ -1655,9 +1650,9 @@ fn computeHash(f: *Fetch, pkg_path: Cache.Path, filter: Filter) RunError!Compute |
| 1655 | 1650 | }; |
| 1656 | 1651 | } |
| 1657 | 1652 | |
| 1658 | fn dumpHashInfo(all_files: []const *const HashedFile) !void { | |
| 1653 | fn dumpHashInfo(io: Io, all_files: []const *const HashedFile) !void { | |
| 1659 | 1654 | var stdout_buffer: [1024]u8 = undefined; |
| 1660 | var stdout_writer: Io.File.Writer = .initStreaming(.stdout(), &stdout_buffer); | |
| 1655 | var stdout_writer: Io.File.Writer = .initStreaming(.stdout(), io, &stdout_buffer); | |
| 1661 | 1656 | const w = &stdout_writer.interface; |
| 1662 | 1657 | for (all_files) |hashed_file| { |
| 1663 | 1658 | try w.print("{t}: {x}: {s}\n", .{ hashed_file.kind, &hashed_file.hash, hashed_file.normalized_path }); |
| ... | ... | @@ -1665,8 +1660,8 @@ fn dumpHashInfo(all_files: []const *const HashedFile) !void { |
| 1665 | 1660 | try w.flush(); |
| 1666 | 1661 | } |
| 1667 | 1662 | |
| 1668 | fn workerHashFile(dir: Io.Dir, hashed_file: *HashedFile) void { | |
| 1669 | hashed_file.failure = hashFileFallible(dir, hashed_file); | |
| 1663 | fn workerHashFile(io: Io, dir: Io.Dir, hashed_file: *HashedFile) void { | |
| 1664 | hashed_file.failure = hashFileFallible(io, dir, hashed_file); | |
| 1670 | 1665 | } |
| 1671 | 1666 | |
| 1672 | 1667 | fn workerDeleteFile(io: Io, dir: Io.Dir, deleted_file: *DeletedFile) void { |
| ... | ... | @@ -1745,7 +1740,7 @@ const HashedFile = struct { |
| 1745 | 1740 | Io.File.OpenError || |
| 1746 | 1741 | Io.File.Reader.Error || |
| 1747 | 1742 | Io.File.StatError || |
| 1748 | Io.File.ChmodError || | |
| 1743 | Io.File.SetPermissionsError || | |
| 1749 | 1744 | Io.Dir.ReadLinkError; |
| 1750 | 1745 | |
| 1751 | 1746 | const Kind = enum { file, link }; |
src/Package/Fetch/git.zig+1-1| ... | ... | @@ -274,7 +274,7 @@ pub const Repository = struct { |
| 274 | 274 | continue; |
| 275 | 275 | }; |
| 276 | 276 | defer file.close(io); |
| 277 | try file.writeAll(file_object.data); | |
| 277 | try file.writePositionalAll(io, file_object.data, 0); | |
| 278 | 278 | }, |
| 279 | 279 | .symlink => { |
| 280 | 280 | try repository.odb.seekOid(entry.oid); |
src/Sema.zig+1-1| ... | ... | @@ -2679,7 +2679,7 @@ pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Zcu.ErrorMsg |
| 2679 | 2679 | Compilation.addModuleErrorMsg(zcu, &wip_errors, err_msg.*, false) catch @panic("out of memory"); |
| 2680 | 2680 | std.debug.print("compile error during Sema:\n", .{}); |
| 2681 | 2681 | var error_bundle = wip_errors.toOwnedBundle("") catch @panic("out of memory"); |
| 2682 | error_bundle.renderToStderr(io, .{}, .auto); | |
| 2682 | error_bundle.renderToStderr(io, .{}, .auto) catch @panic("failed to print to stderr"); | |
| 2683 | 2683 | std.debug.panicExtra(@returnAddress(), "unexpected compile error occurred", .{}); |
| 2684 | 2684 | } |
| 2685 | 2685 |
src/Zcu.zig+7-10| ... | ... | @@ -2988,11 +2988,10 @@ pub fn loadZirCacheBody(gpa: Allocator, header: Zir.Header, cache_br: *Io.Reader |
| 2988 | 2988 | |
| 2989 | 2989 | pub fn saveZirCache( |
| 2990 | 2990 | gpa: Allocator, |
| 2991 | io: Io, | |
| 2992 | cache_file: Io.File, | |
| 2991 | cache_file_writer: *Io.File.Writer, | |
| 2993 | 2992 | stat: Io.File.Stat, |
| 2994 | 2993 | zir: Zir, |
| 2995 | ) (Io.File.WriteError || Allocator.Error)!void { | |
| 2994 | ) (Io.File.Writer.Error || Allocator.Error)!void { | |
| 2996 | 2995 | const safety_buffer = if (data_has_safety_tag) |
| 2997 | 2996 | try gpa.alloc([8]u8, zir.instructions.len) |
| 2998 | 2997 | else |
| ... | ... | @@ -3026,13 +3025,12 @@ pub fn saveZirCache( |
| 3026 | 3025 | zir.string_bytes, |
| 3027 | 3026 | @ptrCast(zir.extra), |
| 3028 | 3027 | }; |
| 3029 | var cache_fw = cache_file.writer(io, &.{}); | |
| 3030 | cache_fw.interface.writeVecAll(&vecs) catch |err| switch (err) { | |
| 3031 | error.WriteFailed => return cache_fw.err.?, | |
| 3028 | cache_file_writer.interface.writeVecAll(&vecs) catch |err| switch (err) { | |
| 3029 | error.WriteFailed => return cache_file_writer.err.?, | |
| 3032 | 3030 | }; |
| 3033 | 3031 | } |
| 3034 | 3032 | |
| 3035 | pub fn saveZoirCache(io: Io, cache_file: Io.File, stat: Io.File.Stat, zoir: Zoir) Io.File.WriteError!void { | |
| 3033 | pub fn saveZoirCache(cache_file_writer: *Io.File.Writer, stat: Io.File.Stat, zoir: Zoir) Io.File.Writer.Error!void { | |
| 3036 | 3034 | const header: Zoir.Header = .{ |
| 3037 | 3035 | .nodes_len = @intCast(zoir.nodes.len), |
| 3038 | 3036 | .extra_len = @intCast(zoir.extra.len), |
| ... | ... | @@ -3056,9 +3054,8 @@ pub fn saveZoirCache(io: Io, cache_file: Io.File, stat: Io.File.Stat, zoir: Zoir |
| 3056 | 3054 | @ptrCast(zoir.compile_errors), |
| 3057 | 3055 | @ptrCast(zoir.error_notes), |
| 3058 | 3056 | }; |
| 3059 | var cache_fw = cache_file.writer(io, &.{}); | |
| 3060 | cache_fw.interface.writeVecAll(&vecs) catch |err| switch (err) { | |
| 3061 | error.WriteFailed => return cache_fw.err.?, | |
| 3057 | cache_file_writer.interface.writeVecAll(&vecs) catch |err| switch (err) { | |
| 3058 | error.WriteFailed => return cache_file_writer.err.?, | |
| 3062 | 3059 | }; |
| 3063 | 3060 | } |
| 3064 | 3061 |
src/Zcu/PerThread.zig+35-15| ... | ... | @@ -238,18 +238,13 @@ pub fn updateFile( |
| 238 | 238 | if (builtin.os.tag == .wasi or lock == .exclusive) break true; |
| 239 | 239 | // Otherwise, unlock to give someone a chance to get the exclusive lock |
| 240 | 240 | // and then upgrade to an exclusive lock. |
| 241 | cache_file.unlock(); | |
| 241 | cache_file.unlock(io); | |
| 242 | 242 | lock = .exclusive; |
| 243 | try cache_file.lock(lock); | |
| 243 | try cache_file.lock(io, lock); | |
| 244 | 244 | }; |
| 245 | 245 | |
| 246 | 246 | if (need_update) { |
| 247 | // The cache is definitely stale so delete the contents to avoid an underwrite later. | |
| 248 | cache_file.setLength(io, 0) catch |err| switch (err) { | |
| 249 | error.FileTooBig => unreachable, // 0 is not too big | |
| 250 | else => |e| return e, | |
| 251 | }; | |
| 252 | try cache_file.seekTo(0); | |
| 247 | var cache_file_writer: Io.File.Writer = .init(cache_file, io, &.{}); | |
| 253 | 248 | |
| 254 | 249 | if (stat.size > std.math.maxInt(u32)) |
| 255 | 250 | return error.FileTooBig; |
| ... | ... | @@ -278,7 +273,7 @@ pub fn updateFile( |
| 278 | 273 | switch (file.getMode()) { |
| 279 | 274 | .zig => { |
| 280 | 275 | file.zir = try AstGen.generate(gpa, file.tree.?); |
| 281 | Zcu.saveZirCache(gpa, io, cache_file, stat, file.zir.?) catch |err| switch (err) { | |
| 276 | Zcu.saveZirCache(gpa, &cache_file_writer, stat, file.zir.?) catch |err| switch (err) { | |
| 282 | 277 | error.OutOfMemory => |e| return e, |
| 283 | 278 | else => log.warn("unable to write cached ZIR code for {f} to {f}{s}: {t}", .{ |
| 284 | 279 | file.path.fmt(comp), cache_directory, &hex_digest, err, |
| ... | ... | @@ -287,13 +282,19 @@ pub fn updateFile( |
| 287 | 282 | }, |
| 288 | 283 | .zon => { |
| 289 | 284 | file.zoir = try ZonGen.generate(gpa, file.tree.?, .{}); |
| 290 | Zcu.saveZoirCache(io, cache_file, stat, file.zoir.?) catch |err| { | |
| 285 | Zcu.saveZoirCache(&cache_file_writer, stat, file.zoir.?) catch |err| { | |
| 291 | 286 | log.warn("unable to write cached ZOIR code for {f} to {f}{s}: {t}", .{ |
| 292 | 287 | file.path.fmt(comp), cache_directory, &hex_digest, err, |
| 293 | 288 | }); |
| 294 | 289 | }; |
| 295 | 290 | }, |
| 296 | 291 | } |
| 292 | ||
| 293 | cache_file_writer.end() catch |err| switch (err) { | |
| 294 | error.WriteFailed => return cache_file_writer.err.?, | |
| 295 | else => |e| return e, | |
| 296 | }; | |
| 297 | ||
| 297 | 298 | if (timer.finish()) |ns_astgen| { |
| 298 | 299 | comp.mutex.lockUncancelable(io); |
| 299 | 300 | defer comp.mutex.unlock(io); |
| ... | ... | @@ -4524,12 +4525,14 @@ pub fn runCodegen(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) Ru |
| 4524 | 4525 | .stage2_llvm, |
| 4525 | 4526 | => {}, |
| 4526 | 4527 | }, |
| 4528 | error.Canceled => |e| return e, | |
| 4527 | 4529 | } |
| 4528 | 4530 | return error.AlreadyReported; |
| 4529 | 4531 | }; |
| 4530 | 4532 | } |
| 4531 | 4533 | fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) error{ |
| 4532 | 4534 | OutOfMemory, |
| 4535 | Canceled, | |
| 4533 | 4536 | CodegenFail, |
| 4534 | 4537 | NoLinkFile, |
| 4535 | 4538 | BackendDoesNotProduceMir, |
| ... | ... | @@ -4555,13 +4558,16 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e |
| 4555 | 4558 | null; |
| 4556 | 4559 | defer if (liveness) |*l| l.deinit(gpa); |
| 4557 | 4560 | |
| 4558 | if (build_options.enable_debug_extensions and comp.verbose_air) { | |
| 4561 | if (build_options.enable_debug_extensions and comp.verbose_air) p: { | |
| 4559 | 4562 | const io = comp.io; |
| 4560 | 4563 | const stderr = try io.lockStderrWriter(&.{}); |
| 4561 | 4564 | defer io.unlockStderrWriter(); |
| 4562 | stderr.print("# Begin Function AIR: {f}:\n", .{fqn.fmt(ip)}) catch {}; | |
| 4563 | air.write(stderr, pt, liveness); | |
| 4564 | stderr.print("# End Function AIR: {f}\n\n", .{fqn.fmt(ip)}) catch {}; | |
| 4565 | printVerboseAir(pt, liveness, fqn, air, &stderr.interface) catch |err| switch (err) { | |
| 4566 | error.WriteFailed => switch (stderr.err.?) { | |
| 4567 | error.Canceled => |e| return e, | |
| 4568 | else => break :p, | |
| 4569 | }, | |
| 4570 | }; | |
| 4565 | 4571 | } |
| 4566 | 4572 | |
| 4567 | 4573 | if (std.debug.runtime_safety) verify_liveness: { |
| ... | ... | @@ -4576,7 +4582,7 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e |
| 4576 | 4582 | |
| 4577 | 4583 | verify.verify() catch |err| switch (err) { |
| 4578 | 4584 | error.OutOfMemory => return error.OutOfMemory, |
| 4579 | else => return zcu.codegenFail(nav, "invalid liveness: {s}", .{@errorName(err)}), | |
| 4585 | else => return zcu.codegenFail(nav, "invalid liveness: {t}", .{err}), | |
| 4580 | 4586 | }; |
| 4581 | 4587 | } |
| 4582 | 4588 | |
| ... | ... | @@ -4612,3 +4618,17 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e |
| 4612 | 4618 | => return zcu.codegenFail(nav, "unable to codegen: {s}", .{@errorName(err)}), |
| 4613 | 4619 | }; |
| 4614 | 4620 | } |
| 4621 | ||
| 4622 | fn printVerboseAir( | |
| 4623 | pt: Zcu.PerThread, | |
| 4624 | liveness: ?Air.Liveness, | |
| 4625 | fqn: InternPool.NullTerminatedString, | |
| 4626 | air: *const Air, | |
| 4627 | w: *Io.Writer, | |
| 4628 | ) Io.Writer.Error!void { | |
| 4629 | const zcu = pt.zcu; | |
| 4630 | const ip = &zcu.intern_pool; | |
| 4631 | try w.print("# Begin Function AIR: {f}:\n", .{fqn.fmt(ip)}); | |
| 4632 | try air.write(w, pt, liveness); | |
| 4633 | try w.print("# End Function AIR: {f}\n\n", .{fqn.fmt(ip)}); | |
| 4634 | } |
src/fmt.zig+6-6| ... | ... | @@ -124,7 +124,7 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) ! |
| 124 | 124 | try wip_errors.addZirErrorMessages(zir, tree, source_code, "<stdin>"); |
| 125 | 125 | var error_bundle = try wip_errors.toOwnedBundle(""); |
| 126 | 126 | defer error_bundle.deinit(gpa); |
| 127 | error_bundle.renderToStderr(io, .{}, color); | |
| 127 | error_bundle.renderToStderr(io, .{}, color) catch {}; | |
| 128 | 128 | process.exit(2); |
| 129 | 129 | } |
| 130 | 130 | } else { |
| ... | ... | @@ -138,12 +138,12 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) ! |
| 138 | 138 | try wip_errors.addZoirErrorMessages(zoir, tree, source_code, "<stdin>"); |
| 139 | 139 | var error_bundle = try wip_errors.toOwnedBundle(""); |
| 140 | 140 | defer error_bundle.deinit(gpa); |
| 141 | error_bundle.renderToStderr(io, .{}, color); | |
| 141 | error_bundle.renderToStderr(io, .{}, color) catch {}; | |
| 142 | 142 | process.exit(2); |
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | } else if (tree.errors.len != 0) { |
| 146 | try std.zig.printAstErrorsToStderr(gpa, tree, "<stdin>", color); | |
| 146 | std.zig.printAstErrorsToStderr(gpa, io, tree, "<stdin>", color) catch {}; | |
| 147 | 147 | process.exit(2); |
| 148 | 148 | } |
| 149 | 149 | const formatted = try tree.renderAlloc(gpa); |
| ... | ... | @@ -298,7 +298,7 @@ fn fmtPathFile( |
| 298 | 298 | defer tree.deinit(gpa); |
| 299 | 299 | |
| 300 | 300 | if (tree.errors.len != 0) { |
| 301 | try std.zig.printAstErrorsToStderr(gpa, tree, file_path, fmt.color); | |
| 301 | try std.zig.printAstErrorsToStderr(gpa, io, tree, file_path, fmt.color); | |
| 302 | 302 | fmt.any_error = true; |
| 303 | 303 | return; |
| 304 | 304 | } |
| ... | ... | @@ -319,7 +319,7 @@ fn fmtPathFile( |
| 319 | 319 | try wip_errors.addZirErrorMessages(zir, tree, source_code, file_path); |
| 320 | 320 | var error_bundle = try wip_errors.toOwnedBundle(""); |
| 321 | 321 | defer error_bundle.deinit(gpa); |
| 322 | error_bundle.renderToStderr(io, .{}, fmt.color); | |
| 322 | try error_bundle.renderToStderr(io, .{}, fmt.color); | |
| 323 | 323 | fmt.any_error = true; |
| 324 | 324 | } |
| 325 | 325 | }, |
| ... | ... | @@ -334,7 +334,7 @@ fn fmtPathFile( |
| 334 | 334 | try wip_errors.addZoirErrorMessages(zoir, tree, source_code, file_path); |
| 335 | 335 | var error_bundle = try wip_errors.toOwnedBundle(""); |
| 336 | 336 | defer error_bundle.deinit(gpa); |
| 337 | error_bundle.renderToStderr(io, .{}, fmt.color); | |
| 337 | try error_bundle.renderToStderr(io, .{}, fmt.color); | |
| 338 | 338 | fmt.any_error = true; |
| 339 | 339 | } |
| 340 | 340 | }, |
src/libs/freebsd.zig+2-2| ... | ... | @@ -401,8 +401,8 @@ pub const BuiltSharedObjects = struct { |
| 401 | 401 | lock: Cache.Lock, |
| 402 | 402 | dir_path: Path, |
| 403 | 403 | |
| 404 | pub fn deinit(self: *BuiltSharedObjects, gpa: Allocator) void { | |
| 405 | self.lock.release(); | |
| 404 | pub fn deinit(self: *BuiltSharedObjects, gpa: Allocator, io: Io) void { | |
| 405 | self.lock.release(io); | |
| 406 | 406 | gpa.free(self.dir_path.sub_path); |
| 407 | 407 | self.* = undefined; |
| 408 | 408 | } |
src/libs/glibc.zig+2-2| ... | ... | @@ -640,8 +640,8 @@ pub const BuiltSharedObjects = struct { |
| 640 | 640 | lock: Cache.Lock, |
| 641 | 641 | dir_path: Path, |
| 642 | 642 | |
| 643 | pub fn deinit(self: *BuiltSharedObjects, gpa: Allocator) void { | |
| 644 | self.lock.release(); | |
| 643 | pub fn deinit(self: *BuiltSharedObjects, gpa: Allocator, io: Io) void { | |
| 644 | self.lock.release(io); | |
| 645 | 645 | gpa.free(self.dir_path.sub_path); |
| 646 | 646 | self.* = undefined; |
| 647 | 647 | } |
src/libs/netbsd.zig+2-2| ... | ... | @@ -346,8 +346,8 @@ pub const BuiltSharedObjects = struct { |
| 346 | 346 | lock: Cache.Lock, |
| 347 | 347 | dir_path: Path, |
| 348 | 348 | |
| 349 | pub fn deinit(self: *BuiltSharedObjects, gpa: Allocator) void { | |
| 350 | self.lock.release(); | |
| 349 | pub fn deinit(self: *BuiltSharedObjects, gpa: Allocator, io: Io) void { | |
| 350 | self.lock.release(io); | |
| 351 | 351 | gpa.free(self.dir_path.sub_path); |
| 352 | 352 | self.* = undefined; |
| 353 | 353 | } |
src/link.zig+2-3| ... | ... | @@ -2246,13 +2246,12 @@ fn resolvePathInputLib( |
| 2246 | 2246 | var error_bundle = try wip_errors.toOwnedBundle(""); |
| 2247 | 2247 | defer error_bundle.deinit(gpa); |
| 2248 | 2248 | |
| 2249 | error_bundle.renderToStderr(io, .{}, color); | |
| 2250 | ||
| 2249 | error_bundle.renderToStderr(io, .{}, color) catch {}; | |
| 2251 | 2250 | std.process.exit(1); |
| 2252 | 2251 | } |
| 2253 | 2252 | |
| 2254 | 2253 | var ld_script = ld_script_result catch |err| |
| 2255 | fatal("{f}: failed to parse linker script: {s}", .{ test_path, @errorName(err) }); | |
| 2254 | fatal("{f}: failed to parse linker script: {t}", .{ test_path, err }); | |
| 2256 | 2255 | defer ld_script.deinit(gpa); |
| 2257 | 2256 | |
| 2258 | 2257 | try unresolved_inputs.ensureUnusedCapacity(gpa, ld_script.args.len); |
src/main.zig+6-1| ... | ... | @@ -4598,6 +4598,8 @@ const UpdateModuleError = Compilation.UpdateError || error{ |
| 4598 | 4598 | /// The update caused compile errors. The error bundle has already been |
| 4599 | 4599 | /// reported to the user by being rendered to stderr. |
| 4600 | 4600 | CompileErrorsReported, |
| 4601 | /// Error occurred printing compilation errors to stderr. | |
| 4602 | PrintingErrorsFailed, | |
| 4601 | 4603 | }; |
| 4602 | 4604 | fn updateModule(comp: *Compilation, color: Color, prog_node: std.Progress.Node) UpdateModuleError!void { |
| 4603 | 4605 | try comp.update(prog_node); |
| ... | ... | @@ -4607,7 +4609,10 @@ fn updateModule(comp: *Compilation, color: Color, prog_node: std.Progress.Node) |
| 4607 | 4609 | |
| 4608 | 4610 | if (errors.errorMessageCount() > 0) { |
| 4609 | 4611 | const io = comp.io; |
| 4610 | try errors.renderToStderr(io, .{}, color); | |
| 4612 | errors.renderToStderr(io, .{}, color) catch |err| switch (err) { | |
| 4613 | error.Canceled => |e| return e, | |
| 4614 | else => return error.PrintingErrorsFailed, | |
| 4615 | }; | |
| 4611 | 4616 | return error.CompileErrorsReported; |
| 4612 | 4617 | } |
| 4613 | 4618 | } |