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,...@@ -34,7 +34,6 @@ available_options_map: std.array_hash_map.String(AvailableOption) = .empty,
34invalid_user_input: bool,34invalid_user_input: bool,
35default_step: *Step,35default_step: *Step,
36top_level_steps: std.StringArrayHashMapUnmanaged(*Step.TopLevel),36top_level_steps: std.StringArrayHashMapUnmanaged(*Step.TopLevel),
37install_prefix: []const u8,
38debug_log_scopes: []const []const u8 = &.{},37debug_log_scopes: []const []const u8 = &.{},
39/// Number of stack frames captured when a `StackTrace` is recorded for debug purposes,38/// Number of stack frames captured when a `StackTrace` is recorded for debug purposes,
40/// in particular at `Step` creation.39/// in particular at `Step` creation.
...@@ -217,7 +216,6 @@ pub fn create(...@@ -217,7 +216,6 @@ pub fn create(
217 .user_input_options = UserInputOptionsMap.init(arena),216 .user_input_options = UserInputOptionsMap.init(arena),
218 .top_level_steps = .{},217 .top_level_steps = .{},
219 .default_step = undefined,218 .default_step = undefined,
220 .install_prefix = undefined,
221 .install_tls = .{219 .install_tls = .{
222 .step = .init(.{220 .step = .init(.{
223 .tag = .top_level,221 .tag = .top_level,
...@@ -506,7 +504,7 @@ const OrderedUserValue = union(enum) {...@@ -506,7 +504,7 @@ const OrderedUserValue = union(enum) {
506 hasher.update(sp.sub_path);504 hasher.update(sp.sub_path);
507 },505 },
508 .generated => |gen| {506 .generated => |gen| {
509 hasher.update(gen.file.step.owner.pkg_hash);507 hasher.update(std.mem.asBytes(&gen.index));
510 hasher.update(std.mem.asBytes(&gen.up));508 hasher.update(std.mem.asBytes(&gen.up));
511 hasher.update(gen.sub_path);509 hasher.update(gen.sub_path);
512 },510 },
...@@ -1728,9 +1726,9 @@ fn findPkgHashOrFatal(b: *Build, name: []const u8) []const u8 {...@@ -1728,9 +1726,9 @@ fn findPkgHashOrFatal(b: *Build, name: []const u8) []const u8 {
1728 for (b.available_deps) |dep| {1726 for (b.available_deps) |dep| {
1729 if (mem.eql(u8, dep[0], name)) return dep[1];1727 if (mem.eql(u8, dep[0], name)) return dep[1];
1730 }1728 }
17311729 std.log.info("all dependencies used by build.zig must be declared in corresponding build.zig.zon", .{});
1732 const full_path = b.pathFromRoot("build.zig.zon");1730 if (b.pkg_hash.len == 0) std.debug.panic("no dependency named {s}", .{name});
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 });1731 std.debug.panic("no dependency named {s} in {s} ({s})", .{ name, b.dep_prefix, b.pkg_hash });
1734}1732}
17351733
1736inline fn findImportPkgHashOrFatal(b: *Build, comptime asking_build_zig: type, comptime dep_name: []const u8) []const u8 {1734inline 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 {...@@ -1931,10 +1929,10 @@ fn userLazyPathsAreTheSame(lhs_lp: LazyPath, rhs_lp: LazyPath) bool {
1931 if (lhs_sp.owner != rhs_sp.owner) return false;1929 if (lhs_sp.owner != rhs_sp.owner) return false;
1932 if (std.mem.eql(u8, lhs_sp.sub_path, rhs_sp.sub_path)) return false;1930 if (std.mem.eql(u8, lhs_sp.sub_path, rhs_sp.sub_path)) return false;
1933 },1931 },
1934 .generated => |lhs_gen| {1932 .generated => |*lhs_gen| {
1935 const rhs_gen = rhs_lp.generated;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;
1938 if (lhs_gen.up != rhs_gen.up) return false;1936 if (lhs_gen.up != rhs_gen.up) return false;
1939 if (std.mem.eql(u8, lhs_gen.sub_path, rhs_gen.sub_path)) return false;1937 if (std.mem.eql(u8, lhs_gen.sub_path, rhs_gen.sub_path)) return false;
1940 },1938 },
...@@ -1962,7 +1960,6 @@ fn dependencyInner(...@@ -1962,7 +1960,6 @@ fn dependencyInner(
1962 pkg_deps: AvailableDeps,1960 pkg_deps: AvailableDeps,
1963 args: anytype,1961 args: anytype,
1964) *Dependency {1962) *Dependency {
1965 const io = b.graph.io;
1966 const user_input_options = userInputOptionsFromArgs(b.allocator, args);1963 const user_input_options = userInputOptionsFromArgs(b.allocator, args);
1967 if (b.graph.dependency_cache.getContext(.{1964 if (b.graph.dependency_cache.getContext(.{
1968 .build_root_string = build_root_string,1965 .build_root_string = build_root_string,
...@@ -1970,13 +1967,7 @@ fn dependencyInner(...@@ -1970,13 +1967,7 @@ fn dependencyInner(
1970 }, .{ .allocator = b.graph.arena })) |dep|1967 }, .{ .allocator = b.graph.arena })) |dep|
1971 return dep;1968 return dep;
19721969
1973 const build_root: std.Build.Cache.Directory = .{1970 const sub_builder = b.createChild(name, pkg_hash, pkg_deps, user_input_options) catch
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
1980 @panic("unhandled error");1971 @panic("unhandled error");
1981 if (build_zig) |bz| {1972 if (build_zig) |bz| {
1982 sub_builder.runBuild(bz) catch @panic("unhandled error");1973 sub_builder.runBuild(bz) catch @panic("unhandled error");
...@@ -2142,7 +2133,7 @@ pub const LazyPath = union(enum) {...@@ -2142,7 +2133,7 @@ pub const LazyPath = union(enum) {
2142 .sub_path = try fs.path.resolve(arena, &.{ src.sub_path, sub_path }),2133 .sub_path = try fs.path.resolve(arena, &.{ src.sub_path, sub_path }),
2143 } },2134 } },
2144 .generated => |gen| .{ .generated = .{2135 .generated => |gen| .{ .generated = .{
2145 .file = gen.file,2136 .index = gen.index,
2146 .up = gen.up,2137 .up = gen.up,
2147 .sub_path = try fs.path.resolve(arena, &.{ gen.sub_path, sub_path }),2138 .sub_path = try fs.path.resolve(arena, &.{ gen.sub_path, sub_path }),
2148 } },2139 } },
lib/std/Build/Step/Compile.zig+3-3
...@@ -317,10 +317,10 @@ pub const HeaderInstallation = union(enum) {...@@ -317,10 +317,10 @@ pub const HeaderInstallation = union(enum) {
317 /// `exclude_extensions` takes precedence over `include_extensions`.317 /// `exclude_extensions` takes precedence over `include_extensions`.
318 include_extensions: ?[]const []const u8 = &.{".h"},318 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 {
321 return .{321 return .{
322 .exclude_extensions = b.dupeStrings(opts.exclude_extensions),322 .exclude_extensions = graph.dupeStrings(opts.exclude_extensions),
323 .include_extensions = if (opts.include_extensions) |incs| b.dupeStrings(incs) else null,323 .include_extensions = if (opts.include_extensions) |incs| graph.dupeStrings(incs) else null,
324 };324 };
325 }325 }
326 };326 };