authorgravatar for 36753247+AdamGoertz@users.noreply.github.comAdamGoertz <36753247+AdamGoertz@users.noreply.github.com> 2023-02-13 09:23:13-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-02-13 16:23:13+02:00
logc8dc00086e6622f3f29d7e18deb92ea102cf1074
tree93e5cf2d530b22267897a6fe31a446e740dd803b
parent5894be94c8326dc1c32fd528f002911c04af69c9
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Add -ferror-tracing and -fno-error-tracing compile options


3 files changed, 13 insertions(+), 3 deletions(-)

lib/std/Build.zig+1-1
......@@ -906,7 +906,7 @@ pub fn standardOptimizeOption(self: *Build, options: StandardOptimizeOptionOptio
906906 return self.option(
907907 std.builtin.Mode,
908908 "optimize",
909 "prioritize performance, safety, or binary size (-O flag)",
909 "Prioritize performance, safety, or binary size (-O flag)",
910910 ) orelse .Debug;
911911 }
912912}
src/Compilation.zig+4-2
......@@ -1029,6 +1029,7 @@ pub const InitOptions = struct {
10291029 /// This is for stage1 and should be deleted upon completion of self-hosting.
10301030 color: Color = .auto,
10311031 reference_trace: ?u32 = null,
1032 error_tracing: ?bool = null,
10321033 test_filter: ?[]const u8 = null,
10331034 test_name_prefix: ?[]const u8 = null,
10341035 test_runner_path: ?[]const u8 = null,
......@@ -1715,8 +1716,9 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
17151716
17161717 const error_return_tracing = !strip and switch (options.optimize_mode) {
17171718 .Debug, .ReleaseSafe => (!options.target.isWasm() or options.target.os.tag == .emscripten) and
1718 !options.target.cpu.arch.isBpf(),
1719 .ReleaseFast, .ReleaseSmall => false,
1719 !options.target.cpu.arch.isBpf() and (options.error_tracing orelse true),
1720 .ReleaseFast => options.error_tracing orelse false,
1721 .ReleaseSmall => false,
17201722 };
17211723
17221724 // For resource management purposes.
src/main.zig+8
......@@ -432,6 +432,8 @@ const usage_build_generic =
432432 \\ -fno-Clang Prevent using Clang as the C/C++ compilation backend
433433 \\ -freference-trace[=num] How many lines of reference trace should be shown per compile error
434434 \\ -fno-reference-trace Disable reference trace
435 \\ -ferror-tracing Enable error tracing in ReleaseFast mode
436 \\ -fno-error-tracing Disable error tracing in Debug and ReleaseSafe mode
435437 \\ -fsingle-threaded Code assumes there is only one thread
436438 \\ -fno-single-threaded Code may not assume there is only one thread
437439 \\ -fbuiltin Enable implicit builtin knowledge of functions
......@@ -797,6 +799,7 @@ fn buildOutputType(
797799 var headerpad_max_install_names: bool = false;
798800 var dead_strip_dylibs: bool = false;
799801 var reference_trace: ?u32 = null;
802 var error_tracing: ?bool = null;
800803 var pdb_out_path: ?[]const u8 = null;
801804
802805 // e.g. -m3dnow or -mno-outline-atomics. They correspond to std.Target llvm cpu feature names.
......@@ -1218,6 +1221,10 @@ fn buildOutputType(
12181221 };
12191222 } else if (mem.eql(u8, arg, "-fno-reference-trace")) {
12201223 reference_trace = null;
1224 } else if (mem.eql(u8, arg, "-ferror-tracing")) {
1225 error_tracing = true;
1226 } else if (mem.eql(u8, arg, "-fno-error-tracing")) {
1227 error_tracing = false;
12211228 } else if (mem.eql(u8, arg, "-rdynamic")) {
12221229 rdynamic = true;
12231230 } else if (mem.eql(u8, arg, "-fsoname")) {
......@@ -3136,6 +3143,7 @@ fn buildOutputType(
31363143 .headerpad_max_install_names = headerpad_max_install_names,
31373144 .dead_strip_dylibs = dead_strip_dylibs,
31383145 .reference_trace = reference_trace,
3146 .error_tracing = error_tracing,
31393147 .pdb_out_path = pdb_out_path,
31403148 }) catch |err| switch (err) {
31413149 error.LibCUnavailable => {