authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-18 06:42:41-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-18 06:42:54-07:00
log6e5589866193a6bd73c75b126adeecd71924b6f5
treef37daaea18c49f11f78a9b604f32aa9c7d128a6c
parent3ae0ba096d6ba9181a984d0745e1e079c67d62ff

Compilation: refactor std.fs -> fs

no functional change

1 files changed, 51 insertions(+), 51 deletions(-)

src/Compilation.zig+51-51
...@@ -684,7 +684,7 @@ pub const Directories = struct {...@@ -684,7 +684,7 @@ pub const Directories = struct {
684 global,684 global,
685 },685 },
686 wasi_preopens: switch (builtin.target.os.tag) {686 wasi_preopens: switch (builtin.target.os.tag) {
687 .wasi => std.fs.wasi.Preopens,687 .wasi => fs.wasi.Preopens,
688 else => void,688 else => void,
689 },689 },
690 self_exe_path: switch (builtin.target.os.tag) {690 self_exe_path: switch (builtin.target.os.tag) {
...@@ -741,7 +741,7 @@ pub const Directories = struct {...@@ -741,7 +741,7 @@ pub const Directories = struct {
741 .local_cache = local_cache,741 .local_cache = local_cache,
742 };742 };
743 }743 }
744 fn openWasiPreopen(preopens: std.fs.wasi.Preopens, name: []const u8) Cache.Directory {744 fn openWasiPreopen(preopens: fs.wasi.Preopens, name: []const u8) Cache.Directory {
745 return .{745 return .{
746 .path = if (std.mem.eql(u8, name, ".")) null else name,746 .path = if (std.mem.eql(u8, name, ".")) null else name,
747 .handle = .{747 .handle = .{
...@@ -755,8 +755,8 @@ pub const Directories = struct {...@@ -755,8 +755,8 @@ pub const Directories = struct {
755 };755 };
756 const nonempty_path = if (path.len == 0) "." else path;756 const nonempty_path = if (path.len == 0) "." else path;
757 const handle_or_err = switch (thing) {757 const handle_or_err = switch (thing) {
758 .@"zig lib" => std.fs.cwd().openDir(nonempty_path, .{}),758 .@"zig lib" => fs.cwd().openDir(nonempty_path, .{}),
759 .@"global cache", .@"local cache" => std.fs.cwd().makeOpenPath(nonempty_path, .{}),759 .@"global cache", .@"local cache" => fs.cwd().makeOpenPath(nonempty_path, .{}),
760 };760 };
761 return .{761 return .{
762 .path = if (path.len == 0) null else path,762 .path = if (path.len == 0) null else path,
...@@ -993,7 +993,7 @@ pub const CObject = struct {...@@ -993,7 +993,7 @@ pub const CObject = struct {
993 const source_line = source_line: {993 const source_line = source_line: {
994 if (diag.src_loc.offset == 0 or diag.src_loc.column == 0) break :source_line 0;994 if (diag.src_loc.offset == 0 or diag.src_loc.column == 0) break :source_line 0;
995995
996 const file = std.fs.cwd().openFile(file_name, .{}) catch break :source_line 0;996 const file = fs.cwd().openFile(file_name, .{}) catch break :source_line 0;
997 defer file.close();997 defer file.close();
998 file.seekTo(diag.src_loc.offset + 1 - diag.src_loc.column) catch break :source_line 0;998 file.seekTo(diag.src_loc.offset + 1 - diag.src_loc.column) catch break :source_line 0;
999999
...@@ -1067,7 +1067,7 @@ pub const CObject = struct {...@@ -1067,7 +1067,7 @@ pub const CObject = struct {
1067 }1067 }
1068 };1068 };
10691069
1070 const file = try std.fs.cwd().openFile(path, .{});1070 const file = try fs.cwd().openFile(path, .{});
1071 defer file.close();1071 defer file.close();
1072 var br = std.io.bufferedReader(file.deprecatedReader());1072 var br = std.io.bufferedReader(file.deprecatedReader());
1073 const reader = br.reader();1073 const reader = br.reader();
...@@ -1875,7 +1875,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1875,7 +1875,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1875 if (options.root_mod.resolved_target.llvm_cpu_features) |cf| print: {1875 if (options.root_mod.resolved_target.llvm_cpu_features) |cf| print: {
1876 std.debug.lockStdErr();1876 std.debug.lockStdErr();
1877 defer std.debug.unlockStdErr();1877 defer std.debug.unlockStdErr();
1878 const stderr = std.fs.File.stderr().deprecatedWriter();1878 const stderr = fs.File.stderr().deprecatedWriter();
1879 nosuspend {1879 nosuspend {
1880 stderr.print("compilation: {s}\n", .{options.root_name}) catch break :print;1880 stderr.print("compilation: {s}\n", .{options.root_name}) catch break :print;
1881 stderr.print(" target: {s}\n", .{try target.zigTriple(arena)}) catch break :print;1881 stderr.print(" target: {s}\n", .{try target.zigTriple(arena)}) catch break :print;
...@@ -1901,7 +1901,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1901,7 +1901,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1901 .manifest_dir = try options.dirs.local_cache.handle.makeOpenPath("h", .{}),1901 .manifest_dir = try options.dirs.local_cache.handle.makeOpenPath("h", .{}),
1902 };1902 };
1903 // These correspond to std.zig.Server.Message.PathPrefix.1903 // These correspond to std.zig.Server.Message.PathPrefix.
1904 cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() });1904 cache.addPrefix(.{ .path = null, .handle = fs.cwd() });
1905 cache.addPrefix(options.dirs.zig_lib);1905 cache.addPrefix(options.dirs.zig_lib);
1906 cache.addPrefix(options.dirs.local_cache);1906 cache.addPrefix(options.dirs.local_cache);
1907 cache.addPrefix(options.dirs.global_cache);1907 cache.addPrefix(options.dirs.global_cache);
...@@ -2192,7 +2192,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -2192,7 +2192,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
2192 comp.digest = hash.peekBin();2192 comp.digest = hash.peekBin();
2193 const digest = hash.final();2193 const digest = hash.final();
21942194
2195 const artifact_sub_dir = "o" ++ std.fs.path.sep_str ++ digest;2195 const artifact_sub_dir = "o" ++ fs.path.sep_str ++ digest;
2196 var artifact_dir = try options.dirs.local_cache.handle.makeOpenPath(artifact_sub_dir, .{});2196 var artifact_dir = try options.dirs.local_cache.handle.makeOpenPath(artifact_sub_dir, .{});
2197 errdefer artifact_dir.close();2197 errdefer artifact_dir.close();
2198 const artifact_directory: Cache.Directory = .{2198 const artifact_directory: Cache.Directory = .{
...@@ -2604,11 +2604,11 @@ fn cleanupAfterUpdate(comp: *Compilation, tmp_dir_rand_int: u64) void {...@@ -2604,11 +2604,11 @@ fn cleanupAfterUpdate(comp: *Compilation, tmp_dir_rand_int: u64) void {
2604 // temporary directories; it doesn't have a real cache directory anyway.2604 // temporary directories; it doesn't have a real cache directory anyway.
2605 return;2605 return;
2606 }2606 }
2607 const tmp_dir_sub_path = "tmp" ++ std.fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int);2607 const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int);
2608 comp.dirs.local_cache.handle.deleteTree(tmp_dir_sub_path) catch |err| {2608 comp.dirs.local_cache.handle.deleteTree(tmp_dir_sub_path) catch |err| {
2609 log.warn("failed to delete temporary directory '{s}{c}{s}': {s}", .{2609 log.warn("failed to delete temporary directory '{s}{c}{s}': {s}", .{
2610 comp.dirs.local_cache.path orelse ".",2610 comp.dirs.local_cache.path orelse ".",
2611 std.fs.path.sep,2611 fs.path.sep,
2612 tmp_dir_sub_path,2612 tmp_dir_sub_path,
2613 @errorName(err),2613 @errorName(err),
2614 });2614 });
...@@ -2628,11 +2628,11 @@ fn cleanupAfterUpdate(comp: *Compilation, tmp_dir_rand_int: u64) void {...@@ -2628,11 +2628,11 @@ fn cleanupAfterUpdate(comp: *Compilation, tmp_dir_rand_int: u64) void {
2628 if (whole.tmp_artifact_directory) |*tmp_dir| {2628 if (whole.tmp_artifact_directory) |*tmp_dir| {
2629 tmp_dir.handle.close();2629 tmp_dir.handle.close();
2630 whole.tmp_artifact_directory = null;2630 whole.tmp_artifact_directory = null;
2631 const tmp_dir_sub_path = "tmp" ++ std.fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int);2631 const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int);
2632 comp.dirs.local_cache.handle.deleteTree(tmp_dir_sub_path) catch |err| {2632 comp.dirs.local_cache.handle.deleteTree(tmp_dir_sub_path) catch |err| {
2633 log.warn("failed to delete temporary directory '{s}{c}{s}': {s}", .{2633 log.warn("failed to delete temporary directory '{s}{c}{s}': {s}", .{
2634 comp.dirs.local_cache.path orelse ".",2634 comp.dirs.local_cache.path orelse ".",
2635 std.fs.path.sep,2635 fs.path.sep,
2636 tmp_dir_sub_path,2636 tmp_dir_sub_path,
2637 @errorName(err),2637 @errorName(err),
2638 });2638 });
...@@ -2668,7 +2668,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void {...@@ -2668,7 +2668,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void {
2668 assert(none.tmp_artifact_directory == null);2668 assert(none.tmp_artifact_directory == null);
2669 none.tmp_artifact_directory = d: {2669 none.tmp_artifact_directory = d: {
2670 tmp_dir_rand_int = std.crypto.random.int(u64);2670 tmp_dir_rand_int = std.crypto.random.int(u64);
2671 const tmp_dir_sub_path = "tmp" ++ std.fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int);2671 const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int);
2672 const path = try comp.dirs.local_cache.join(arena, &.{tmp_dir_sub_path});2672 const path = try comp.dirs.local_cache.join(arena, &.{tmp_dir_sub_path});
2673 break :d .{2673 break :d .{
2674 .path = path,2674 .path = path,
...@@ -2735,7 +2735,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void {...@@ -2735,7 +2735,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void {
2735 // Compile the artifacts to a temporary directory.2735 // Compile the artifacts to a temporary directory.
2736 whole.tmp_artifact_directory = d: {2736 whole.tmp_artifact_directory = d: {
2737 tmp_dir_rand_int = std.crypto.random.int(u64);2737 tmp_dir_rand_int = std.crypto.random.int(u64);
2738 const tmp_dir_sub_path = "tmp" ++ std.fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int);2738 const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int);
2739 const path = try comp.dirs.local_cache.join(arena, &.{tmp_dir_sub_path});2739 const path = try comp.dirs.local_cache.join(arena, &.{tmp_dir_sub_path});
2740 break :d .{2740 break :d .{
2741 .path = path,2741 .path = path,
...@@ -2910,7 +2910,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void {...@@ -2910,7 +2910,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void {
2910 // Close tmp dir and link.File to avoid open handle during rename.2910 // Close tmp dir and link.File to avoid open handle during rename.
2911 whole.tmp_artifact_directory.?.handle.close();2911 whole.tmp_artifact_directory.?.handle.close();
2912 whole.tmp_artifact_directory = null;2912 whole.tmp_artifact_directory = null;
2913 const s = std.fs.path.sep_str;2913 const s = fs.path.sep_str;
2914 const tmp_dir_sub_path = "tmp" ++ s ++ std.fmt.hex(tmp_dir_rand_int);2914 const tmp_dir_sub_path = "tmp" ++ s ++ std.fmt.hex(tmp_dir_rand_int);
2915 const o_sub_path = "o" ++ s ++ hex_digest;2915 const o_sub_path = "o" ++ s ++ hex_digest;
2916 renameTmpIntoCache(comp.dirs.local_cache, tmp_dir_sub_path, o_sub_path) catch |err| {2916 renameTmpIntoCache(comp.dirs.local_cache, tmp_dir_sub_path, o_sub_path) catch |err| {
...@@ -2932,7 +2932,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void {...@@ -2932,7 +2932,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void {
2932 if (comp.bin_file) |lf| {2932 if (comp.bin_file) |lf| {
2933 lf.emit = .{2933 lf.emit = .{
2934 .root_dir = comp.dirs.local_cache,2934 .root_dir = comp.dirs.local_cache,
2935 .sub_path = try std.fs.path.join(arena, &.{ o_sub_path, comp.emit_bin.? }),2935 .sub_path = try fs.path.join(arena, &.{ o_sub_path, comp.emit_bin.? }),
2936 };2936 };
29372937
2938 switch (need_writable_dance) {2938 switch (need_writable_dance) {
...@@ -3105,7 +3105,7 @@ fn renameTmpIntoCache(...@@ -3105,7 +3105,7 @@ fn renameTmpIntoCache(
3105) !void {3105) !void {
3106 var seen_eaccess = false;3106 var seen_eaccess = false;
3107 while (true) {3107 while (true) {
3108 std.fs.rename(3108 fs.rename(
3109 cache_directory.handle,3109 cache_directory.handle,
3110 tmp_dir_sub_path,3110 tmp_dir_sub_path,
3111 cache_directory.handle,3111 cache_directory.handle,
...@@ -3931,7 +3931,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {...@@ -3931,7 +3931,7 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
3931 // This AU is referenced and has a transitive compile error, meaning it referenced something with a compile error.3931 // This AU is referenced and has a transitive compile error, meaning it referenced something with a compile error.
3932 // However, we haven't reported any such error.3932 // However, we haven't reported any such error.
3933 // This is a compiler bug.3933 // This is a compiler bug.
3934 const stderr = std.fs.File.stderr().deprecatedWriter();3934 const stderr = fs.File.stderr().deprecatedWriter();
3935 try stderr.writeAll("referenced transitive analysis errors, but none actually emitted\n");3935 try stderr.writeAll("referenced transitive analysis errors, but none actually emitted\n");
3936 try stderr.print("{f} [transitive failure]\n", .{zcu.fmtAnalUnit(failed_unit)});3936 try stderr.print("{f} [transitive failure]\n", .{zcu.fmtAnalUnit(failed_unit)});
3937 while (ref) |r| {3937 while (ref) |r| {
...@@ -4842,7 +4842,7 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void {...@@ -4842,7 +4842,7 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void {
4842 defer out_dir.close();4842 defer out_dir.close();
48434843
4844 for (&[_][]const u8{ "docs/main.js", "docs/index.html" }) |sub_path| {4844 for (&[_][]const u8{ "docs/main.js", "docs/index.html" }) |sub_path| {
4845 const basename = std.fs.path.basename(sub_path);4845 const basename = fs.path.basename(sub_path);
4846 comp.dirs.zig_lib.handle.copyFile(sub_path, out_dir, basename, .{}) catch |err| {4846 comp.dirs.zig_lib.handle.copyFile(sub_path, out_dir, basename, .{}) catch |err| {
4847 comp.lockAndSetMiscFailure(.docs_copy, "unable to copy {s}: {s}", .{4847 comp.lockAndSetMiscFailure(.docs_copy, "unable to copy {s}: {s}", .{
4848 sub_path,4848 sub_path,
...@@ -4878,7 +4878,7 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void {...@@ -4878,7 +4878,7 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void {
4878 }4878 }
4879}4879}
48804880
4881fn docsCopyModule(comp: *Compilation, module: *Package.Module, name: []const u8, tar_file: std.fs.File) !void {4881fn docsCopyModule(comp: *Compilation, module: *Package.Module, name: []const u8, tar_file: fs.File) !void {
4882 const root = module.root;4882 const root = module.root;
4883 var mod_dir = d: {4883 var mod_dir = d: {
4884 const root_dir, const sub_path = root.openInfo(comp.dirs);4884 const root_dir, const sub_path = root.openInfo(comp.dirs);
...@@ -4973,7 +4973,7 @@ fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -4973,7 +4973,7 @@ fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) anye
4973 });4973 });
49744974
4975 const src_basename = "main.zig";4975 const src_basename = "main.zig";
4976 const root_name = std.fs.path.stem(src_basename);4976 const root_name = fs.path.stem(src_basename);
49774977
4978 const dirs = comp.dirs.withoutLocalCache();4978 const dirs = comp.dirs.withoutLocalCache();
49794979
...@@ -5068,13 +5068,13 @@ fn workerUpdateFile(...@@ -5068,13 +5068,13 @@ fn workerUpdateFile(
5068 prog_node: std.Progress.Node,5068 prog_node: std.Progress.Node,
5069 wg: *WaitGroup,5069 wg: *WaitGroup,
5070) void {5070) void {
5071 const child_prog_node = prog_node.start(std.fs.path.basename(file.path.sub_path), 0);5071 const child_prog_node = prog_node.start(fs.path.basename(file.path.sub_path), 0);
5072 defer child_prog_node.end();5072 defer child_prog_node.end();
50735073
5074 const pt: Zcu.PerThread = .activate(comp.zcu.?, @enumFromInt(tid));5074 const pt: Zcu.PerThread = .activate(comp.zcu.?, @enumFromInt(tid));
5075 defer pt.deactivate();5075 defer pt.deactivate();
5076 pt.updateFile(file_index, file) catch |err| {5076 pt.updateFile(file_index, file) catch |err| {
5077 pt.reportRetryableFileError(file_index, "unable to load '{s}': {s}", .{ std.fs.path.basename(file.path.sub_path), @errorName(err) }) catch |oom| switch (oom) {5077 pt.reportRetryableFileError(file_index, "unable to load '{s}': {s}", .{ fs.path.basename(file.path.sub_path), @errorName(err) }) catch |oom| switch (oom) {
5078 error.OutOfMemory => {5078 error.OutOfMemory => {
5079 comp.mutex.lock();5079 comp.mutex.lock();
5080 defer comp.mutex.unlock();5080 defer comp.mutex.unlock();
...@@ -5239,7 +5239,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8, owner_mod: *Package.Module...@@ -5239,7 +5239,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8, owner_mod: *Package.Module
5239 const arena = arena_allocator.allocator();5239 const arena = arena_allocator.allocator();
52405240
5241 const tmp_digest = man.hash.peek();5241 const tmp_digest = man.hash.peek();
5242 const tmp_dir_sub_path = try std.fs.path.join(arena, &[_][]const u8{ "o", &tmp_digest });5242 const tmp_dir_sub_path = try fs.path.join(arena, &[_][]const u8{ "o", &tmp_digest });
5243 var zig_cache_tmp_dir = try comp.dirs.local_cache.handle.makeOpenPath(tmp_dir_sub_path, .{});5243 var zig_cache_tmp_dir = try comp.dirs.local_cache.handle.makeOpenPath(tmp_dir_sub_path, .{});
5244 defer zig_cache_tmp_dir.close();5244 defer zig_cache_tmp_dir.close();
5245 const cimport_basename = "cimport.h";5245 const cimport_basename = "cimport.h";
...@@ -5308,7 +5308,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8, owner_mod: *Package.Module...@@ -5308,7 +5308,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8, owner_mod: *Package.Module
5308 log.info("C import .d file: {s}", .{out_dep_path});5308 log.info("C import .d file: {s}", .{out_dep_path});
5309 }5309 }
53105310
5311 const dep_basename = std.fs.path.basename(out_dep_path);5311 const dep_basename = fs.path.basename(out_dep_path);
5312 try man.addDepFilePost(zig_cache_tmp_dir, dep_basename);5312 try man.addDepFilePost(zig_cache_tmp_dir, dep_basename);
5313 switch (comp.cache_use) {5313 switch (comp.cache_use) {
5314 .whole => |whole| if (whole.cache_manifest) |whole_cache_manifest| {5314 .whole => |whole| if (whole.cache_manifest) |whole_cache_manifest| {
...@@ -5321,7 +5321,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8, owner_mod: *Package.Module...@@ -5321,7 +5321,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8, owner_mod: *Package.Module
53215321
5322 const bin_digest = man.finalBin();5322 const bin_digest = man.finalBin();
5323 const hex_digest = Cache.binToHex(bin_digest);5323 const hex_digest = Cache.binToHex(bin_digest);
5324 const o_sub_path = "o" ++ std.fs.path.sep_str ++ hex_digest;5324 const o_sub_path = "o" ++ fs.path.sep_str ++ hex_digest;
5325 var o_dir = try comp.dirs.local_cache.handle.makeOpenPath(o_sub_path, .{});5325 var o_dir = try comp.dirs.local_cache.handle.makeOpenPath(o_sub_path, .{});
5326 defer o_dir.close();5326 defer o_dir.close();
53275327
...@@ -5674,7 +5674,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr...@@ -5674,7 +5674,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr
5674 defer arena_allocator.deinit();5674 defer arena_allocator.deinit();
5675 const arena = arena_allocator.allocator();5675 const arena = arena_allocator.allocator();
56765676
5677 const c_source_basename = std.fs.path.basename(c_object.src.src_path);5677 const c_source_basename = fs.path.basename(c_object.src.src_path);
56785678
5679 const child_progress_node = c_obj_prog_node.start(c_source_basename, 0);5679 const child_progress_node = c_obj_prog_node.start(c_source_basename, 0);
5680 defer child_progress_node.end();5680 defer child_progress_node.end();
...@@ -5687,7 +5687,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr...@@ -5687,7 +5687,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr
5687 const o_basename_noext = if (direct_o)5687 const o_basename_noext = if (direct_o)
5688 comp.root_name5688 comp.root_name
5689 else5689 else
5690 c_source_basename[0 .. c_source_basename.len - std.fs.path.extension(c_source_basename).len];5690 c_source_basename[0 .. c_source_basename.len - fs.path.extension(c_source_basename).len];
56915691
5692 const target = comp.getTarget();5692 const target = comp.getTarget();
5693 const o_ext = target.ofmt.fileExt(target.cpu.arch);5693 const o_ext = target.ofmt.fileExt(target.cpu.arch);
...@@ -5814,11 +5814,11 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr...@@ -5814,11 +5814,11 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr
5814 }5814 }
58155815
5816 // Just to save disk space, we delete the files that are never needed again.5816 // Just to save disk space, we delete the files that are never needed again.
5817 defer if (out_diag_path) |diag_file_path| zig_cache_tmp_dir.deleteFile(std.fs.path.basename(diag_file_path)) catch |err| switch (err) {5817 defer if (out_diag_path) |diag_file_path| zig_cache_tmp_dir.deleteFile(fs.path.basename(diag_file_path)) catch |err| switch (err) {
5818 error.FileNotFound => {}, // the file wasn't created due to an error we reported5818 error.FileNotFound => {}, // the file wasn't created due to an error we reported
5819 else => log.warn("failed to delete '{s}': {s}", .{ diag_file_path, @errorName(err) }),5819 else => log.warn("failed to delete '{s}': {s}", .{ diag_file_path, @errorName(err) }),
5820 };5820 };
5821 defer if (out_dep_path) |dep_file_path| zig_cache_tmp_dir.deleteFile(std.fs.path.basename(dep_file_path)) catch |err| switch (err) {5821 defer if (out_dep_path) |dep_file_path| zig_cache_tmp_dir.deleteFile(fs.path.basename(dep_file_path)) catch |err| switch (err) {
5822 error.FileNotFound => {}, // the file wasn't created due to an error we reported5822 error.FileNotFound => {}, // the file wasn't created due to an error we reported
5823 else => log.warn("failed to delete '{s}': {s}", .{ dep_file_path, @errorName(err) }),5823 else => log.warn("failed to delete '{s}': {s}", .{ dep_file_path, @errorName(err) }),
5824 };5824 };
...@@ -5889,7 +5889,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr...@@ -5889,7 +5889,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr
5889 }5889 }
58905890
5891 if (out_dep_path) |dep_file_path| {5891 if (out_dep_path) |dep_file_path| {
5892 const dep_basename = std.fs.path.basename(dep_file_path);5892 const dep_basename = fs.path.basename(dep_file_path);
5893 // Add the files depended on to the cache system.5893 // Add the files depended on to the cache system.
5894 try man.addDepFilePost(zig_cache_tmp_dir, dep_basename);5894 try man.addDepFilePost(zig_cache_tmp_dir, dep_basename);
5895 switch (comp.cache_use) {5895 switch (comp.cache_use) {
...@@ -5909,11 +5909,11 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr...@@ -5909,11 +5909,11 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr
59095909
5910 // Rename into place.5910 // Rename into place.
5911 const digest = man.final();5911 const digest = man.final();
5912 const o_sub_path = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest });5912 const o_sub_path = try fs.path.join(arena, &[_][]const u8{ "o", &digest });
5913 var o_dir = try comp.dirs.local_cache.handle.makeOpenPath(o_sub_path, .{});5913 var o_dir = try comp.dirs.local_cache.handle.makeOpenPath(o_sub_path, .{});
5914 defer o_dir.close();5914 defer o_dir.close();
5915 const tmp_basename = std.fs.path.basename(out_obj_path);5915 const tmp_basename = fs.path.basename(out_obj_path);
5916 try std.fs.rename(zig_cache_tmp_dir, tmp_basename, o_dir, o_basename);5916 try fs.rename(zig_cache_tmp_dir, tmp_basename, o_dir, o_basename);
5917 break :blk digest;5917 break :blk digest;
5918 };5918 };
59195919
...@@ -5935,7 +5935,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr...@@ -5935,7 +5935,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr
5935 .success = .{5935 .success = .{
5936 .object_path = .{5936 .object_path = .{
5937 .root_dir = comp.dirs.local_cache,5937 .root_dir = comp.dirs.local_cache,
5938 .sub_path = try std.fs.path.join(gpa, &.{ "o", &digest, o_basename }),5938 .sub_path = try fs.path.join(gpa, &.{ "o", &digest, o_basename }),
5939 },5939 },
5940 .lock = man.toOwnedLock(),5940 .lock = man.toOwnedLock(),
5941 },5941 },
...@@ -5959,7 +5959,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -5959,7 +5959,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
5959 .rc => |rc_src| rc_src.src_path,5959 .rc => |rc_src| rc_src.src_path,
5960 .manifest => |src_path| src_path,5960 .manifest => |src_path| src_path,
5961 };5961 };
5962 const src_basename = std.fs.path.basename(src_path);5962 const src_basename = fs.path.basename(src_path);
59635963
5964 log.debug("updating win32 resource: {s}", .{src_path});5964 log.debug("updating win32 resource: {s}", .{src_path});
59655965
...@@ -5996,7 +5996,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -5996,7 +5996,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
5996 // get the digest now and write the .res directly to the cache5996 // get the digest now and write the .res directly to the cache
5997 const digest = man.final();5997 const digest = man.final();
59985998
5999 const o_sub_path = try std.fs.path.join(arena, &.{ "o", &digest });5999 const o_sub_path = try fs.path.join(arena, &.{ "o", &digest });
6000 var o_dir = try comp.dirs.local_cache.handle.makeOpenPath(o_sub_path, .{});6000 var o_dir = try comp.dirs.local_cache.handle.makeOpenPath(o_sub_path, .{});
6001 defer o_dir.close();6001 defer o_dir.close();
60026002
...@@ -6082,7 +6082,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -6082,7 +6082,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
6082 _ = try man.addFile(rc_src.src_path, null);6082 _ = try man.addFile(rc_src.src_path, null);
6083 man.hash.addListOfBytes(rc_src.extra_flags);6083 man.hash.addListOfBytes(rc_src.extra_flags);
60846084
6085 const rc_basename_noext = src_basename[0 .. src_basename.len - std.fs.path.extension(src_basename).len];6085 const rc_basename_noext = src_basename[0 .. src_basename.len - fs.path.extension(src_basename).len];
60866086
6087 const digest = if (try man.hit()) man.final() else blk: {6087 const digest = if (try man.hit()) man.final() else blk: {
6088 var zig_cache_tmp_dir = try comp.dirs.local_cache.handle.makeOpenPath("tmp", .{});6088 var zig_cache_tmp_dir = try comp.dirs.local_cache.handle.makeOpenPath("tmp", .{});
...@@ -6127,7 +6127,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -6127,7 +6127,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
61276127
6128 // Read depfile and update cache manifest6128 // Read depfile and update cache manifest
6129 {6129 {
6130 const dep_basename = std.fs.path.basename(out_dep_path);6130 const dep_basename = fs.path.basename(out_dep_path);
6131 const dep_file_contents = try zig_cache_tmp_dir.readFileAlloc(arena, dep_basename, 50 * 1024 * 1024);6131 const dep_file_contents = try zig_cache_tmp_dir.readFileAlloc(arena, dep_basename, 50 * 1024 * 1024);
6132 defer arena.free(dep_file_contents);6132 defer arena.free(dep_file_contents);
61336133
...@@ -6155,11 +6155,11 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -6155,11 +6155,11 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
61556155
6156 // Rename into place.6156 // Rename into place.
6157 const digest = man.final();6157 const digest = man.final();
6158 const o_sub_path = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest });6158 const o_sub_path = try fs.path.join(arena, &[_][]const u8{ "o", &digest });
6159 var o_dir = try comp.dirs.local_cache.handle.makeOpenPath(o_sub_path, .{});6159 var o_dir = try comp.dirs.local_cache.handle.makeOpenPath(o_sub_path, .{});
6160 defer o_dir.close();6160 defer o_dir.close();
6161 const tmp_basename = std.fs.path.basename(out_res_path);6161 const tmp_basename = fs.path.basename(out_res_path);
6162 try std.fs.rename(zig_cache_tmp_dir, tmp_basename, o_dir, res_filename);6162 try fs.rename(zig_cache_tmp_dir, tmp_basename, o_dir, res_filename);
6163 break :blk digest;6163 break :blk digest;
6164 };6164 };
61656165
...@@ -6270,7 +6270,7 @@ fn spawnZigRc(...@@ -6270,7 +6270,7 @@ fn spawnZigRc(
6270}6270}
62716271
6272pub fn tmpFilePath(comp: Compilation, ally: Allocator, suffix: []const u8) error{OutOfMemory}![]const u8 {6272pub fn tmpFilePath(comp: Compilation, ally: Allocator, suffix: []const u8) error{OutOfMemory}![]const u8 {
6273 const s = std.fs.path.sep_str;6273 const s = fs.path.sep_str;
6274 const rand_int = std.crypto.random.int(u64);6274 const rand_int = std.crypto.random.int(u64);
6275 if (comp.dirs.local_cache.path) |p| {6275 if (comp.dirs.local_cache.path) |p| {
6276 return std.fmt.allocPrint(ally, "{s}" ++ s ++ "tmp" ++ s ++ "{x}-{s}", .{ p, rand_int, suffix });6276 return std.fmt.allocPrint(ally, "{s}" ++ s ++ "tmp" ++ s ++ "{x}-{s}", .{ p, rand_int, suffix });
...@@ -6520,12 +6520,12 @@ pub fn addCCArgs(...@@ -6520,12 +6520,12 @@ pub fn addCCArgs(
65206520
6521 if (comp.config.link_libcpp) {6521 if (comp.config.link_libcpp) {
6522 try argv.append("-isystem");6522 try argv.append("-isystem");
6523 try argv.append(try std.fs.path.join(arena, &[_][]const u8{6523 try argv.append(try fs.path.join(arena, &[_][]const u8{
6524 comp.dirs.zig_lib.path.?, "libcxx", "include",6524 comp.dirs.zig_lib.path.?, "libcxx", "include",
6525 }));6525 }));
65266526
6527 try argv.append("-isystem");6527 try argv.append("-isystem");
6528 try argv.append(try std.fs.path.join(arena, &[_][]const u8{6528 try argv.append(try fs.path.join(arena, &[_][]const u8{
6529 comp.dirs.zig_lib.path.?, "libcxxabi", "include",6529 comp.dirs.zig_lib.path.?, "libcxxabi", "include",
6530 }));6530 }));
65316531
...@@ -6536,7 +6536,7 @@ pub fn addCCArgs(...@@ -6536,7 +6536,7 @@ pub fn addCCArgs(
6536 // However as noted by @dimenus, appending libc headers before compiler headers breaks6536 // However as noted by @dimenus, appending libc headers before compiler headers breaks
6537 // intrinsics and other compiler specific items.6537 // intrinsics and other compiler specific items.
6538 try argv.append("-isystem");6538 try argv.append("-isystem");
6539 try argv.append(try std.fs.path.join(arena, &.{ comp.dirs.zig_lib.path.?, "include" }));6539 try argv.append(try fs.path.join(arena, &.{ comp.dirs.zig_lib.path.?, "include" }));
65406540
6541 try argv.ensureUnusedCapacity(comp.libc_include_dir_list.len * 2);6541 try argv.ensureUnusedCapacity(comp.libc_include_dir_list.len * 2);
6542 for (comp.libc_include_dir_list) |include_dir| {6542 for (comp.libc_include_dir_list) |include_dir| {
...@@ -6554,7 +6554,7 @@ pub fn addCCArgs(...@@ -6554,7 +6554,7 @@ pub fn addCCArgs(
65546554
6555 if (comp.config.link_libunwind) {6555 if (comp.config.link_libunwind) {
6556 try argv.append("-isystem");6556 try argv.append("-isystem");
6557 try argv.append(try std.fs.path.join(arena, &[_][]const u8{6557 try argv.append(try fs.path.join(arena, &[_][]const u8{
6558 comp.dirs.zig_lib.path.?, "libunwind", "include",6558 comp.dirs.zig_lib.path.?, "libunwind", "include",
6559 }));6559 }));
6560 }6560 }
...@@ -7147,7 +7147,7 @@ fn get_libc_crt_file(comp: *Compilation, arena: Allocator, basename: []const u8)...@@ -7147,7 +7147,7 @@ fn get_libc_crt_file(comp: *Compilation, arena: Allocator, basename: []const u8)
7147 return (try crtFilePath(&comp.crt_files, basename)) orelse {7147 return (try crtFilePath(&comp.crt_files, basename)) orelse {
7148 const lci = comp.libc_installation orelse return error.LibCInstallationNotAvailable;7148 const lci = comp.libc_installation orelse return error.LibCInstallationNotAvailable;
7149 const crt_dir_path = lci.crt_dir orelse return error.LibCInstallationMissingCrtDir;7149 const crt_dir_path = lci.crt_dir orelse return error.LibCInstallationMissingCrtDir;
7150 const full_path = try std.fs.path.join(arena, &[_][]const u8{ crt_dir_path, basename });7150 const full_path = try fs.path.join(arena, &[_][]const u8{ crt_dir_path, basename });
7151 return Cache.Path.initCwd(full_path);7151 return Cache.Path.initCwd(full_path);
7152 };7152 };
7153}7153}
...@@ -7211,7 +7211,7 @@ pub fn lockAndSetMiscFailure(...@@ -7211,7 +7211,7 @@ pub fn lockAndSetMiscFailure(
7211pub fn dump_argv(argv: []const []const u8) void {7211pub fn dump_argv(argv: []const []const u8) void {
7212 std.debug.lockStdErr();7212 std.debug.lockStdErr();
7213 defer std.debug.unlockStdErr();7213 defer std.debug.unlockStdErr();
7214 const stderr = std.fs.File.stderr().deprecatedWriter();7214 const stderr = fs.File.stderr().deprecatedWriter();
7215 for (argv[0 .. argv.len - 1]) |arg| {7215 for (argv[0 .. argv.len - 1]) |arg| {
7216 nosuspend stderr.print("{s} ", .{arg}) catch return;7216 nosuspend stderr.print("{s} ", .{arg}) catch return;
7217 }7217 }
...@@ -7542,7 +7542,7 @@ pub fn toCrtFile(comp: *Compilation) Allocator.Error!CrtFile {...@@ -7542,7 +7542,7 @@ pub fn toCrtFile(comp: *Compilation) Allocator.Error!CrtFile {
7542 return .{7542 return .{
7543 .full_object_path = .{7543 .full_object_path = .{
7544 .root_dir = comp.dirs.local_cache,7544 .root_dir = comp.dirs.local_cache,
7545 .sub_path = try std.fs.path.join(comp.gpa, &.{7545 .sub_path = try fs.path.join(comp.gpa, &.{
7546 "o",7546 "o",
7547 &Cache.binToHex(comp.digest.?),7547 &Cache.binToHex(comp.digest.?),
7548 comp.emit_bin.?,7548 comp.emit_bin.?,