From 5aa35f62c391d34b92445388c5d645d87f9c4621 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 17 Feb 2022 14:28:19 -0700 Subject: [PATCH] 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`. --- lib/std/build.zig | 14 --------- src/main.zig | 4 +-- test/standalone.zig | 1 - test/standalone/fail_full_report/build.zig | 32 --------------------- test/standalone/fail_full_report/build2.zig | 8 ------ 5 files changed, 1 insertion(+), 58 deletions(-) delete mode 100644 test/standalone/fail_full_report/build.zig delete mode 100644 test/standalone/fail_full_report/build2.zig diff --git a/lib/std/build.zig b/lib/std/build.zig index df8bad52da..fcaa115ccb 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -3438,17 +3438,3 @@ test "LibExeObjStep.addPackage" { const dupe = exe.packages.items[0]; try std.testing.expectEqualStrings(pkg_top.name, dupe.name); } - -/// This exit code from either "zig build" or the build_runner indicates -/// the "full reason" for a build failure has already been reported to stderr. -/// This will prevent 'zig` from piling on errors to the ones reported by the -/// build_runner. -pub const fail_fully_reported_exit_code = 0x3f; - -/// Print an error message to stderr and exit with a special exit -/// code that notifies the invoking process that the build error -/// has already been fully reported to stderr. -pub fn fatalFullReport(comptime error_fmt: []const u8, args: anytype) noreturn { - std.log.err(error_fmt, args); - std.os.exit(fail_fully_reported_exit_code); -} diff --git a/src/main.zig b/src/main.zig index 42e8f339f1..05afc2b166 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3616,9 +3616,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi .Exited => |code| { if (code == 0) return cleanExit(); - if (code == std.build.fail_fully_reported_exit_code) { - process.exit(std.build.fail_fully_reported_exit_code); - } else if (prominent_compile_errors) { + if (prominent_compile_errors) { fatal("the build command failed with exit code {d}", .{code}); } else { const cmd = try std.mem.join(arena, " ", child_argv); diff --git a/test/standalone.zig b/test/standalone.zig index b731463975..6df3387018 100644 --- a/test/standalone.zig +++ b/test/standalone.zig @@ -49,7 +49,6 @@ pub fn addCases(cases: *tests.StandaloneContext) void { cases.addBuildFile("test/standalone/issue_7030/build.zig", .{}); cases.addBuildFile("test/standalone/install_raw_hex/build.zig", .{}); cases.addBuildFile("test/standalone/issue_9812/build.zig", .{}); - cases.addBuildFile("test/standalone/fail_full_report/build.zig", .{}); if (builtin.os.tag != .wasi) { cases.addBuildFile("test/standalone/load_dynamic_library/build.zig", .{}); } diff --git a/test/standalone/fail_full_report/build.zig b/test/standalone/fail_full_report/build.zig deleted file mode 100644 index 75edfca835..0000000000 --- a/test/standalone/fail_full_report/build.zig +++ /dev/null @@ -1,32 +0,0 @@ -const std = @import("std"); -const Builder = std.build.Builder; - -pub fn build(b: *Builder) !void { - const test_step = b.step("test", "The test"); - - { - const run_step = b.addSystemCommand(&[_][]const u8{ - b.zig_exe, - "build", - "--build-file", - "build2.zig", - }); - run_step.stdout_action = .{ .expect_exact = "" }; - test_step.dependOn(&run_step.step); - } - - { - const run_step = b.addSystemCommand(&[_][]const u8{ - b.zig_exe, - "build", - "--build-file", - "build2.zig", - "-Dbadoption", - }); - run_step.stderr_action = .{ .expect_exact = "error: got a bad build option!\n" }; - run_step.expected_exit_code = std.build.fail_fully_reported_exit_code; - test_step.dependOn(&run_step.step); - } - - b.default_step.dependOn(test_step); -} diff --git a/test/standalone/fail_full_report/build2.zig b/test/standalone/fail_full_report/build2.zig deleted file mode 100644 index 5b0f58a827..0000000000 --- a/test/standalone/fail_full_report/build2.zig +++ /dev/null @@ -1,8 +0,0 @@ -const std = @import("std"); -const Builder = std.build.Builder; - -pub fn build(b: *Builder) !void { - const bad_option = if (b.option(bool, "badoption", "Use this to emulator a bad build option")) |o| o else false; - if (bad_option) - std.build.fatalFullReport("got a bad build option!", .{}); -}