-
-
Notifications
You must be signed in to change notification settings - Fork 3k
std.Build: add --seed argument to randomize step dependencies spawning #16817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
Don't forget that part of the acceptance criteria is
make the
zig build
subcommand 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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