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...@@ -906,7 +906,7 @@ pub fn standardOptimizeOption(self: *Build, options: StandardOptimizeOptionOptio
906 return self.option(906 return self.option(
907 std.builtin.Mode,907 std.builtin.Mode,
908 "optimize",908 "optimize",
909 "prioritize performance, safety, or binary size (-O flag)",909 "Prioritize performance, safety, or binary size (-O flag)",
910 ) orelse .Debug;910 ) orelse .Debug;
911 }911 }
912}912}
src/Compilation.zig+4-2
...@@ -1029,6 +1029,7 @@ pub const InitOptions = struct {...@@ -1029,6 +1029,7 @@ pub const InitOptions = struct {
1029 /// This is for stage1 and should be deleted upon completion of self-hosting.1029 /// This is for stage1 and should be deleted upon completion of self-hosting.
1030 color: Color = .auto,1030 color: Color = .auto,
1031 reference_trace: ?u32 = null,1031 reference_trace: ?u32 = null,
1032 error_tracing: ?bool = null,
1032 test_filter: ?[]const u8 = null,1033 test_filter: ?[]const u8 = null,
1033 test_name_prefix: ?[]const u8 = null,1034 test_name_prefix: ?[]const u8 = null,
1034 test_runner_path: ?[]const u8 = null,1035 test_runner_path: ?[]const u8 = null,
...@@ -1715,8 +1716,9 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1715,8 +1716,9 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
17151716
1716 const error_return_tracing = !strip and switch (options.optimize_mode) {1717 const error_return_tracing = !strip and switch (options.optimize_mode) {
1717 .Debug, .ReleaseSafe => (!options.target.isWasm() or options.target.os.tag == .emscripten) and1718 .Debug, .ReleaseSafe => (!options.target.isWasm() or options.target.os.tag == .emscripten) and
1718 !options.target.cpu.arch.isBpf(),1719 !options.target.cpu.arch.isBpf() and (options.error_tracing orelse true),
1719 .ReleaseFast, .ReleaseSmall => false,1720 .ReleaseFast => options.error_tracing orelse false,
1721 .ReleaseSmall => false,
1720 };1722 };
17211723
1722 // For resource management purposes.1724 // For resource management purposes.
src/main.zig+8
...@@ -432,6 +432,8 @@ const usage_build_generic =...@@ -432,6 +432,8 @@ const usage_build_generic =
432 \\ -fno-Clang Prevent using Clang as the C/C++ compilation backend432 \\ -fno-Clang Prevent using Clang as the C/C++ compilation backend
433 \\ -freference-trace[=num] How many lines of reference trace should be shown per compile error433 \\ -freference-trace[=num] How many lines of reference trace should be shown per compile error
434 \\ -fno-reference-trace Disable reference trace434 \\ -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
435 \\ -fsingle-threaded Code assumes there is only one thread437 \\ -fsingle-threaded Code assumes there is only one thread
436 \\ -fno-single-threaded Code may not assume there is only one thread438 \\ -fno-single-threaded Code may not assume there is only one thread
437 \\ -fbuiltin Enable implicit builtin knowledge of functions439 \\ -fbuiltin Enable implicit builtin knowledge of functions
...@@ -797,6 +799,7 @@ fn buildOutputType(...@@ -797,6 +799,7 @@ fn buildOutputType(
797 var headerpad_max_install_names: bool = false;799 var headerpad_max_install_names: bool = false;
798 var dead_strip_dylibs: bool = false;800 var dead_strip_dylibs: bool = false;
799 var reference_trace: ?u32 = null;801 var reference_trace: ?u32 = null;
802 var error_tracing: ?bool = null;
800 var pdb_out_path: ?[]const u8 = null;803 var pdb_out_path: ?[]const u8 = null;
801804
802 // e.g. -m3dnow or -mno-outline-atomics. They correspond to std.Target llvm cpu feature names.805 // e.g. -m3dnow or -mno-outline-atomics. They correspond to std.Target llvm cpu feature names.
...@@ -1218,6 +1221,10 @@ fn buildOutputType(...@@ -1218,6 +1221,10 @@ fn buildOutputType(
1218 };1221 };
1219 } else if (mem.eql(u8, arg, "-fno-reference-trace")) {1222 } else if (mem.eql(u8, arg, "-fno-reference-trace")) {
1220 reference_trace = null;1223 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;
1221 } else if (mem.eql(u8, arg, "-rdynamic")) {1228 } else if (mem.eql(u8, arg, "-rdynamic")) {
1222 rdynamic = true;1229 rdynamic = true;
1223 } else if (mem.eql(u8, arg, "-fsoname")) {1230 } else if (mem.eql(u8, arg, "-fsoname")) {
...@@ -3136,6 +3143,7 @@ fn buildOutputType(...@@ -3136,6 +3143,7 @@ fn buildOutputType(
3136 .headerpad_max_install_names = headerpad_max_install_names,3143 .headerpad_max_install_names = headerpad_max_install_names,
3137 .dead_strip_dylibs = dead_strip_dylibs,3144 .dead_strip_dylibs = dead_strip_dylibs,
3138 .reference_trace = reference_trace,3145 .reference_trace = reference_trace,
3146 .error_tracing = error_tracing,
3139 .pdb_out_path = pdb_out_path,3147 .pdb_out_path = pdb_out_path,
3140 }) catch |err| switch (err) {3148 }) catch |err| switch (err) {
3141 error.LibCUnavailable => {3149 error.LibCUnavailable => {