authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-10-14 19:00:42-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-10-14 19:00:42-07:00
logf6a00a4751c7d49f7a4406e9c640ebaee85662f9
tree46e0c3f57a4d7e352c7cb478a1573b64e6842c93
parent6cecad145d569bf9794760ca13bd2bf479a357c7

Maker: guard project id construction with have_manifest


2 files changed, 40 insertions(+), 36 deletions(-)

lib/compiler/Maker.zig+26-24
......@@ -1446,32 +1446,34 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig {
14461446 }
14471447 if (!f.has_build_zig) continue;
14481448
1449 const project_id: Package.ProjectId = .init(f.manifest.name, f.manifest.id);
1450 if (fork_set.getKeyPtrAdapted(project_id, @as(Fetch.JobQueue.Fork.Adapter, .{}))) |fork| {
1451 const path = try fork.path.toString(arena);
1452 const gop = deps_mod.deps.getOrPutAssumeCapacity(path);
1453 if (gop.found_existing) {
1454 assert(fork.uses > 1);
1455 f.cli_module = gop.value_ptr.*;
1456 } else {
1457 const m = try arena.create(CliModule);
1458 m.* = .{
1459 .root_path = try f.package_root.toString(arena),
1460 .name = path,
1461 };
1462 gop.value_ptr.* = m;
1463 f.cli_module = m;
1449 if (f.have_manifest) {
1450 const project_id: Package.ProjectId = .init(f.manifest.name, f.manifest.id);
1451 if (fork_set.getKeyPtrAdapted(project_id, @as(Fetch.JobQueue.Fork.Adapter, .{}))) |fork| {
1452 const path = try fork.path.toString(arena);
1453 const gop = deps_mod.deps.getOrPutAssumeCapacity(path);
1454 if (gop.found_existing) {
1455 assert(fork.uses > 1);
1456 f.cli_module = gop.value_ptr.*;
1457 } else {
1458 const m = try arena.create(CliModule);
1459 m.* = .{
1460 .root_path = try f.package_root.toString(arena),
1461 .name = path,
1462 };
1463 gop.value_ptr.* = m;
1464 f.cli_module = m;
1465 }
1466 continue;
14641467 }
1465 } else {
1466 const hash_slice = try arena.dupe(u8, hash.toSlice());
1467 const m = try arena.create(CliModule);
1468 m.* = .{
1469 .root_path = try f.package_root.toString(arena),
1470 .name = hash_slice,
1471 };
1472 deps_mod.deps.putAssumeCapacityNoClobber(hash_slice, m);
1473 f.cli_module = m;
14741468 }
1469 const hash_slice = try arena.dupe(u8, hash.toSlice());
1470 const m = try arena.create(CliModule);
1471 m.* = .{
1472 .root_path = try f.package_root.toString(arena),
1473 .name = hash_slice,
1474 };
1475 deps_mod.deps.putAssumeCapacityNoClobber(hash_slice, m);
1476 f.cli_module = m;
14751477 }
14761478
14771479 // Each build.zig module needs access to each of its dependencies' build.zig modules by
lib/compiler/Maker/Fetch.zig+14-12
......@@ -289,19 +289,21 @@ pub const JobQueue = struct {
289289 \\
290290 , .{std.fmt.alt(fetch.package_root, .formatEscapeString)});
291291
292 if (fetch.has_build_zig) {
293 const project_id: Package.ProjectId = .init(fetch.manifest.name, fetch.manifest.id);
294 if (jq.fork_set.getKeyPtrAdapted(project_id, @as(JobQueue.Fork.Adapter, .{}))) |fork| {
295 try w.print(
296 \\ pub const build_zig = @import({qf});
297 \\
298 , .{fork.path});
299 } else {
300 try w.print(
301 \\ pub const build_zig = @import({q});
302 \\
303 , .{hash_slice});
292 if (fetch.has_build_zig) b: {
293 if (fetch.have_manifest) {
294 const project_id: Package.ProjectId = .init(fetch.manifest.name, fetch.manifest.id);
295 if (jq.fork_set.getKeyPtrAdapted(project_id, @as(JobQueue.Fork.Adapter, .{}))) |fork| {
296 try w.print(
297 \\ pub const build_zig = @import({qf});
298 \\
299 , .{fork.path});
300 }
301 break :b;
304302 }
303 try w.print(
304 \\ pub const build_zig = @import({q});
305 \\
306 , .{hash_slice});
305307 }
306308
307309 if (fetch.have_manifest) {