authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-14 21:12:32-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-19 12:39:36-07:00
log83d41cf04dcec3d66a84b6c2a727621c076e971e
treee160c6e76a6f7e23f67af7cd0357123b38ffae8b
parent0c4dcb12b93d88028c032d76241aac83b0958efd

add build_root to cache prefix directories


10 files changed, 117 insertions(+), 79 deletions(-)

lib/compiler/Maker.zig+2
......@@ -614,6 +614,8 @@ pub fn main(init: process.Init.Minimal) !void {
614614 comptime assert(1 == @backingInt(std.zig.Server.Message.PathPrefix.zig_lib));
615615 comptime assert(2 == @backingInt(std.zig.Server.Message.PathPrefix.local_cache));
616616 comptime assert(3 == @backingInt(std.zig.Server.Message.PathPrefix.global_cache));
617 comptime assert(4 == @backingInt(std.zig.Server.Message.PathPrefix.build_root));
618 comptime assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".field_names.len == 5);
617619
618620 graph.cache.hash.addBytes(builtin.zig_version_string);
619621
lib/compiler/Maker/Step.zig+7
......@@ -656,6 +656,13 @@ fn zigProcessUpdate(step_index: Configuration.Step.Index, maker: *Maker, zp: *Zi
656656 };
657657 try addWatchInputFromPath(s, maker, path, Dir.path.basename(sub_path));
658658 },
659 .build_root => {
660 const path: Path = .{
661 .root_dir = graph.build_root_directory,
662 .sub_path = sub_path_dirname,
663 };
664 try addWatchInputFromPath(s, maker, path, Dir.path.basename(sub_path));
665 },
659666 }
660667 }
661668 },
lib/compiler/Maker/Step/Compile.zig+2-1
......@@ -658,9 +658,10 @@ fn lowerZigArgs(
658658 zig_args.appendAssumeCapacity(libc_file);
659659 }
660660
661 (try zig_args.addManyAsArray(gpa, 4)).* = .{
661 (try zig_args.addManyAsArray(gpa, 6)).* = .{
662662 "--cache-dir", graph.local_cache_root.path orelse ".",
663663 "--global-cache-dir", graph.global_cache_root.path orelse ".",
664 "--build-root", graph.build_root_directory.path orelse ".",
664665 };
665666
666667 try zig_args.ensureUnusedCapacity(gpa, 1);
lib/std/Build/Cache.zig+2-6
......@@ -418,7 +418,6 @@ pub const Manifest = struct {
418418 }
419419
420420 fn addFileInner(self: *Manifest, prefixed_path: PrefixedPath, handle: ?Io.File, max_file_size: ?usize) usize {
421 assert(!std.fs.path.isAbsolute(prefixed_path.sub_path));
422421 const gop = self.files.getOrPutAssumeCapacityAdapted(prefixed_path, FilesAdapter{});
423422 if (gop.found_existing) {
424423 self.cache.gpa.free(prefixed_path.sub_path);
......@@ -951,7 +950,6 @@ pub const Manifest = struct {
951950 /// will need to be recompiled if the imported file is changed.
952951 pub fn addFilePostFetch(self: *Manifest, file_path: []const u8, max_file_size: usize) ![]const u8 {
953952 assert(self.manifest_file != null);
954 assert(!std.fs.path.isAbsolute(file_path));
955953
956954 const gpa = self.cache.gpa;
957955 const prefixed_path = try self.cache.findPrefix(file_path);
......@@ -1009,7 +1007,6 @@ pub const Manifest = struct {
10091007 /// whether or not `prefixed_path.sub_path` should be kept.
10101008 pub fn addPrefixedPathPost(man: *Manifest, prefixed_path: PrefixedPath) !bool {
10111009 assert(man.manifest_file != null);
1012 assert(!std.fs.path.isAbsolute(prefixed_path.sub_path));
10131010 const gpa = man.cache.gpa;
10141011
10151012 const gop = try man.files.getOrPutAdapted(gpa, prefixed_path, FilesAdapter{});
......@@ -1041,7 +1038,6 @@ pub const Manifest = struct {
10411038 stat: File.Stat,
10421039 ) !void {
10431040 assert(self.manifest_file != null);
1044 assert(!std.fs.path.isAbsolute(file_path));
10451041 const gpa = self.cache.gpa;
10461042
10471043 const prefixed_path = try self.cache.findPrefix(file_path);
......@@ -1268,10 +1264,10 @@ pub const Manifest = struct {
12681264 }
12691265 }
12701266
1271 pub fn populateOtherManifest(man: *Manifest, other: *Manifest, prefix_map: [4]u8) Allocator.Error!void {
1267 pub fn populateOtherManifest(man: *Manifest, other: *Manifest, prefix_map: [5]u8) Allocator.Error!void {
12721268 const gpa = other.cache.gpa;
12731269 assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".field_names.len == man.cache.prefixes_len);
1274 assert(man.cache.prefixes_len == 4);
1270 assert(man.cache.prefixes_len == 5);
12751271 for (man.files.keys()) |file| {
12761272 const prefixed_path: PrefixedPath = .{
12771273 .prefix = prefix_map[file.prefixed_path.prefix],
lib/std/zig.zig+32-15
......@@ -1283,6 +1283,10 @@ pub const Directories = struct {
12831283 /// `local_cache.path` is resolved (`resolvePath`) or `null` for cwd.
12841284 /// This may be the same as `global_cache`.
12851285 local_cache: Cache.Directory,
1286 /// The directory that contains build.zig. This path is provided by the
1287 /// build system, when the build system is used, otherwise, it is `null`
1288 /// for cwd.
1289 build_root: Cache.Directory,
12861290
12871291 pub fn deinit(dirs: *Directories, io: Io) void {
12881292 // The local and global caches could be the same.
......@@ -1291,6 +1295,7 @@ pub const Directories = struct {
12911295 dirs.global_cache.handle.close(io);
12921296 if (close_local) dirs.local_cache.handle.close(io);
12931297 dirs.zig_lib.handle.close(io);
1298 if (dirs.build_root.path != null) dirs.build_root.handle.close(io);
12941299 }
12951300
12961301 /// Returns a `Directories` where `local_cache` is replaced with `global_cache`, intended for
......@@ -1302,6 +1307,7 @@ pub const Directories = struct {
13021307 .zig_lib = dirs.zig_lib,
13031308 .global_cache = dirs.global_cache,
13041309 .local_cache = dirs.global_cache,
1310 .build_root = dirs.build_root,
13051311 };
13061312 }
13071313
......@@ -1311,12 +1317,10 @@ pub const Directories = struct {
13111317 global,
13121318 };
13131319
1314 /// Uses `std.process.fatal` on error conditions.
1315 pub fn init(
1316 arena: Allocator,
1317 io: Io,
1320 pub const InitOptions = struct {
13181321 override_zig_lib: ?[]const u8,
13191322 override_global_cache: ?[]const u8,
1323 build_root: ?[]const u8,
13201324 local_cache_strat: LocalCacheStrategy,
13211325 preopens: std.process.Preopens,
13221326 self_exe_path: switch (builtin.target.os.tag) {
......@@ -1325,27 +1329,38 @@ pub const Directories = struct {
13251329 },
13261330 environ_map: *const std.process.Environ.Map,
13271331 cwd: []const u8,
1328 ) Directories {
1332 };
1333
1334 /// Uses `std.process.fatal` on error conditions.
1335 pub fn init(arena: Allocator, io: Io, options: InitOptions) Directories {
13291336 const wasi = builtin.target.os.tag == .wasi;
1337 const cwd = options.cwd;
13301338
13311339 const zig_lib: Cache.Directory = d: {
1332 if (override_zig_lib) |path| break :d openUnresolved(arena, io, cwd, path, .@"zig lib");
1333 if (wasi) break :d getPreopen(preopens, "/lib");
1334 break :d findZigLibDirFromSelfExe(arena, io, cwd, self_exe_path) catch |err| {
1335 fatal("unable to find zig installation directory from executable path {q}: {t}", .{ self_exe_path, err });
1340 if (options.override_zig_lib) |path| break :d openUnresolved(arena, io, cwd, path, .@"zig lib");
1341 if (wasi) break :d getPreopen(options.preopens, "/lib");
1342 break :d findZigLibDirFromSelfExe(arena, io, cwd, options.self_exe_path) catch |err| {
1343 fatal("unable to find zig installation directory from executable path {q}: {t}", .{
1344 options.self_exe_path, err,
1345 });
13361346 };
13371347 };
1348 const build_root: Cache.Directory = if (options.build_root) |s|
1349 // TODO this ends up setting path to null, leaking the fd in deinit
1350 openUnresolved(arena, io, cwd, s, .@"build root")
1351 else
1352 .cwd();
13381353
13391354 const global_cache: Cache.Directory = d: {
1340 if (override_global_cache) |path| break :d openUnresolved(arena, io, cwd, path, .@"global cache");
1341 if (wasi) break :d getPreopen(preopens, "/cache");
1342 const path = resolveGlobalCacheDir(arena, environ_map) catch |err| {
1355 if (options.override_global_cache) |path| break :d openUnresolved(arena, io, cwd, path, .@"global cache");
1356 if (wasi) break :d getPreopen(options.preopens, "/cache");
1357 const path = resolveGlobalCacheDir(arena, options.environ_map) catch |err| {
13431358 fatal("unable to resolve zig cache directory: {t}", .{err});
13441359 };
13451360 break :d openUnresolved(arena, io, cwd, path, .@"global cache");
13461361 };
13471362
1348 const local_cache = getLocalCacheDirectory(arena, io, cwd, global_cache, local_cache_strat);
1363 const local_cache = getLocalCacheDirectory(arena, io, cwd, global_cache, options.local_cache_strat);
13491364
13501365 if (mem.eql(u8, zig_lib.path orelse "", global_cache.path orelse "")) {
13511366 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 {
13591374 .zig_lib = zig_lib,
13601375 .global_cache = global_cache,
13611376 .local_cache = local_cache,
1377 .build_root = build_root,
13621378 };
13631379 }
13641380
......@@ -1395,14 +1411,14 @@ pub const Directories = struct {
13951411 io: Io,
13961412 cwd: []const u8,
13971413 unresolved_path: []const u8,
1398 thing: enum { @"zig lib", @"global cache", @"local cache" },
1414 thing: enum { @"zig lib", @"global cache", @"local cache", @"build root" },
13991415 ) Cache.Directory {
14001416 const path = resolvePath(arena, cwd, &.{unresolved_path}) catch |err| {
14011417 fatal("unable to resolve {t} directory: {t}", .{ thing, err });
14021418 };
14031419 const nonempty_path = if (path.len == 0) "." else path;
14041420 const handle_or_err = switch (thing) {
1405 .@"zig lib" => Dir.cwd().openDir(io, nonempty_path, .{}),
1421 .@"zig lib", .@"build root" => Dir.cwd().openDir(io, nonempty_path, .{}),
14061422 .@"global cache", .@"local cache" => Dir.cwd().createDirPathOpen(io, nonempty_path, .{}),
14071423 };
14081424 return .{
......@@ -1747,6 +1763,7 @@ pub fn buildExeSubprocess(
17471763 const sub_path = try gpa.dupe(u8, prefixed_path[1..]);
17481764 var keep = false;
17491765 defer if (!keep) gpa.free(sub_path);
1766 log.debug("file system input: {t} {s}", .{ prefix, sub_path });
17501767 keep = man.addPrefixedPathPost(.{
17511768 .prefix = @backingInt(prefix),
17521769 .sub_path = sub_path,
lib/std/zig/Server.zig+1
......@@ -135,6 +135,7 @@ pub const Message = struct {
135135 zig_lib,
136136 local_cache,
137137 global_cache,
138 build_root,
138139 };
139140
140141 /// Trailing:
src/Compilation.zig+23-10
......@@ -397,6 +397,7 @@ pub const Path = struct {
397397 global_cache,
398398 /// `sub_path` is relative to the local cache directory on `Compilation`.
399399 local_cache,
400 build_root,
400401 /// `sub_path` is not relative to any of the roots listed above.
401402 /// It is resolved starting with `Directories.cwd`; so it is an absolute path on most
402403 /// targets, but cwd-relative on WASI. We do not make it cwd-relative on other targets
......@@ -439,6 +440,7 @@ pub const Path = struct {
439440 .zig_lib => dirs.zig_lib.handle,
440441 .global_cache => dirs.global_cache.handle,
441442 .local_cache => dirs.local_cache.handle,
443 .build_root => dirs.build_root.handle,
442444 };
443445 if (p.sub_path.len == 0) return .{ dir, "." };
444446 assert(!fs.path.isAbsolute(p.sub_path));
......@@ -457,6 +459,7 @@ pub const Path = struct {
457459 .zig_lib => f.comp.dirs.zig_lib.path orelse ".",
458460 .global_cache => f.comp.dirs.global_cache.path orelse ".",
459461 .local_cache => f.comp.dirs.local_cache.path orelse ".",
462 .build_root => f.comp.dirs.build_root.path orelse ".",
460463 .none => {
461464 const cwd_sub_path = absToCwdRelative(f.p.sub_path, f.comp.dirs.cwd);
462465 try w.writeAll(cwd_sub_path);
......@@ -581,6 +584,7 @@ pub const Path = struct {
581584 .zig_lib => dirs.zig_lib.path orelse "",
582585 .global_cache => dirs.global_cache.path orelse "",
583586 .local_cache => dirs.local_cache.path orelse "",
587 .build_root => dirs.build_root.path orelse "",
584588 .none => "",
585589 },
586590 sub_path,
......@@ -603,6 +607,7 @@ pub const Path = struct {
603607 .zig_lib => dirs.zig_lib.path orelse "",
604608 .global_cache => dirs.global_cache.path orelse "",
605609 .local_cache => dirs.local_cache.path orelse "",
610 .build_root => dirs.build_root.path orelse "",
606611 .none => "",
607612 },
608613 p.sub_path,
......@@ -622,6 +627,7 @@ pub const Path = struct {
622627 .zig_lib => dirs.zig_lib.path orelse "",
623628 .global_cache => dirs.global_cache.path orelse "",
624629 .local_cache => dirs.local_cache.path orelse "",
630 .build_root => dirs.build_root.path orelse "",
625631 .none => "",
626632 },
627633 p.sub_path,
......@@ -635,6 +641,7 @@ pub const Path = struct {
635641 .zig_lib => dirs.zig_lib,
636642 .global_cache => dirs.global_cache,
637643 .local_cache => dirs.local_cache,
644 .build_root => dirs.build_root,
638645 else => {
639646 const cwd_sub_path = absToCwdRelative(p.sub_path, dirs.cwd);
640647 return .{
......@@ -658,13 +665,10 @@ pub const Path = struct {
658665 .zig_lib => dirs.zig_lib.path orelse "",
659666 .global_cache => dirs.global_cache.path orelse "",
660667 .local_cache => dirs.local_cache.path orelse "",
668 .build_root => dirs.build_root.path orelse "",
661669 .none => "",
662670 };
663 return fs.path.resolve(gpa, &.{
664 dirs.cwd,
665 root_path,
666 p.sub_path,
667 });
671 return fs.path.resolve(gpa, &.{ dirs.cwd, root_path, p.sub_path });
668672 }
669673
670674 pub fn isNested(inner: Path, outer: Path) union(enum) {
......@@ -1348,7 +1352,7 @@ pub const CacheMode = enum {
13481352pub const ParentWholeCache = struct {
13491353 manifest: *Cache.Manifest,
13501354 mutex: *std.Io.Mutex,
1351 prefix_map: [4]u8,
1355 prefix_map: [5]u8,
13521356};
13531357
13541358const CacheUse = union(CacheMode) {
......@@ -1926,6 +1930,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,
19261930 }
19271931
19281932 const error_limit = options.error_limit orelse (std.math.maxInt(u16) - 1);
1933 const main_mod = options.main_mod orelse options.root_mod;
19291934
19301935 // We put everything into the cache hash that *cannot be modified
19311936 // 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,
19441949 },
19451950 .cwd = options.dirs.cwd,
19461951 };
1947 // These correspond to std.zig.Server.Message.PathPrefix.
1952 comptime assert(0 == @backingInt(std.zig.Server.Message.PathPrefix.cwd));
1953 comptime assert(1 == @backingInt(std.zig.Server.Message.PathPrefix.zig_lib));
1954 comptime assert(2 == @backingInt(std.zig.Server.Message.PathPrefix.local_cache));
1955 comptime assert(3 == @backingInt(std.zig.Server.Message.PathPrefix.global_cache));
1956 comptime assert(4 == @backingInt(std.zig.Server.Message.PathPrefix.build_root));
1957 comptime assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".field_names.len == 5);
19481958 cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() });
19491959 cache.addPrefix(options.dirs.zig_lib);
19501960 cache.addPrefix(options.dirs.local_cache);
19511961 cache.addPrefix(options.dirs.global_cache);
1962 log.debug("addPrefix build_root {s}", .{options.dirs.build_root.path orelse "(null)"});
1963 cache.addPrefix(options.dirs.build_root);
19521964 errdefer cache.manifest_dir.close(io);
19531965
19541966 // 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,
19841996 cache.hash.add(options.emit_docs != .no);
19851997 // TODO audit this and make sure everything is in it
19861998
1987 const main_mod = options.main_mod orelse options.root_mod;
19881999 const comp = try arena.create(Compilation);
19892000 const opt_zcu: ?*Zcu = if (have_zcu) blk: {
19902001 // 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
31163127 .zig_lib => comp.dirs.zig_lib,
31173128 .global_cache => comp.dirs.global_cache,
31183129 .local_cache => comp.dirs.local_cache,
3130 .build_root => comp.dirs.build_root,
31193131 .none => .cwd(),
31203132 };
31213133 const prefix: u8 = for (prefixes, 1..) |prefix_dir, i| {
......@@ -3123,8 +3135,8 @@ pub fn appendFileSystemInput(comp: *Compilation, path: Compilation.Path) Allocat
31233135 break @intCast(i);
31243136 }
31253137 } else std.debug.panic(
3126 "missing prefix directory '{s}' ('{f}') for '{s}'",
3127 .{ @tagName(path.root), want_prefix_dir, path.sub_path },
3138 "missing prefix directory {t} ('{f}') for {q}",
3139 .{ path.root, want_prefix_dir, path.sub_path },
31283140 );
31293141
31303142 // There may be concurrent calls to this function from C object workers and/or the main thread.
......@@ -7323,6 +7335,7 @@ fn buildOutputFromZig(
73237335 1, // zig lib dir is the same
73247336 3, // local cache is mapped to global cache
73257337 3, // global cache is the same
7338 0, // build root is not provided
73267339 },
73277340 },
73287341 .incremental, .none => null,
src/Zcu/PerThread.zig+1-1
......@@ -481,7 +481,7 @@ pub fn updateFile(
481481 const stat = try source_file.stat(io);
482482
483483 const want_local_cache = switch (file.path.root) {
484 .none, .local_cache => true,
484 .none, .local_cache, .build_root => true,
485485 .global_cache, .zig_lib => false,
486486 };
487487
src/codegen/llvm.zig+1
......@@ -1701,6 +1701,7 @@ pub const Object = struct {
17011701 .zig_lib => dirs.zig_lib.path,
17021702 .global_cache => dirs.global_cache.path,
17031703 .local_cache => dirs.local_cache.path,
1704 .build_root => dirs.build_root.path,
17041705 .none => null,
17051706 };
17061707
src/main.zig+46-46
......@@ -423,17 +423,16 @@ fn mainArgs(
423423 .wasi => {},
424424 else => process.executablePathAlloc(io, arena) catch |err| fatal("unable to find zig self exe path: {t}", .{err}),
425425 };
426 var dirs: std.zig.Directories = .init(
427 arena,
428 io,
429 EnvVar.ZIG_LIB_DIR.get(environ_map),
430 EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map),
431 .global,
432 preopens,
433 self_exe_path,
434 environ_map,
435 try std.zig.getResolvedCwd(io, arena),
436 );
426 var dirs: std.zig.Directories = .init(arena, io, .{
427 .override_zig_lib = EnvVar.ZIG_LIB_DIR.get(environ_map),
428 .override_global_cache = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map),
429 .build_root = null,
430 .local_cache_strat = .global,
431 .preopens = preopens,
432 .self_exe_path = self_exe_path,
433 .environ_map = environ_map,
434 .cwd = try std.zig.getResolvedCwd(io, arena),
435 });
437436 defer dirs.deinit(io);
438437 const host = std.zig.resolveTargetQueryOrFatal(io, .{});
439438 var stdout_writer = Io.File.stdout().writer(io, &stdout_buffer);
......@@ -458,17 +457,16 @@ fn mainArgs(
458457 .wasi => args[0],
459458 else => process.executablePathAlloc(io, arena) catch |err| fatal("unable to find zig self exe path: {t}", .{err}),
460459 };
461 var dirs: std.zig.Directories = .init(
462 arena,
463 io,
464 EnvVar.ZIG_LIB_DIR.get(environ_map),
465 EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map),
466 .global,
467 preopens,
468 if (native_os != .wasi) self_exe_path,
469 environ_map,
470 try std.zig.getResolvedCwd(io, arena),
471 );
460 var dirs: std.zig.Directories = .init(arena, io, .{
461 .override_zig_lib = EnvVar.ZIG_LIB_DIR.get(environ_map),
462 .override_global_cache = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map),
463 .build_root = null,
464 .local_cache_strat = .global,
465 .preopens = preopens,
466 .self_exe_path = if (native_os != .wasi) self_exe_path,
467 .environ_map = environ_map,
468 .cwd = try std.zig.getResolvedCwd(io, arena),
469 });
472470 defer dirs.deinit(io);
473471 const host = std.zig.resolveTargetQueryOrFatal(io, .{});
474472 var stdout_writer = Io.File.stdout().writer(io, &stdout_buffer);
......@@ -511,7 +509,7 @@ fn mainArgs(
511509 }
512510}
513511
514const usage_build_generic =
512const compile_usage =
515513 \\Usage: zig build-exe [options] [files]
516514 \\ zig build-lib [options] [files]
517515 \\ zig build-obj [options] [files]
......@@ -565,6 +563,7 @@ const usage_build_generic =
565563 \\ --cache-dir [path] Override the local cache directory
566564 \\ --global-cache-dir [path] Override the global cache directory
567565 \\ --zig-lib-dir [path] Override path to Zig installation lib directory
566 \\ --build-root [path] Override path to project source files
568567 \\
569568 \\Global Compile Options:
570569 \\ --name [name] Compilation unit name (not a file path)
......@@ -1054,6 +1053,7 @@ fn buildOutputType(
10541053 var rc_includes: std.zig.RcIncludes = .any;
10551054 var manifest_file: ?[]const u8 = null;
10561055 var linker_export_symbol_names: std.ArrayList([]const u8) = .empty;
1056 var build_root_path: ?[]const u8 = null;
10571057
10581058 // Tracks the position in c_source_files which have already their owner populated.
10591059 var c_source_files_owner_index: usize = 0;
......@@ -1167,7 +1167,7 @@ fn buildOutputType(
11671167 fatal("unable to read response file {q}: {t}", .{ resp_file_path, err });
11681168 } else if (mem.startsWith(u8, arg, "-")) {
11691169 if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {
1170 try Io.File.stdout().writeStreamingAll(io, usage_build_generic);
1170 try Io.File.stdout().writeStreamingAll(io, compile_usage);
11711171 return cleanExit(io);
11721172 } else if (mem.eql(u8, arg, "--")) {
11731173 if (arg_mode == .run) {
......@@ -1440,6 +1440,8 @@ fn buildOutputType(
14401440 override_global_cache_dir = args_iter.nextOrFatal();
14411441 } else if (mem.eql(u8, arg, "--zig-lib-dir")) {
14421442 override_lib_dir = args_iter.nextOrFatal();
1443 } else if (mem.eql(u8, arg, "--build-root")) {
1444 build_root_path = args_iter.nextOrFatal();
14431445 } else if (mem.eql(u8, arg, "--debug-log")) {
14441446 try addDebugLog(arena, args_iter.nextOrFatal());
14451447 } else if (mem.eql(u8, arg, "--listen")) {
......@@ -3254,23 +3256,22 @@ fn buildOutputType(
32543256 const cwd_path = try std.zig.getResolvedCwd(io, arena);
32553257
32563258 // This `init` calls `fatal` on error.
3257 var dirs: std.zig.Directories = .init(
3258 arena,
3259 io,
3260 override_lib_dir,
3261 override_global_cache_dir,
3262 s: {
3259 var dirs: std.zig.Directories = .init(arena, io, .{
3260 .override_zig_lib = override_lib_dir,
3261 .override_global_cache = override_global_cache_dir,
3262 .build_root = build_root_path,
3263 .local_cache_strat = s: {
32633264 if (override_local_cache_dir) |p| break :s .{ .override = p };
32643265 break :s switch (arg_mode) {
32653266 .run => .global,
32663267 else => .search,
32673268 };
32683269 },
3269 preopens,
3270 self_exe_path,
3271 environ_map,
3272 cwd_path,
3273 );
3270 .preopens = preopens,
3271 .self_exe_path = self_exe_path,
3272 .environ_map = environ_map,
3273 .cwd = cwd_path,
3274 });
32743275 defer dirs.deinit(io);
32753276
32763277 if (linker_optimization) |o| warn("ignoring deprecated linker optimization setting {q}", .{o});
......@@ -5020,17 +5021,16 @@ fn jitCmdInner(
50205021 const cwd_path = try std.zig.getResolvedCwd(io, arena);
50215022
50225023 // This `init` calls `fatal` on error.
5023 var dirs: std.zig.Directories = .init(
5024 arena,
5025 io,
5026 override_lib_dir,
5027 override_global_cache_dir,
5028 .global,
5029 preopens,
5030 self_exe_path,
5031 environ_map,
5032 cwd_path,
5033 );
5024 var dirs: std.zig.Directories = .init(arena, io, .{
5025 .override_zig_lib = override_lib_dir,
5026 .override_global_cache = override_global_cache_dir,
5027 .build_root = null,
5028 .local_cache_strat = .global,
5029 .preopens = preopens,
5030 .self_exe_path = self_exe_path,
5031 .environ_map = environ_map,
5032 .cwd = cwd_path,
5033 });
50345034 defer dirs.deinit(io);
50355035
50365036 var child_argv: std.ArrayList([]const u8) = .empty;