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-16 12:34:06-07:00
log2249a9198c82eab9663826451ae89381cf862bc7
treeed89ff3dd33f96f803713e30d9a210ce1efece92
parent026e105afaf33c4887a02102b21f8c2e233cd930

Maker: guard project id construction with have_manifest


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

lib/compiler/Maker.zig+26-24
...@@ -1387,32 +1387,34 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig {...@@ -1387,32 +1387,34 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig {
1387 }1387 }
1388 if (!f.has_build_zig) continue;1388 if (!f.has_build_zig) continue;
13891389
1390 const project_id: Package.ProjectId = .init(f.manifest.name, f.manifest.id);1390 if (f.have_manifest) {
1391 if (fork_set.getKeyPtrAdapted(project_id, @as(Fetch.JobQueue.Fork.Adapter, .{}))) |fork| {1391 const project_id: Package.ProjectId = .init(f.manifest.name, f.manifest.id);
1392 const path = try fork.path.toString(arena);1392 if (fork_set.getKeyPtrAdapted(project_id, @as(Fetch.JobQueue.Fork.Adapter, .{}))) |fork| {
1393 const gop = deps_mod.deps.getOrPutAssumeCapacity(path);1393 const path = try fork.path.toString(arena);
1394 if (gop.found_existing) {1394 const gop = deps_mod.deps.getOrPutAssumeCapacity(path);
1395 assert(fork.uses > 1);1395 if (gop.found_existing) {
1396 f.cli_module = gop.value_ptr.*;1396 assert(fork.uses > 1);
1397 } else {1397 f.cli_module = gop.value_ptr.*;
1398 const m = try arena.create(CliModule);1398 } else {
1399 m.* = .{1399 const m = try arena.create(CliModule);
1400 .root_path = try f.package_root.toString(arena),1400 m.* = .{
1401 .name = path,1401 .root_path = try f.package_root.toString(arena),
1402 };1402 .name = path,
1403 gop.value_ptr.* = m;1403 };
1404 f.cli_module = m;1404 gop.value_ptr.* = m;
1405 f.cli_module = m;
1406 }
1407 continue;
1405 }1408 }
1406 } else {
1407 const hash_slice = try arena.dupe(u8, hash.toSlice());
1408 const m = try arena.create(CliModule);
1409 m.* = .{
1410 .root_path = try f.package_root.toString(arena),
1411 .name = hash_slice,
1412 };
1413 deps_mod.deps.putAssumeCapacityNoClobber(hash_slice, m);
1414 f.cli_module = m;
1415 }1409 }
1410 const hash_slice = try arena.dupe(u8, hash.toSlice());
1411 const m = try arena.create(CliModule);
1412 m.* = .{
1413 .root_path = try f.package_root.toString(arena),
1414 .name = hash_slice,
1415 };
1416 deps_mod.deps.putAssumeCapacityNoClobber(hash_slice, m);
1417 f.cli_module = m;
1416 }1418 }
14171419
1418 // Each build.zig module needs access to each of its dependencies' build.zig modules by1420 // 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 {...@@ -289,19 +289,21 @@ pub const JobQueue = struct {
289 \\289 \\
290 , .{std.fmt.alt(fetch.package_root, .formatEscapeString)});290 , .{std.fmt.alt(fetch.package_root, .formatEscapeString)});
291291
292 if (fetch.has_build_zig) {292 if (fetch.has_build_zig) b: {
293 const project_id: Package.ProjectId = .init(fetch.manifest.name, fetch.manifest.id);293 if (fetch.have_manifest) {
294 if (jq.fork_set.getKeyPtrAdapted(project_id, @as(JobQueue.Fork.Adapter, .{}))) |fork| {294 const project_id: Package.ProjectId = .init(fetch.manifest.name, fetch.manifest.id);
295 try w.print(295 if (jq.fork_set.getKeyPtrAdapted(project_id, @as(JobQueue.Fork.Adapter, .{}))) |fork| {
296 \\ pub const build_zig = @import({qf});296 try w.print(
297 \\297 \\ pub const build_zig = @import({qf});
298 , .{fork.path});298 \\
299 } else {299 , .{fork.path});
300 try w.print(300 }
301 \\ pub const build_zig = @import({q});301 break :b;
302 \\
303 , .{hash_slice});
304 }302 }
303 try w.print(
304 \\ pub const build_zig = @import({q});
305 \\
306 , .{hash_slice});
305 }307 }
306308
307 if (fetch.have_manifest) {309 if (fetch.have_manifest) {