From 83d41cf04dcec3d66a84b6c2a727621c076e971e Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 14 Aug 2026 21:12:32 -0700 Subject: [PATCH] add build_root to cache prefix directories --- lib/compiler/Maker.zig | 2 + lib/compiler/Maker/Step.zig | 7 +++ lib/compiler/Maker/Step/Compile.zig | 3 +- lib/std/Build/Cache.zig | 8 +-- lib/std/zig.zig | 47 ++++++++++----- lib/std/zig/Server.zig | 1 + src/Compilation.zig | 33 +++++++---- src/Zcu/PerThread.zig | 2 +- src/codegen/llvm.zig | 1 + src/main.zig | 92 ++++++++++++++--------------- 10 files changed, 117 insertions(+), 79 deletions(-) diff --git a/lib/compiler/Maker.zig b/lib/compiler/Maker.zig index 92db208cbc7e299ee0282a504ca1dd372f83a604..0a0b68aabbe65d31f6f24518c63aa40e9bf387ee 100644 --- a/lib/compiler/Maker.zig +++ b/lib/compiler/Maker.zig @@ -614,6 +614,8 @@ pub fn main(init: process.Init.Minimal) !void { comptime assert(1 == @backingInt(std.zig.Server.Message.PathPrefix.zig_lib)); comptime assert(2 == @backingInt(std.zig.Server.Message.PathPrefix.local_cache)); comptime assert(3 == @backingInt(std.zig.Server.Message.PathPrefix.global_cache)); + comptime assert(4 == @backingInt(std.zig.Server.Message.PathPrefix.build_root)); + comptime assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".field_names.len == 5); graph.cache.hash.addBytes(builtin.zig_version_string); diff --git a/lib/compiler/Maker/Step.zig b/lib/compiler/Maker/Step.zig index 2ce90b5a9b7725d452258af167de82b60b973a6b..0fd82226cce06989c0acea46f4f22e4dcd6d6e58 100644 --- a/lib/compiler/Maker/Step.zig +++ b/lib/compiler/Maker/Step.zig @@ -656,6 +656,13 @@ fn zigProcessUpdate(step_index: Configuration.Step.Index, maker: *Maker, zp: *Zi }; try addWatchInputFromPath(s, maker, path, Dir.path.basename(sub_path)); }, + .build_root => { + const path: Path = .{ + .root_dir = graph.build_root_directory, + .sub_path = sub_path_dirname, + }; + try addWatchInputFromPath(s, maker, path, Dir.path.basename(sub_path)); + }, } } }, diff --git a/lib/compiler/Maker/Step/Compile.zig b/lib/compiler/Maker/Step/Compile.zig index 1e60ad77a30a78bf0f903527430ac76b7af4fdd4..bca0df4de84cc95c42b2067d3ec1f5d65176488b 100644 --- a/lib/compiler/Maker/Step/Compile.zig +++ b/lib/compiler/Maker/Step/Compile.zig @@ -658,9 +658,10 @@ fn lowerZigArgs( zig_args.appendAssumeCapacity(libc_file); } - (try zig_args.addManyAsArray(gpa, 4)).* = .{ + (try zig_args.addManyAsArray(gpa, 6)).* = .{ "--cache-dir", graph.local_cache_root.path orelse ".", "--global-cache-dir", graph.global_cache_root.path orelse ".", + "--build-root", graph.build_root_directory.path orelse ".", }; try zig_args.ensureUnusedCapacity(gpa, 1); diff --git a/lib/std/Build/Cache.zig b/lib/std/Build/Cache.zig index 64331f583515b109e2e5cd5fe00b31c43c974e09..2391e698c4158197c63db208cceb0618b342a208 100644 --- a/lib/std/Build/Cache.zig +++ b/lib/std/Build/Cache.zig @@ -418,7 +418,6 @@ pub const Manifest = struct { } fn addFileInner(self: *Manifest, prefixed_path: PrefixedPath, handle: ?Io.File, max_file_size: ?usize) usize { - assert(!std.fs.path.isAbsolute(prefixed_path.sub_path)); const gop = self.files.getOrPutAssumeCapacityAdapted(prefixed_path, FilesAdapter{}); if (gop.found_existing) { self.cache.gpa.free(prefixed_path.sub_path); @@ -951,7 +950,6 @@ pub const Manifest = struct { /// will need to be recompiled if the imported file is changed. pub fn addFilePostFetch(self: *Manifest, file_path: []const u8, max_file_size: usize) ![]const u8 { assert(self.manifest_file != null); - assert(!std.fs.path.isAbsolute(file_path)); const gpa = self.cache.gpa; const prefixed_path = try self.cache.findPrefix(file_path); @@ -1009,7 +1007,6 @@ pub const Manifest = struct { /// whether or not `prefixed_path.sub_path` should be kept. pub fn addPrefixedPathPost(man: *Manifest, prefixed_path: PrefixedPath) !bool { assert(man.manifest_file != null); - assert(!std.fs.path.isAbsolute(prefixed_path.sub_path)); const gpa = man.cache.gpa; const gop = try man.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{}); @@ -1041,7 +1038,6 @@ pub const Manifest = struct { stat: File.Stat, ) !void { assert(self.manifest_file != null); - assert(!std.fs.path.isAbsolute(file_path)); const gpa = self.cache.gpa; const prefixed_path = try self.cache.findPrefix(file_path); @@ -1268,10 +1264,10 @@ pub const Manifest = struct { } } - pub fn populateOtherManifest(man: *Manifest, other: *Manifest, prefix_map: [4]u8) Allocator.Error!void { + pub fn populateOtherManifest(man: *Manifest, other: *Manifest, prefix_map: [5]u8) Allocator.Error!void { const gpa = other.cache.gpa; assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".field_names.len == man.cache.prefixes_len); - assert(man.cache.prefixes_len == 4); + assert(man.cache.prefixes_len == 5); for (man.files.keys()) |file| { const prefixed_path: PrefixedPath = .{ .prefix = prefix_map[file.prefixed_path.prefix], diff --git a/lib/std/zig.zig b/lib/std/zig.zig index ec6fc7d630a92133751c8ae481ff193d3fc0dfff..4853d43f93a2814160ba278fa04fa6ef2d011102 100644 --- a/lib/std/zig.zig +++ b/lib/std/zig.zig @@ -1283,6 +1283,10 @@ pub const Directories = struct { /// `local_cache.path` is resolved (`resolvePath`) or `null` for cwd. /// This may be the same as `global_cache`. local_cache: Cache.Directory, + /// The directory that contains build.zig. This path is provided by the + /// build system, when the build system is used, otherwise, it is `null` + /// for cwd. + build_root: Cache.Directory, pub fn deinit(dirs: *Directories, io: Io) void { // The local and global caches could be the same. @@ -1291,6 +1295,7 @@ pub const Directories = struct { dirs.global_cache.handle.close(io); if (close_local) dirs.local_cache.handle.close(io); dirs.zig_lib.handle.close(io); + if (dirs.build_root.path != null) dirs.build_root.handle.close(io); } /// Returns a `Directories` where `local_cache` is replaced with `global_cache`, intended for @@ -1302,6 +1307,7 @@ pub const Directories = struct { .zig_lib = dirs.zig_lib, .global_cache = dirs.global_cache, .local_cache = dirs.global_cache, + .build_root = dirs.build_root, }; } @@ -1311,12 +1317,10 @@ pub const Directories = struct { global, }; - /// Uses `std.process.fatal` on error conditions. - pub fn init( - arena: Allocator, - io: Io, + pub const InitOptions = struct { override_zig_lib: ?[]const u8, override_global_cache: ?[]const u8, + build_root: ?[]const u8, local_cache_strat: LocalCacheStrategy, preopens: std.process.Preopens, self_exe_path: switch (builtin.target.os.tag) { @@ -1325,27 +1329,38 @@ pub const Directories = struct { }, environ_map: *const std.process.Environ.Map, cwd: []const u8, - ) Directories { + }; + + /// Uses `std.process.fatal` on error conditions. + pub fn init(arena: Allocator, io: Io, options: InitOptions) Directories { const wasi = builtin.target.os.tag == .wasi; + const cwd = options.cwd; const zig_lib: Cache.Directory = d: { - if (override_zig_lib) |path| break :d openUnresolved(arena, io, cwd, path, .@"zig lib"); - if (wasi) break :d getPreopen(preopens, "/lib"); - break :d findZigLibDirFromSelfExe(arena, io, cwd, self_exe_path) catch |err| { - fatal("unable to find zig installation directory from executable path {q}: {t}", .{ self_exe_path, err }); + if (options.override_zig_lib) |path| break :d openUnresolved(arena, io, cwd, path, .@"zig lib"); + if (wasi) break :d getPreopen(options.preopens, "/lib"); + break :d findZigLibDirFromSelfExe(arena, io, cwd, options.self_exe_path) catch |err| { + fatal("unable to find zig installation directory from executable path {q}: {t}", .{ + options.self_exe_path, err, + }); }; }; + const build_root: Cache.Directory = if (options.build_root) |s| + // TODO this ends up setting path to null, leaking the fd in deinit + openUnresolved(arena, io, cwd, s, .@"build root") + else + .cwd(); const global_cache: Cache.Directory = d: { - if (override_global_cache) |path| break :d openUnresolved(arena, io, cwd, path, .@"global cache"); - if (wasi) break :d getPreopen(preopens, "/cache"); - const path = resolveGlobalCacheDir(arena, environ_map) catch |err| { + if (options.override_global_cache) |path| break :d openUnresolved(arena, io, cwd, path, .@"global cache"); + if (wasi) break :d getPreopen(options.preopens, "/cache"); + const path = resolveGlobalCacheDir(arena, options.environ_map) catch |err| { fatal("unable to resolve zig cache directory: {t}", .{err}); }; break :d openUnresolved(arena, io, cwd, path, .@"global cache"); }; - const local_cache = getLocalCacheDirectory(arena, io, cwd, global_cache, local_cache_strat); + const local_cache = getLocalCacheDirectory(arena, io, cwd, global_cache, options.local_cache_strat); if (mem.eql(u8, zig_lib.path orelse "", global_cache.path orelse "")) { fatal("zig lib directory '{f}' cannot be equal to global cache directory '{f}'", .{ zig_lib, global_cache }); @@ -1359,6 +1374,7 @@ pub const Directories = struct { .zig_lib = zig_lib, .global_cache = global_cache, .local_cache = local_cache, + .build_root = build_root, }; } @@ -1395,14 +1411,14 @@ pub const Directories = struct { io: Io, cwd: []const u8, unresolved_path: []const u8, - thing: enum { @"zig lib", @"global cache", @"local cache" }, + thing: enum { @"zig lib", @"global cache", @"local cache", @"build root" }, ) Cache.Directory { const path = resolvePath(arena, cwd, &.{unresolved_path}) catch |err| { fatal("unable to resolve {t} directory: {t}", .{ thing, err }); }; const nonempty_path = if (path.len == 0) "." else path; const handle_or_err = switch (thing) { - .@"zig lib" => Dir.cwd().openDir(io, nonempty_path, .{}), + .@"zig lib", .@"build root" => Dir.cwd().openDir(io, nonempty_path, .{}), .@"global cache", .@"local cache" => Dir.cwd().createDirPathOpen(io, nonempty_path, .{}), }; return .{ @@ -1747,6 +1763,7 @@ pub fn buildExeSubprocess( const sub_path = try gpa.dupe(u8, prefixed_path[1..]); var keep = false; defer if (!keep) gpa.free(sub_path); + log.debug("file system input: {t} {s}", .{ prefix, sub_path }); keep = man.addPrefixedPathPost(.{ .prefix = @backingInt(prefix), .sub_path = sub_path, diff --git a/lib/std/zig/Server.zig b/lib/std/zig/Server.zig index 1f6d208084abdcc9d93ef33929e36aa0239549af..eac3555acf7074a174f333401e0f79c70c23ab7e 100644 --- a/lib/std/zig/Server.zig +++ b/lib/std/zig/Server.zig @@ -135,6 +135,7 @@ pub const Message = struct { zig_lib, local_cache, global_cache, + build_root, }; /// Trailing: diff --git a/src/Compilation.zig b/src/Compilation.zig index b8ae83d05a5173b58ff700f04bae6a883725dc34..92d77b97f882816fae92bf88c8db3d18b1e37ec5 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -397,6 +397,7 @@ pub const Path = struct { global_cache, /// `sub_path` is relative to the local cache directory on `Compilation`. local_cache, + build_root, /// `sub_path` is not relative to any of the roots listed above. /// It is resolved starting with `Directories.cwd`; so it is an absolute path on most /// targets, but cwd-relative on WASI. We do not make it cwd-relative on other targets @@ -439,6 +440,7 @@ pub const Path = struct { .zig_lib => dirs.zig_lib.handle, .global_cache => dirs.global_cache.handle, .local_cache => dirs.local_cache.handle, + .build_root => dirs.build_root.handle, }; if (p.sub_path.len == 0) return .{ dir, "." }; assert(!fs.path.isAbsolute(p.sub_path)); @@ -457,6 +459,7 @@ pub const Path = struct { .zig_lib => f.comp.dirs.zig_lib.path orelse ".", .global_cache => f.comp.dirs.global_cache.path orelse ".", .local_cache => f.comp.dirs.local_cache.path orelse ".", + .build_root => f.comp.dirs.build_root.path orelse ".", .none => { const cwd_sub_path = absToCwdRelative(f.p.sub_path, f.comp.dirs.cwd); try w.writeAll(cwd_sub_path); @@ -581,6 +584,7 @@ pub const Path = struct { .zig_lib => dirs.zig_lib.path orelse "", .global_cache => dirs.global_cache.path orelse "", .local_cache => dirs.local_cache.path orelse "", + .build_root => dirs.build_root.path orelse "", .none => "", }, sub_path, @@ -603,6 +607,7 @@ pub const Path = struct { .zig_lib => dirs.zig_lib.path orelse "", .global_cache => dirs.global_cache.path orelse "", .local_cache => dirs.local_cache.path orelse "", + .build_root => dirs.build_root.path orelse "", .none => "", }, p.sub_path, @@ -622,6 +627,7 @@ pub const Path = struct { .zig_lib => dirs.zig_lib.path orelse "", .global_cache => dirs.global_cache.path orelse "", .local_cache => dirs.local_cache.path orelse "", + .build_root => dirs.build_root.path orelse "", .none => "", }, p.sub_path, @@ -635,6 +641,7 @@ pub const Path = struct { .zig_lib => dirs.zig_lib, .global_cache => dirs.global_cache, .local_cache => dirs.local_cache, + .build_root => dirs.build_root, else => { const cwd_sub_path = absToCwdRelative(p.sub_path, dirs.cwd); return .{ @@ -658,13 +665,10 @@ pub const Path = struct { .zig_lib => dirs.zig_lib.path orelse "", .global_cache => dirs.global_cache.path orelse "", .local_cache => dirs.local_cache.path orelse "", + .build_root => dirs.build_root.path orelse "", .none => "", }; - return fs.path.resolve(gpa, &.{ - dirs.cwd, - root_path, - p.sub_path, - }); + return fs.path.resolve(gpa, &.{ dirs.cwd, root_path, p.sub_path }); } pub fn isNested(inner: Path, outer: Path) union(enum) { @@ -1348,7 +1352,7 @@ pub const CacheMode = enum { pub const ParentWholeCache = struct { manifest: *Cache.Manifest, mutex: *std.Io.Mutex, - prefix_map: [4]u8, + prefix_map: [5]u8, }; const CacheUse = union(CacheMode) { @@ -1926,6 +1930,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, } const error_limit = options.error_limit orelse (std.math.maxInt(u16) - 1); + const main_mod = options.main_mod orelse options.root_mod; // We put everything into the cache hash that *cannot be modified // during an incremental update*. For example, one cannot change the @@ -1944,11 +1949,18 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, }, .cwd = options.dirs.cwd, }; - // These correspond to std.zig.Server.Message.PathPrefix. + comptime assert(0 == @backingInt(std.zig.Server.Message.PathPrefix.cwd)); + comptime assert(1 == @backingInt(std.zig.Server.Message.PathPrefix.zig_lib)); + comptime assert(2 == @backingInt(std.zig.Server.Message.PathPrefix.local_cache)); + comptime assert(3 == @backingInt(std.zig.Server.Message.PathPrefix.global_cache)); + comptime assert(4 == @backingInt(std.zig.Server.Message.PathPrefix.build_root)); + comptime assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".field_names.len == 5); cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() }); cache.addPrefix(options.dirs.zig_lib); cache.addPrefix(options.dirs.local_cache); cache.addPrefix(options.dirs.global_cache); + log.debug("addPrefix build_root {s}", .{options.dirs.build_root.path orelse "(null)"}); + cache.addPrefix(options.dirs.build_root); errdefer cache.manifest_dir.close(io); // This is shared hasher state common to zig source and all C source files. @@ -1984,7 +1996,6 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, cache.hash.add(options.emit_docs != .no); // TODO audit this and make sure everything is in it - const main_mod = options.main_mod orelse options.root_mod; const comp = try arena.create(Compilation); const opt_zcu: ?*Zcu = if (have_zcu) blk: { // Pre-open the directory handles for cached ZIR code so that it does not need @@ -3116,6 +3127,7 @@ pub fn appendFileSystemInput(comp: *Compilation, path: Compilation.Path) Allocat .zig_lib => comp.dirs.zig_lib, .global_cache => comp.dirs.global_cache, .local_cache => comp.dirs.local_cache, + .build_root => comp.dirs.build_root, .none => .cwd(), }; const prefix: u8 = for (prefixes, 1..) |prefix_dir, i| { @@ -3123,8 +3135,8 @@ pub fn appendFileSystemInput(comp: *Compilation, path: Compilation.Path) Allocat break @intCast(i); } } else std.debug.panic( - "missing prefix directory '{s}' ('{f}') for '{s}'", - .{ @tagName(path.root), want_prefix_dir, path.sub_path }, + "missing prefix directory {t} ('{f}') for {q}", + .{ path.root, want_prefix_dir, path.sub_path }, ); // There may be concurrent calls to this function from C object workers and/or the main thread. @@ -7323,6 +7335,7 @@ fn buildOutputFromZig( 1, // zig lib dir is the same 3, // local cache is mapped to global cache 3, // global cache is the same + 0, // build root is not provided }, }, .incremental, .none => null, diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig index 56de07bed5a44a25590f77de9ed10b2ae420d8b0..8b355ee22a5895eb65ef581aa536689078379315 100644 --- a/src/Zcu/PerThread.zig +++ b/src/Zcu/PerThread.zig @@ -481,7 +481,7 @@ pub fn updateFile( const stat = try source_file.stat(io); const want_local_cache = switch (file.path.root) { - .none, .local_cache => true, + .none, .local_cache, .build_root => true, .global_cache, .zig_lib => false, }; diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 8bb33f83e0d0911b2f427ede147964df5c73cf9a..9e6c29c94c5cfdab42e3822d5a62e5e279d510c8 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1701,6 +1701,7 @@ pub const Object = struct { .zig_lib => dirs.zig_lib.path, .global_cache => dirs.global_cache.path, .local_cache => dirs.local_cache.path, + .build_root => dirs.build_root.path, .none => null, }; diff --git a/src/main.zig b/src/main.zig index d2068b8cdbb6a53f63dd28ac667503f7495e777e..eb5ae7d15354880032f098a121e8099578ea32c3 100644 --- a/src/main.zig +++ b/src/main.zig @@ -423,17 +423,16 @@ fn mainArgs( .wasi => {}, else => process.executablePathAlloc(io, arena) catch |err| fatal("unable to find zig self exe path: {t}", .{err}), }; - var dirs: std.zig.Directories = .init( - arena, - io, - EnvVar.ZIG_LIB_DIR.get(environ_map), - EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map), - .global, - preopens, - self_exe_path, - environ_map, - try std.zig.getResolvedCwd(io, arena), - ); + var dirs: std.zig.Directories = .init(arena, io, .{ + .override_zig_lib = EnvVar.ZIG_LIB_DIR.get(environ_map), + .override_global_cache = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map), + .build_root = null, + .local_cache_strat = .global, + .preopens = preopens, + .self_exe_path = self_exe_path, + .environ_map = environ_map, + .cwd = try std.zig.getResolvedCwd(io, arena), + }); defer dirs.deinit(io); const host = std.zig.resolveTargetQueryOrFatal(io, .{}); var stdout_writer = Io.File.stdout().writer(io, &stdout_buffer); @@ -458,17 +457,16 @@ fn mainArgs( .wasi => args[0], else => process.executablePathAlloc(io, arena) catch |err| fatal("unable to find zig self exe path: {t}", .{err}), }; - var dirs: std.zig.Directories = .init( - arena, - io, - EnvVar.ZIG_LIB_DIR.get(environ_map), - EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map), - .global, - preopens, - if (native_os != .wasi) self_exe_path, - environ_map, - try std.zig.getResolvedCwd(io, arena), - ); + var dirs: std.zig.Directories = .init(arena, io, .{ + .override_zig_lib = EnvVar.ZIG_LIB_DIR.get(environ_map), + .override_global_cache = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map), + .build_root = null, + .local_cache_strat = .global, + .preopens = preopens, + .self_exe_path = if (native_os != .wasi) self_exe_path, + .environ_map = environ_map, + .cwd = try std.zig.getResolvedCwd(io, arena), + }); defer dirs.deinit(io); const host = std.zig.resolveTargetQueryOrFatal(io, .{}); var stdout_writer = Io.File.stdout().writer(io, &stdout_buffer); @@ -511,7 +509,7 @@ fn mainArgs( } } -const usage_build_generic = +const compile_usage = \\Usage: zig build-exe [options] [files] \\ zig build-lib [options] [files] \\ zig build-obj [options] [files] @@ -565,6 +563,7 @@ const usage_build_generic = \\ --cache-dir [path] Override the local cache directory \\ --global-cache-dir [path] Override the global cache directory \\ --zig-lib-dir [path] Override path to Zig installation lib directory + \\ --build-root [path] Override path to project source files \\ \\Global Compile Options: \\ --name [name] Compilation unit name (not a file path) @@ -1054,6 +1053,7 @@ fn buildOutputType( var rc_includes: std.zig.RcIncludes = .any; var manifest_file: ?[]const u8 = null; var linker_export_symbol_names: std.ArrayList([]const u8) = .empty; + var build_root_path: ?[]const u8 = null; // Tracks the position in c_source_files which have already their owner populated. var c_source_files_owner_index: usize = 0; @@ -1167,7 +1167,7 @@ fn buildOutputType( fatal("unable to read response file {q}: {t}", .{ resp_file_path, err }); } else if (mem.startsWith(u8, arg, "-")) { if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { - try Io.File.stdout().writeStreamingAll(io, usage_build_generic); + try Io.File.stdout().writeStreamingAll(io, compile_usage); return cleanExit(io); } else if (mem.eql(u8, arg, "--")) { if (arg_mode == .run) { @@ -1440,6 +1440,8 @@ fn buildOutputType( override_global_cache_dir = args_iter.nextOrFatal(); } else if (mem.eql(u8, arg, "--zig-lib-dir")) { override_lib_dir = args_iter.nextOrFatal(); + } else if (mem.eql(u8, arg, "--build-root")) { + build_root_path = args_iter.nextOrFatal(); } else if (mem.eql(u8, arg, "--debug-log")) { try addDebugLog(arena, args_iter.nextOrFatal()); } else if (mem.eql(u8, arg, "--listen")) { @@ -3254,23 +3256,22 @@ fn buildOutputType( const cwd_path = try std.zig.getResolvedCwd(io, arena); // This `init` calls `fatal` on error. - var dirs: std.zig.Directories = .init( - arena, - io, - override_lib_dir, - override_global_cache_dir, - s: { + var dirs: std.zig.Directories = .init(arena, io, .{ + .override_zig_lib = override_lib_dir, + .override_global_cache = override_global_cache_dir, + .build_root = build_root_path, + .local_cache_strat = s: { if (override_local_cache_dir) |p| break :s .{ .override = p }; break :s switch (arg_mode) { .run => .global, else => .search, }; }, - preopens, - self_exe_path, - environ_map, - cwd_path, - ); + .preopens = preopens, + .self_exe_path = self_exe_path, + .environ_map = environ_map, + .cwd = cwd_path, + }); defer dirs.deinit(io); if (linker_optimization) |o| warn("ignoring deprecated linker optimization setting {q}", .{o}); @@ -5020,17 +5021,16 @@ fn jitCmdInner( const cwd_path = try std.zig.getResolvedCwd(io, arena); // This `init` calls `fatal` on error. - var dirs: std.zig.Directories = .init( - arena, - io, - override_lib_dir, - override_global_cache_dir, - .global, - preopens, - self_exe_path, - environ_map, - cwd_path, - ); + var dirs: std.zig.Directories = .init(arena, io, .{ + .override_zig_lib = override_lib_dir, + .override_global_cache = override_global_cache_dir, + .build_root = null, + .local_cache_strat = .global, + .preopens = preopens, + .self_exe_path = self_exe_path, + .environ_map = environ_map, + .cwd = cwd_path, + }); defer dirs.deinit(io); var child_argv: std.ArrayList([]const u8) = .empty; -- 2.54.0