authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-04-30 18:35:20-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 18:54:35-07:00
log364a1400ffb7c88539a34d86c83245478b096b84
tree167c7714f5576a2c618e1499f810cd3a4a25dbc7
parent9ae410eec22dd0afaa93c3d2f33f3fa6ce6b7861

configurer: fix compilation in the presence of dependencies


2 files changed, 12 insertions(+), 21 deletions(-)

lib/std/Build.zig+9-18
......@@ -34,7 +34,6 @@ available_options_map: std.array_hash_map.String(AvailableOption) = .empty,
3434invalid_user_input: bool,
3535default_step: *Step,
3636top_level_steps: std.StringArrayHashMapUnmanaged(*Step.TopLevel),
37install_prefix: []const u8,
3837debug_log_scopes: []const []const u8 = &.{},
3938/// Number of stack frames captured when a `StackTrace` is recorded for debug purposes,
4039/// in particular at `Step` creation.
......@@ -217,7 +216,6 @@ pub fn create(
217216 .user_input_options = UserInputOptionsMap.init(arena),
218217 .top_level_steps = .{},
219218 .default_step = undefined,
220 .install_prefix = undefined,
221219 .install_tls = .{
222220 .step = .init(.{
223221 .tag = .top_level,
......@@ -506,7 +504,7 @@ const OrderedUserValue = union(enum) {
506504 hasher.update(sp.sub_path);
507505 },
508506 .generated => |gen| {
509 hasher.update(gen.file.step.owner.pkg_hash);
507 hasher.update(std.mem.asBytes(&gen.index));
510508 hasher.update(std.mem.asBytes(&gen.up));
511509 hasher.update(gen.sub_path);
512510 },
......@@ -1728,9 +1726,9 @@ fn findPkgHashOrFatal(b: *Build, name: []const u8) []const u8 {
17281726 for (b.available_deps) |dep| {
17291727 if (mem.eql(u8, dep[0], name)) return dep[1];
17301728 }
1731
1732 const full_path = b.pathFromRoot("build.zig.zon");
1733 std.debug.panic("no dependency named '{s}' in '{s}'. All packages used in build.zig must be declared in this file", .{ name, full_path });
1729 std.log.info("all dependencies used by build.zig must be declared in corresponding build.zig.zon", .{});
1730 if (b.pkg_hash.len == 0) std.debug.panic("no dependency named {s}", .{name});
1731 std.debug.panic("no dependency named {s} in {s} ({s})", .{ name, b.dep_prefix, b.pkg_hash });
17341732}
17351733
17361734inline fn findImportPkgHashOrFatal(b: *Build, comptime asking_build_zig: type, comptime dep_name: []const u8) []const u8 {
......@@ -1931,10 +1929,10 @@ fn userLazyPathsAreTheSame(lhs_lp: LazyPath, rhs_lp: LazyPath) bool {
19311929 if (lhs_sp.owner != rhs_sp.owner) return false;
19321930 if (std.mem.eql(u8, lhs_sp.sub_path, rhs_sp.sub_path)) return false;
19331931 },
1934 .generated => |lhs_gen| {
1935 const rhs_gen = rhs_lp.generated;
1932 .generated => |*lhs_gen| {
1933 const rhs_gen = &rhs_lp.generated;
19361934
1937 if (lhs_gen.file != rhs_gen.file) return false;
1935 if (lhs_gen.index != rhs_gen.index) return false;
19381936 if (lhs_gen.up != rhs_gen.up) return false;
19391937 if (std.mem.eql(u8, lhs_gen.sub_path, rhs_gen.sub_path)) return false;
19401938 },
......@@ -1962,7 +1960,6 @@ fn dependencyInner(
19621960 pkg_deps: AvailableDeps,
19631961 args: anytype,
19641962) *Dependency {
1965 const io = b.graph.io;
19661963 const user_input_options = userInputOptionsFromArgs(b.allocator, args);
19671964 if (b.graph.dependency_cache.getContext(.{
19681965 .build_root_string = build_root_string,
......@@ -1970,13 +1967,7 @@ fn dependencyInner(
19701967 }, .{ .allocator = b.graph.arena })) |dep|
19711968 return dep;
19721969
1973 const build_root: std.Build.Cache.Directory = .{
1974 .path = build_root_string,
1975 .handle = Io.Dir.cwd().openDir(io, build_root_string, .{}) catch |err|
1976 process.fatal("unable to open {s}: {t}", .{ build_root_string, err }),
1977 };
1978
1979 const sub_builder = b.createChild(name, build_root, pkg_hash, pkg_deps, user_input_options) catch
1970 const sub_builder = b.createChild(name, pkg_hash, pkg_deps, user_input_options) catch
19801971 @panic("unhandled error");
19811972 if (build_zig) |bz| {
19821973 sub_builder.runBuild(bz) catch @panic("unhandled error");
......@@ -2142,7 +2133,7 @@ pub const LazyPath = union(enum) {
21422133 .sub_path = try fs.path.resolve(arena, &.{ src.sub_path, sub_path }),
21432134 } },
21442135 .generated => |gen| .{ .generated = .{
2145 .file = gen.file,
2136 .index = gen.index,
21462137 .up = gen.up,
21472138 .sub_path = try fs.path.resolve(arena, &.{ gen.sub_path, sub_path }),
21482139 } },
lib/std/Build/Step/Compile.zig+3-3
......@@ -317,10 +317,10 @@ pub const HeaderInstallation = union(enum) {
317317 /// `exclude_extensions` takes precedence over `include_extensions`.
318318 include_extensions: ?[]const []const u8 = &.{".h"},
319319
320 pub fn dupe(opts: Directory.Options, b: *std.Build) Directory.Options {
320 pub fn dupe(opts: Directory.Options, graph: *std.Build.Graph) Directory.Options {
321321 return .{
322 .exclude_extensions = b.dupeStrings(opts.exclude_extensions),
323 .include_extensions = if (opts.include_extensions) |incs| b.dupeStrings(incs) else null,
322 .exclude_extensions = graph.dupeStrings(opts.exclude_extensions),
323 .include_extensions = if (opts.include_extensions) |incs| graph.dupeStrings(incs) else null,
324324 };
325325 }
326326 };