std.Build: add --seed argument to randomize step dependencies spawning#16817
std.Build: add --seed argument to randomize step dependencies spawning#16817andrewrk merged 2 commits intoziglang:masterfrom
Conversation
andrewrk
left a comment
There was a problem hiding this comment.
Thanks for working on this!
Don't forget that part of the acceptance criteria is
make the
zig buildsubcommand always supply a random seed argument.
That's what Lines 271 to 273 in 615372a is about, am I missing something ? |
Yeah- specifically the Zig CLI should choose the seed, so that when the build fails, the command to reproduce the issue includes the In src/main.zig, in the |
lib/build_runner.zig
Outdated
| std.debug.print("Expected u32 after {s}\n\n", .{arg}); | ||
| usageAndErr(builder, false, stderr_stream); | ||
| }; | ||
| seed = std.fmt.parseUnsigned(u32, next_arg, 10) catch |err| { |
There was a problem hiding this comment.
| seed = std.fmt.parseUnsigned(u32, next_arg, 10) catch |err| { | |
| seed = std.fmt.parseUnsigned(u32, next_arg, 0) catch |err| { |
This will allow the user to use hexadecimal notation and a few others supported by parseUnsigned.
| }; | ||
| seed = std.fmt.parseUnsigned(u32, next_arg, 10) catch |err| { | ||
| std.debug.print("unable to parse seed '{s}' as u32: {s}", .{ next_arg, @errorName(err) }); | ||
| process.exit(1); |
There was a problem hiding this comment.
Please follow the pattern of error handling above and below for failure to parse user arguments. If you want to change all of them to not print the usage, please do that in a separate PR.
src/main.zig
Outdated
| const micros: u32 = @truncate(@as(u64, @bitCast(std.time.microTimestamp()))); | ||
| var seed: []const u8 = try std.fmt.allocPrint(arena, "{}", .{micros}); |
There was a problem hiding this comment.
Please use std.crypto.random.int(u32).
17413c6 to
5567781
Compare
help detect possibly hidden dependencies on the running order of steps, especially in -j1 mode
* support 0x prefixed hex code for CLI seed arguments * don't change the build summary; the printed CLI on build runner failure is sufficient * use `std.crypto.random` instead of system time for entropy
5567781 to
1020097
Compare
Closes #14940