zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit c57bf9904396c365191d25b9ce6410bb47daa96a (tree)
parent 364a1400ffb7c88539a34d86c83245478b096b84
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Thu, 30 Apr 2026 21:19:04 -0700

Configuration: implement Storage.UnionList.tag

Diffstat:
MBRANCH_TODO | 4+++-
Mlib/compiler/Maker/ScannedConfig.zig | 9+++++++++
Mlib/compiler/configurer.zig | 2--
Mlib/std/Build/Configuration.zig | 9++++-----
4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/BRANCH_TODO b/BRANCH_TODO @@ -2,7 +2,6 @@ * inspect b4ffb402c082605c4b324e88120306fc8fb3cf32 diff and apply changes as needed (merge conflict) * make zig-pkg path root configurable in maker (make sure --system still works) * eliminate calls to getPath, getPath2, getPath3 -* [build system compile step data races with getGraph function](https://codeberg.org/ziglang/zig/issues/31397) * test lazyImport * solve the TODOs added in this branch * get zig tests passing @@ -17,6 +16,7 @@ * refactor with DefaultingEnum * implement {q} or delete {q} uses +* make the generated dependencies.zig be dependencies.zon and don't put absolute paths in there ## Followup Issues * reduce the size of Maker.Step.Extended (make Run smaller) probably by using an arena per make @@ -49,3 +49,5 @@ run_cmd.addPassthruArgs(); This removes a capability from build scripts since they can no longer observe those arguments. In exchange, it means that when changing those arguments, build scripts no longer must be rebuilt from source. + +closes #31397 diff --git a/lib/compiler/Maker/ScannedConfig.zig b/lib/compiler/Maker/ScannedConfig.zig @@ -79,6 +79,15 @@ fn printValue(sc: *const ScannedConfig, s: *Serializer, comptime Field: type, fi try printStruct(sc, &sub_struct, Configuration.Step.Run.Arg, field_value.get(c)); try sub_struct.end(); }, + Configuration.LazyPath.Index => { + switch (field_value.get(c)) { + inline else => |u| { + var sub_struct = try s.beginStruct(.{}); + try printStruct(sc, &sub_struct, @TypeOf(u), u); + try sub_struct.end(); + }, + } + }, else => switch (@typeInfo(Field)) { .int => try s.int(field_value), .pointer => |info| switch (info.size) { diff --git a/lib/compiler/configurer.zig b/lib/compiler/configurer.zig @@ -164,7 +164,6 @@ const Serialize = struct { .src_path => |src_path| i: { const sub_path = try wc.addString(src_path.sub_path); break :i try wc.addExtra(@as(Configuration.LazyPath.SourcePath, .{ - .flags = .{}, .owner = try s.builderToPackage(src_path.owner), .sub_path = sub_path, })); @@ -187,7 +186,6 @@ const Serialize = struct { .dependency => |dependency| i: { const sub_path = try wc.addString(dependency.sub_path); break :i try wc.addExtra(@as(Configuration.LazyPath.SourcePath, .{ - .flags = .{}, .owner = try s.builderToPackage(dependency.dependency.builder), .sub_path = sub_path, })); diff --git a/lib/std/Build/Configuration.zig b/lib/std/Build/Configuration.zig @@ -1173,7 +1173,7 @@ pub const LazyPath = union(@This().Tag) { }; pub const SourcePath = struct { - flags: @This().Flags, + flags: @This().Flags = .{}, owner: Package.Index, sub_path: String, @@ -2318,10 +2318,9 @@ pub const Storage = enum { /// Valid to call only when deserializing. pub fn tag(this: *const @This(), extra: []const u32, i: usize) Tag { - _ = this; - _ = extra; - _ = i; - @panic("TODO implement UnionList.tag"); + const start = @intFromPtr(this.data); + const meta_start = start - (this.len * @bitSizeOf(Meta) + 31) / 32; + return loadBits(u32, extra[meta_start..], i * @bitSizeOf(Meta), Meta).tag; } fn extraLen(len: usize) usize {