authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-06-23 23:32:29-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-06-29 23:50:19-07:00
logc8dad46ced6afcf08dfac2b8d4ae0c3a062983be
tree9fa770c345acba6ff1faea16f75a5603b94915bc
parent9add673f584a514b2e519f679fb0f6baf71daab7

Maker: add configure file system inputs to configuration cache

also wire up progress node to child

4 files changed, 37 insertions(+), 17 deletions(-)

lib/compiler/Maker.zig+7
...@@ -573,11 +573,17 @@ pub fn main(init: process.Init.Minimal) !void {...@@ -573,11 +573,17 @@ pub fn main(init: process.Init.Minimal) !void {
573 .manifest_dir = try graph.local_cache_root.handle.createDirPathOpen(io, "h", .{}),573 .manifest_dir = try graph.local_cache_root.handle.createDirPathOpen(io, "h", .{}),
574 .cwd = cwd_path,574 .cwd = cwd_path,
575 };575 };
576
576 graph.cache.addPrefix(.{ .path = null, .handle = cwd });577 graph.cache.addPrefix(.{ .path = null, .handle = cwd });
577 graph.cache.addPrefix(zig_lib_directory);578 graph.cache.addPrefix(zig_lib_directory);
578 graph.cache.addPrefix(graph.local_cache_root);579 graph.cache.addPrefix(graph.local_cache_root);
579 graph.cache.addPrefix(global_cache_directory);580 graph.cache.addPrefix(global_cache_directory);
580 graph.cache.addPrefix(graph.build_root_directory);581 graph.cache.addPrefix(graph.build_root_directory);
582 comptime assert(0 == @intFromEnum(std.zig.Server.Message.PathPrefix.cwd));
583 comptime assert(1 == @intFromEnum(std.zig.Server.Message.PathPrefix.zig_lib));
584 comptime assert(2 == @intFromEnum(std.zig.Server.Message.PathPrefix.local_cache));
585 comptime assert(3 == @intFromEnum(std.zig.Server.Message.PathPrefix.global_cache));
586
581 graph.cache.hash.addBytes(builtin.zig_version_string);587 graph.cache.hash.addBytes(builtin.zig_version_string);
582588
583 const NO_COLOR = EnvVar.NO_COLOR.isSet(&graph.environ_map);589 const NO_COLOR = EnvVar.NO_COLOR.isSet(&graph.environ_map);
...@@ -940,6 +946,7 @@ pub fn main(init: process.Init.Minimal) !void {...@@ -940,6 +946,7 @@ pub fn main(init: process.Init.Minimal) !void {
940 .environ_map = &graph.environ_map,946 .environ_map = &graph.environ_map,
941 .cache_manifest = &config_man,947 .cache_manifest = &config_man,
942 .arch_os_abi = target_arch_os_abi,948 .arch_os_abi = target_arch_os_abi,
949 .progress_node = compile_prog_node,
943 })) |p| p else |err| switch (err) {950 })) |p| p else |err| switch (err) {
944 error.AlreadyReported => process.exit(1),951 error.AlreadyReported => process.exit(1),
945 // If the file system inputs are populated, we can952 // If the file system inputs are populated, we can
lib/compiler/Maker/WebServer.zig+4
...@@ -622,12 +622,16 @@ fn buildClientWasm(ws: *WebServer, arena: Allocator, optimize: std.builtin.Optim...@@ -622,12 +622,16 @@ fn buildClientWasm(ws: *WebServer, arena: Allocator, optimize: std.builtin.Optim
622 "--listen=-",622 "--listen=-",
623 });623 });
624624
625 const compile_prog_node = ws.root_prog_node.start("Compile WebAssembly Component", 0);
626 defer compile_prog_node.end();
627
625 return std.zig.buildExeSubprocess(gpa, io, .{628 return std.zig.buildExeSubprocess(gpa, io, .{
626 .argv = argv.items,629 .argv = argv.items,
627 .cache_root = graph.global_cache_root,630 .cache_root = graph.global_cache_root,
628 .root_name = root_name,631 .root_name = root_name,
629 .arch_os_abi = arch_os_abi,632 .arch_os_abi = arch_os_abi,
630 .cpu_features = cpu_features,633 .cpu_features = cpu_features,
634 .progress_node = compile_prog_node,
631 });635 });
632}636}
633637
lib/std/Build/Cache.zig+2-2
...@@ -91,13 +91,13 @@ fn findPrefixResolved(cache: *const Cache, resolved_path: []u8) !PrefixedPath {...@@ -91,13 +91,13 @@ fn findPrefixResolved(cache: *const Cache, resolved_path: []u8) !PrefixedPath {
91 };91 };
92 // Free the resolved path since we're not going to return it92 // Free the resolved path since we're not going to return it
93 gpa.free(resolved_path);93 gpa.free(resolved_path);
94 return PrefixedPath{94 return .{
95 .prefix = i,95 .prefix = i,
96 .sub_path = sub_path,96 .sub_path = sub_path,
97 };97 };
98 }98 }
9999
100 return PrefixedPath{100 return .{
101 .prefix = 0,101 .prefix = 0,
102 .sub_path = resolved_path,102 .sub_path = resolved_path,
103 };103 };
lib/std/zig.zig+24-15
...@@ -1250,7 +1250,7 @@ pub const SubprocessCommand = struct {...@@ -1250,7 +1250,7 @@ pub const SubprocessCommand = struct {
1250 for (child_env.keys(), child_env.values()) |key, value| {1250 for (child_env.keys(), child_env.values()) |key, value| {
1251 if (sc.parent_env) |parent_env| {1251 if (sc.parent_env) |parent_env| {
1252 if (parent_env.get(key)) |process_value| {1252 if (parent_env.get(key)) |process_value| {
1253 if (std.mem.eql(u8, value, process_value)) continue;1253 if (mem.eql(u8, value, process_value)) continue;
1254 }1254 }
1255 }1255 }
1256 try w.print("{s}=", .{key});1256 try w.print("{s}=", .{key});
...@@ -1364,10 +1364,10 @@ pub const Directories = struct {...@@ -1364,10 +1364,10 @@ pub const Directories = struct {
13641364
1365 const local_cache = getLocalCacheDirectory(arena, io, cwd, global_cache, local_cache_strat);1365 const local_cache = getLocalCacheDirectory(arena, io, cwd, global_cache, local_cache_strat);
13661366
1367 if (std.mem.eql(u8, zig_lib.path orelse "", global_cache.path orelse "")) {1367 if (mem.eql(u8, zig_lib.path orelse "", global_cache.path orelse "")) {
1368 fatal("zig lib directory '{f}' cannot be equal to global cache directory '{f}'", .{ zig_lib, global_cache });1368 fatal("zig lib directory '{f}' cannot be equal to global cache directory '{f}'", .{ zig_lib, global_cache });
1369 }1369 }
1370 if (std.mem.eql(u8, zig_lib.path orelse "", local_cache.path orelse "")) {1370 if (mem.eql(u8, zig_lib.path orelse "", local_cache.path orelse "")) {
1371 fatal("zig lib directory '{f}' cannot be equal to local cache directory '{f}'", .{ zig_lib, local_cache });1371 fatal("zig lib directory '{f}' cannot be equal to local cache directory '{f}'", .{ zig_lib, local_cache });
1372 }1372 }
13731373
...@@ -1400,7 +1400,7 @@ pub const Directories = struct {...@@ -1400,7 +1400,7 @@ pub const Directories = struct {
14001400
1401 fn getPreopen(preopens: std.process.Preopens, name: []const u8) Cache.Directory {1401 fn getPreopen(preopens: std.process.Preopens, name: []const u8) Cache.Directory {
1402 return .{1402 return .{
1403 .path = if (std.mem.eql(u8, name, ".")) null else name,1403 .path = if (mem.eql(u8, name, ".")) null else name,
1404 .handle = switch (preopens.get(name) orelse fatal("preopen not found: {q}", .{name})) {1404 .handle = switch (preopens.get(name) orelse fatal("preopen not found: {q}", .{name})) {
1405 .file => fatal("preopen {q} is not a directory", .{name}),1405 .file => fatal("preopen {q} is not a directory", .{name}),
1406 .dir => |d| d,1406 .dir => |d| d,
...@@ -1607,7 +1607,7 @@ pub fn resolvePath(...@@ -1607,7 +1607,7 @@ pub fn resolvePath(
1607 assert(Dir.path.isAbsolute(path_resolved));1607 assert(Dir.path.isAbsolute(path_resolved));
1608 assert(Dir.path.isAbsolute(cwd_resolved));1608 assert(Dir.path.isAbsolute(cwd_resolved));
16091609
1610 if (!std.mem.startsWith(u8, path_resolved, cwd_resolved)) return path_resolved; // not in cwd1610 if (!mem.startsWith(u8, path_resolved, cwd_resolved)) return path_resolved; // not in cwd
1611 if (path_resolved.len == cwd_resolved.len) {1611 if (path_resolved.len == cwd_resolved.len) {
1612 // equal to cwd1612 // equal to cwd
1613 gpa.free(path_resolved);1613 gpa.free(path_resolved);
...@@ -1634,6 +1634,7 @@ pub const BuildExeSubprocessOptions = struct {...@@ -1634,6 +1634,7 @@ pub const BuildExeSubprocessOptions = struct {
1634 cache_manifest: ?*Cache.Manifest = null,1634 cache_manifest: ?*Cache.Manifest = null,
1635 arch_os_abi: ?[]const u8 = null,1635 arch_os_abi: ?[]const u8 = null,
1636 cpu_features: ?[]const u8 = null,1636 cpu_features: ?[]const u8 = null,
1637 progress_node: std.Progress.Node = .none,
1637};1638};
16381639
1639pub const BuildExeSubprocessError = error{1640pub const BuildExeSubprocessError = error{
...@@ -1655,6 +1656,7 @@ pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOpt...@@ -1655,6 +1656,7 @@ pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOpt
1655 .stdin = .pipe,1656 .stdin = .pipe,
1656 .stdout = .pipe,1657 .stdout = .pipe,
1657 .stderr = .pipe,1658 .stderr = .pipe,
1659 .progress_node = options.progress_node,
1658 }) catch |err| {1660 }) catch |err| {
1659 log.err("spawning command {t}: {f}", .{ err, cmd });1661 log.err("spawning command {t}: {f}", .{ err, cmd });
1660 return error.AlreadyReported;1662 return error.AlreadyReported;
...@@ -1722,7 +1724,7 @@ pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOpt...@@ -1722,7 +1724,7 @@ pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOpt
17221724
1723 switch (header.tag) {1725 switch (header.tag) {
1724 .zig_version => {1726 .zig_version => {
1725 if (!std.mem.eql(u8, builtin.zig_version_string, body)) {1727 if (!mem.eql(u8, builtin.zig_version_string, body)) {
1726 log.err("zig protocol version mismatch from command: {f}", .{cmd});1728 log.err("zig protocol version mismatch from command: {f}", .{cmd});
1727 return error.AlreadyReported;1729 return error.AlreadyReported;
1728 }1730 }
...@@ -1747,16 +1749,23 @@ pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOpt...@@ -1747,16 +1749,23 @@ pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOpt
1747 .sub_path = try Dir.path.join(gpa, &.{ "o", &Cache.binToHex(digest.*) }),1749 .sub_path = try Dir.path.join(gpa, &.{ "o", &Cache.binToHex(digest.*) }),
1748 };1750 };
1749 },1751 },
1750 .file_system_inputs => {1752 .file_system_inputs => if (options.cache_manifest) |man| {
1751 received_fs_inputs = true;1753 received_fs_inputs = true;
1752 @panic("TODO");1754 var it = mem.splitScalar(u8, body, 0);
1753 //var it = mem.splitScalar(u8, file_system_inputs.items, 0);1755 while (it.next()) |prefixed_path| {
1754 //while (it.next()) |input| {1756 const prefix: Server.Message.PathPrefix = @enumFromInt(prefixed_path[0] - 1);
1755 // _ = try config_man.addPrefixedPathPost(.{1757 const sub_path = prefixed_path[1..];
1756 // .prefix = input[0],1758 _ = man.addPrefixedPathPost(.{
1757 // .sub_path = input[1..],1759 .prefix = @intFromEnum(prefix),
1758 // });1760 .sub_path = sub_path,
1759 //}1761 }) catch |err| switch (err) {
1762 error.Canceled, error.OutOfMemory => |e| return e,
1763 else => |e| {
1764 log.err("adding {t} {s} to cache failed: {t}", .{ prefix, sub_path, e });
1765 return error.AlreadyReported;
1766 },
1767 };
1768 }
1760 },1769 },
1761 else => {}, // ignore other messages1770 else => {}, // ignore other messages
1762 }1771 }