commit 5c133c5765f3c4e80d46c35c104edc23d883c60e (tree)
parent f414370fba47e375cc240f3fcaa8fa36c7c0fed3
Author: Andrew Kelley <andrew@ziglang.org>
Date: Tue, 19 May 2026 16:29:49 -0700
Configuration: fix deserialization of LengthPrefixedList
don't assume only 1 field
Diffstat:
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/BRANCH_TODO b/BRANCH_TODO
@@ -1,4 +1,4 @@
-* WriteFile step failing when making langref
+* Run step getting wrong path_directory values
* double check when targets get resolved (should be at configure time)
* finish migrating the rest of the build steps
* pass overridden pkg-dir to maker
@@ -39,6 +39,7 @@
* WriteFiles: introduce Group
* re-examine the use case of adding file paths to Options steps
* extract the reusable Configure abstractions and reuse it for Zir etc
+* add the ability to delete files to UpdateSourceFiles
## Already Filed Followup Issues
* build system fmt step with check=false does not acquire a write lock on source files #35204
diff --git a/lib/std/Build/Configuration.zig b/lib/std/Build/Configuration.zig
@@ -2545,8 +2545,10 @@ pub const Storage = enum {
};
}
- /// The field contains a u32 length followed by that many items, each
- /// element bitcastable to u32.
+ /// The field contains a u32 length followed by that many items. Each
+ /// element needs well-defined memory layout but can otherwise be any
+ /// multiple of u32 length. The length is number of elements, not the
+ /// number of u32s.
pub fn LengthPrefixedList(comptime ElemArg: type) type {
return struct {
slice: []const Elem,
@@ -2759,19 +2761,21 @@ pub const Storage = enum {
},
.extended => @compileError("TODO"),
.length_prefixed_list => {
+ const n = @divExact(@sizeOf(Field.Elem), @sizeOf(u32));
const data_start = i.* + 1;
- const len = buffer[data_start - 1];
- defer i.* = data_start + len;
- return .{ .slice = @ptrCast(buffer[data_start..][0..len]) };
+ const buf_len = buffer[data_start - 1] * n;
+ defer i.* = data_start + buf_len;
+ return .{ .slice = @ptrCast(buffer[data_start..][0..buf_len]) };
},
.flag_length_prefixed_list => {
const flags = @field(container, @tagName(Field.flags));
const flag = @field(flags, @tagName(Field.flag));
if (!flag) return .{ .slice = &.{} };
+ const n = @divExact(@sizeOf(Field.Elem), @sizeOf(u32));
const data_start = i.* + 1;
- const len = buffer[data_start - 1];
- defer i.* = data_start + len;
- return .{ .slice = @ptrCast(buffer[data_start..][0..len]) };
+ const buf_len = buffer[data_start - 1] * n;
+ defer i.* = data_start + buf_len;
+ return .{ .slice = @ptrCast(buffer[data_start..][0..buf_len]) };
},
.flag_list => {
const flags = @field(container, @tagName(Field.flags));