From f6a00a4751c7d49f7a4406e9c640ebaee85662f9 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 14 Oct 2026 19:00:42 -0700 Subject: [PATCH] Maker: guard project id construction with have_manifest --- lib/compiler/Maker.zig | 50 +++++++++++++++++++----------------- lib/compiler/Maker/Fetch.zig | 26 ++++++++++--------- 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/lib/compiler/Maker.zig b/lib/compiler/Maker.zig index 829c28ff55bcd4e71bc336caca0c7623fe4a4c04..d9f0b132550e12a42f92acdda4be520b465439c5 100644 --- a/lib/compiler/Maker.zig +++ b/lib/compiler/Maker.zig @@ -1446,32 +1446,34 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { } if (!f.has_build_zig) continue; - const project_id: Package.ProjectId = .init(f.manifest.name, f.manifest.id); - if (fork_set.getKeyPtrAdapted(project_id, @as(Fetch.JobQueue.Fork.Adapter, .{}))) |fork| { - const path = try fork.path.toString(arena); - const gop = deps_mod.deps.getOrPutAssumeCapacity(path); - if (gop.found_existing) { - assert(fork.uses > 1); - f.cli_module = gop.value_ptr.*; - } else { - const m = try arena.create(CliModule); - m.* = .{ - .root_path = try f.package_root.toString(arena), - .name = path, - }; - gop.value_ptr.* = m; - f.cli_module = m; + if (f.have_manifest) { + const project_id: Package.ProjectId = .init(f.manifest.name, f.manifest.id); + if (fork_set.getKeyPtrAdapted(project_id, @as(Fetch.JobQueue.Fork.Adapter, .{}))) |fork| { + const path = try fork.path.toString(arena); + const gop = deps_mod.deps.getOrPutAssumeCapacity(path); + if (gop.found_existing) { + assert(fork.uses > 1); + f.cli_module = gop.value_ptr.*; + } else { + const m = try arena.create(CliModule); + m.* = .{ + .root_path = try f.package_root.toString(arena), + .name = path, + }; + gop.value_ptr.* = m; + f.cli_module = m; + } + continue; } - } else { - const hash_slice = try arena.dupe(u8, hash.toSlice()); - const m = try arena.create(CliModule); - m.* = .{ - .root_path = try f.package_root.toString(arena), - .name = hash_slice, - }; - deps_mod.deps.putAssumeCapacityNoClobber(hash_slice, m); - f.cli_module = m; } + const hash_slice = try arena.dupe(u8, hash.toSlice()); + const m = try arena.create(CliModule); + m.* = .{ + .root_path = try f.package_root.toString(arena), + .name = hash_slice, + }; + deps_mod.deps.putAssumeCapacityNoClobber(hash_slice, m); + f.cli_module = m; } // Each build.zig module needs access to each of its dependencies' build.zig modules by diff --git a/lib/compiler/Maker/Fetch.zig b/lib/compiler/Maker/Fetch.zig index 9fa9b121399b55d5745172bda914b1dc3a87a206..68294ffe3a856cd564bb4e365cb93b08189ab6a4 100644 --- a/lib/compiler/Maker/Fetch.zig +++ b/lib/compiler/Maker/Fetch.zig @@ -289,19 +289,21 @@ pub const JobQueue = struct { \\ , .{std.fmt.alt(fetch.package_root, .formatEscapeString)}); - if (fetch.has_build_zig) { - const project_id: Package.ProjectId = .init(fetch.manifest.name, fetch.manifest.id); - if (jq.fork_set.getKeyPtrAdapted(project_id, @as(JobQueue.Fork.Adapter, .{}))) |fork| { - try w.print( - \\ pub const build_zig = @import({qf}); - \\ - , .{fork.path}); - } else { - try w.print( - \\ pub const build_zig = @import({q}); - \\ - , .{hash_slice}); + if (fetch.has_build_zig) b: { + if (fetch.have_manifest) { + const project_id: Package.ProjectId = .init(fetch.manifest.name, fetch.manifest.id); + if (jq.fork_set.getKeyPtrAdapted(project_id, @as(JobQueue.Fork.Adapter, .{}))) |fork| { + try w.print( + \\ pub const build_zig = @import({qf}); + \\ + , .{fork.path}); + } + break :b; } + try w.print( + \\ pub const build_zig = @import({q}); + \\ + , .{hash_slice}); } if (fetch.have_manifest) { -- 2.54.0