Fix struct size assertion in Bake dev server (#22057)

Followup to #22049: I'm pretty sure “platform-specific padding” on
Windows is a hallucination. I think this is due to ReleaseSafe adding
tags to untagged unions.

(For internal tracking: fixes STAB-1057)
This commit is contained in:
taylor.fish
2025-08-22 17:27:53 -07:00
committed by GitHub
parent 92b38fdf80
commit d7bf8210eb
2 changed files with 4 additions and 8 deletions

View File

@@ -182,14 +182,9 @@ pub fn IncrementalGraph(side: bake.Side) type {
};
comptime {
if (!Environment.ci_assert) {
// On Windows, struct padding can cause size to be larger than expected
// Allow for platform-specific padding while ensuring reasonable bounds
const expected_size = @sizeOf(u64) * 5; // 40 bytes
const actual_size = @sizeOf(@This());
if (actual_size < expected_size or actual_size > expected_size + 16) {
@compileError(std.fmt.comptimePrint("Struct size {} is outside expected range [{}, {}]", .{ actual_size, expected_size, expected_size + 16 }));
}
// Debug and ReleaseSafe builds add a tag to untagged unions
if (!Environment.allow_assert) {
bun.assert_eql(@sizeOf(@This()), @sizeOf(u64) * 5);
bun.assert_eql(@alignOf(@This()), @alignOf([*]u8));
}
}

View File

@@ -80,6 +80,7 @@ pub fn quotedContents(self: *const @This()) []u8 {
}
comptime {
// `ci_assert` builds add a `safety.ThreadLock`
if (!Environment.ci_assert) {
assert_eql(@sizeOf(@This()), @sizeOf(usize) * 7);
assert_eql(@alignOf(@This()), @alignOf(usize));