Skip to content
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

introduce a new tool for testing incremental compilation #20688

Merged
merged 7 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/std/process.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2032,3 +2032,9 @@ pub fn createWindowsEnvBlock(allocator: mem.Allocator, env_map: *const EnvMap) !
i += 1;
return try allocator.realloc(result, i);
}

/// Logs an error and then terminates the process with exit code 1.
pub fn fatal(comptime format: []const u8, format_arguments: anytype) noreturn {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this move. Wouldn't this be better on std.log itself? That is what Go does if that counts for anything https://pkg.go.dev/log#Fatal

Copy link
Member

@mlugg mlugg Jul 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What another language does is entirely irrelevant, especially one as different as Go. Why would this live in std.log? Just because it happens to use that API doesn't mean it's part of it. std.process seems like an entirely reasonable place for this to live given its other task of terminating the process with exit code 1.

Copy link
Contributor

@sno2 sno2 Jul 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go and Zig both allow creating custom loggers. This is important because I would like to be able to call fatal on my custom logger without duplicating this function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if std.log.fatal was going to exist, i would still expect this one to exist and for std.log.fatal to call it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it belongs in process since it exits the process.

std.log.err(format, format_arguments);
exit(1);
}
6 changes: 2 additions & 4 deletions lib/std/zig.zig
Original file line number Diff line number Diff line change
Expand Up @@ -667,10 +667,8 @@ pub fn parseTargetQueryOrReportFatalError(
};
}

pub fn fatal(comptime format: []const u8, args: anytype) noreturn {
std.log.err(format, args);
std.process.exit(1);
}
/// Deprecated; see `std.process.fatal`.
pub const fatal = std.process.fatal;

/// Collects all the environment variables that Zig could possibly inspect, so
/// that we can do reflection on this and print them with `zig env`.
Expand Down