authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-02-17 14:28:19-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-02-17 14:30:12-07:00
log5aa35f62c391d34b92445388c5d645d87f9c4621
treee04419c70cc8bfd5079420ba7b6b73c85cc02c41
parent6235afc63207bae564725adec202fc2e7a3ba930

Revert "reduce build error noise"

This reverts commit baead472d7641bdd96130354bafadc1fb1ed223b. Let's go through the proposal process on this one. I want to push back on this. My position is that, at the very least, a full trace of command lines of sub-processes should be printed on failure, with the exception of opt-in flags such as `--prominent-compile-errors`.

5 files changed, 1 insertions(+), 58 deletions(-)

lib/std/build.zig-14
...@@ -3438,17 +3438,3 @@ test "LibExeObjStep.addPackage" {...@@ -3438,17 +3438,3 @@ test "LibExeObjStep.addPackage" {
3438 const dupe = exe.packages.items[0];3438 const dupe = exe.packages.items[0];
3439 try std.testing.expectEqualStrings(pkg_top.name, dupe.name);3439 try std.testing.expectEqualStrings(pkg_top.name, dupe.name);
3440}3440}
3441
3442/// This exit code from either "zig build" or the build_runner indicates
3443/// the "full reason" for a build failure has already been reported to stderr.
3444/// This will prevent 'zig` from piling on errors to the ones reported by the
3445/// build_runner.
3446pub const fail_fully_reported_exit_code = 0x3f;
3447
3448/// Print an error message to stderr and exit with a special exit
3449/// code that notifies the invoking process that the build error
3450/// has already been fully reported to stderr.
3451pub fn fatalFullReport(comptime error_fmt: []const u8, args: anytype) noreturn {
3452 std.log.err(error_fmt, args);
3453 std.os.exit(fail_fully_reported_exit_code);
3454}
src/main.zig+1-3
...@@ -3616,9 +3616,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi...@@ -3616,9 +3616,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
3616 .Exited => |code| {3616 .Exited => |code| {
3617 if (code == 0) return cleanExit();3617 if (code == 0) return cleanExit();
36183618
3619 if (code == std.build.fail_fully_reported_exit_code) {3619 if (prominent_compile_errors) {
3620 process.exit(std.build.fail_fully_reported_exit_code);
3621 } else if (prominent_compile_errors) {
3622 fatal("the build command failed with exit code {d}", .{code});3620 fatal("the build command failed with exit code {d}", .{code});
3623 } else {3621 } else {
3624 const cmd = try std.mem.join(arena, " ", child_argv);3622 const cmd = try std.mem.join(arena, " ", child_argv);
test/standalone.zig-1
...@@ -49,7 +49,6 @@ pub fn addCases(cases: *tests.StandaloneContext) void {...@@ -49,7 +49,6 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
49 cases.addBuildFile("test/standalone/issue_7030/build.zig", .{});49 cases.addBuildFile("test/standalone/issue_7030/build.zig", .{});
50 cases.addBuildFile("test/standalone/install_raw_hex/build.zig", .{});50 cases.addBuildFile("test/standalone/install_raw_hex/build.zig", .{});
51 cases.addBuildFile("test/standalone/issue_9812/build.zig", .{});51 cases.addBuildFile("test/standalone/issue_9812/build.zig", .{});
52 cases.addBuildFile("test/standalone/fail_full_report/build.zig", .{});
53 if (builtin.os.tag != .wasi) {52 if (builtin.os.tag != .wasi) {
54 cases.addBuildFile("test/standalone/load_dynamic_library/build.zig", .{});53 cases.addBuildFile("test/standalone/load_dynamic_library/build.zig", .{});
55 }54 }
test/standalone/fail_full_report/build.zig deleted-32
...@@ -1,32 +0,0 @@
1const std = @import("std");
2const Builder = std.build.Builder;
3
4pub fn build(b: *Builder) !void {
5 const test_step = b.step("test", "The test");
6
7 {
8 const run_step = b.addSystemCommand(&[_][]const u8{
9 b.zig_exe,
10 "build",
11 "--build-file",
12 "build2.zig",
13 });
14 run_step.stdout_action = .{ .expect_exact = "" };
15 test_step.dependOn(&run_step.step);
16 }
17
18 {
19 const run_step = b.addSystemCommand(&[_][]const u8{
20 b.zig_exe,
21 "build",
22 "--build-file",
23 "build2.zig",
24 "-Dbadoption",
25 });
26 run_step.stderr_action = .{ .expect_exact = "error: got a bad build option!\n" };
27 run_step.expected_exit_code = std.build.fail_fully_reported_exit_code;
28 test_step.dependOn(&run_step.step);
29 }
30
31 b.default_step.dependOn(test_step);
32}
test/standalone/fail_full_report/build2.zig deleted-8
...@@ -1,8 +0,0 @@
1const std = @import("std");
2const Builder = std.build.Builder;
3
4pub fn build(b: *Builder) !void {
5 const bad_option = if (b.option(bool, "badoption", "Use this to emulator a bad build option")) |o| o else false;
6 if (bad_option)
7 std.build.fatalFullReport("got a bad build option!", .{});
8}