authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-06-23 23:10:41-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-06-29 23:50:19-07:00
log74168de68b8ebd6cb40cd9ab1c0c44d2e01012d4
tree7cb1ec8d1c06d22a0074691853adf5ebe72e50f8
parent20e7cc8d88dc1490d8635db0e6f96fff194763e6

Maker: fix lowering of build module on CLI


3 files changed, 18 insertions(+), 27 deletions(-)

lib/compiler/Maker.zig+14-19
......@@ -113,6 +113,15 @@ pub const CliModule = struct {
113113 deps: Deps = .empty,
114114
115115 const Deps = std.array_hash_map.String(*CliModule);
116
117 fn lower(cm: *const CliModule, arena: Allocator, gpa: Allocator, argv: *std.ArrayList([]const u8)) !void {
118 try argv.ensureUnusedCapacity(gpa, 2 * cm.deps.count() + 1);
119 for (cm.deps.values()) |dep| {
120 argv.appendAssumeCapacity("--dep");
121 argv.appendAssumeCapacity(dep.name);
122 }
123 argv.appendAssumeCapacity(try allocPrint(arena, "-M{s}={s}", .{ cm.name, cm.root_path }));
124 }
116125};
117126
118127pub fn main(init: process.Init.Minimal) !void {
......@@ -691,19 +700,12 @@ pub fn main(init: process.Init.Minimal) !void {
691700 "--dep", "@build", //
692701 "--dep", "@dependencies", //
693702 try allocPrint(arena, "-Mroot={f}", .{configurer_root_src_path}), //
694 try allocPrint(arena, "-M@build={f}", .{root_build_src_path}), //
695703 });
696704
697705 // In the loop below, after doing the fetch operation, the argv will be
698706 // truncated at this point, dependencies added, and then the
699707 // "--listen=-" arg appended at the end.
700 const argv_deps_index = build_configurer_argv.items.len - 1;
701
702 //const root_mod = try arena.create(CliModule);
703 //root_mod.* = .{
704 // .name = "root",
705 // .root_path = try configurer_root_src_path.toString(arena),
706 //};
708 const argv_deps_index = build_configurer_argv.items.len;
707709
708710 const build_mod = try arena.create(CliModule);
709711 build_mod.* = .{
......@@ -722,7 +724,6 @@ pub fn main(init: process.Init.Minimal) !void {
722724 // This loop is re-evaluated when the build script exits with an indication that it
723725 // could not continue due to missing lazy dependencies.
724726 const configuration_path: Path, const poisoned: bool = cp: while (true) {
725 //root_mod.deps.clearRetainingCapacity();
726727 build_mod.deps.clearRetainingCapacity();
727728 deps_mod.deps.clearRetainingCapacity();
728729
......@@ -923,21 +924,15 @@ pub fn main(init: process.Init.Minimal) !void {
923924 dep.name, dep.root_path,
924925 }));
925926 }
926 try build_configurer_argv.ensureUnusedCapacity(gpa, 2 * deps_mod.deps.count() + 1);
927 for (deps_mod.deps.values()) |dep| {
928 build_configurer_argv.appendAssumeCapacity("--dep");
929 build_configurer_argv.appendAssumeCapacity(dep.name);
930 }
931 build_configurer_argv.appendAssumeCapacity(try allocPrint(arena, "-M@dependencies={s}", .{
932 deps_mod.root_path,
933 }));
927 try deps_mod.lower(arena, gpa, &build_configurer_argv);
928 try build_mod.lower(arena, gpa, &build_configurer_argv);
929
930 try build_configurer_argv.append(gpa, "--listen=-");
934931 }
935932
936933 const compile_prog_node = main_progress_node.start("Compile Configure Script", 0);
937934 defer compile_prog_node.end();
938935
939 try build_configurer_argv.append(gpa, "--listen=-");
940
941936 const configure_exe_path: Path = if (std.zig.buildExeSubprocess(gpa, io, .{
942937 .argv = build_configurer_argv.items,
943938 .cache_root = graph.local_cache_root,
lib/std/zig.zig+1-3
......@@ -1798,9 +1798,7 @@ pub fn buildExeSubprocess(gpa: Allocator, io: Io, options: BuildExeSubprocessOpt
17981798 return error.AlreadyReported;
17991799 },
18001800 };
1801 log.err("{s} command reported {d} compilation errors: {f}", .{
1802 options.argv[0], result_error_bundle.errorMessageCount(), cmd,
1803 });
1801 log.err("command reported {d} compilation errors: {f}", .{ result_error_bundle.errorMessageCount(), cmd });
18041802 if (received_fs_inputs) return error.FailedButCacheIntact;
18051803 return error.AlreadyReported;
18061804 }
src/Compilation.zig+3-5
......@@ -2766,11 +2766,9 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
27662766 .file_open, .file_stat, .file_read, .file_hash => |op| {
27672767 const pp = man.files.keys()[op.file_index].prefixed_path;
27682768 const prefix = man.cache.prefixes()[pp.prefix];
2769 return comp.setMiscFailure(
2770 .check_whole_cache,
2771 "failed to check cache: '{f}{s}' {t} {t}",
2772 .{ prefix, pp.sub_path, man.diagnostic, op.err },
2773 );
2769 return comp.setMiscFailure(.check_whole_cache, "failed to check cache: {f}{s} {t} {t}", .{
2770 prefix, pp.sub_path, man.diagnostic, op.err,
2771 });
27742772 },
27752773 },
27762774 error.OutOfMemory, error.Canceled => |e| return e,