authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-14 19:49:53-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:19-07:00
log2596f5d92593a5f7dad21d9a54f2d08f33639432
treee44cd8e057f87b736a915550393bd023f151b771
parent7e7d5dc958b08dc0f671cd1b119cd831fc877d16

update bin_file.options references in Sema

mainly pertaining to error return tracing

5 files changed, 66 insertions(+), 45 deletions(-)

src/Compilation/Config.zig+22
...@@ -9,6 +9,10 @@ link_libunwind: bool,...@@ -9,6 +9,10 @@ link_libunwind: bool,
9any_unwind_tables: bool,9any_unwind_tables: bool,
10any_c_source_files: bool,10any_c_source_files: bool,
11any_non_single_threaded: bool,11any_non_single_threaded: bool,
12/// This is true if any Module has error_tracing set to true. Function types
13/// and function calling convention depend on this global value, however, other
14/// kinds of error tracing are omitted depending on the per-Module setting.
15any_error_tracing: bool,
12pie: bool,16pie: bool,
13/// If this is true then linker code is responsible for making an LLVM IR17/// If this is true then linker code is responsible for making an LLVM IR
14/// Module, outputting it to an object file, and then linking that together18/// Module, outputting it to an object file, and then linking that together
...@@ -34,6 +38,8 @@ is_test: bool,...@@ -34,6 +38,8 @@ is_test: bool,
34test_evented_io: bool,38test_evented_io: bool,
35entry: ?[]const u8,39entry: ?[]const u8,
36debug_format: DebugFormat,40debug_format: DebugFormat,
41root_strip: bool,
42root_error_tracing: bool,
3743
38pub const CFrontend = enum { clang, aro };44pub const CFrontend = enum { clang, aro };
3945
...@@ -51,6 +57,7 @@ pub const Options = struct {...@@ -51,6 +57,7 @@ pub const Options = struct {
51 emit_bin: bool,57 emit_bin: bool,
52 root_optimize_mode: ?std.builtin.OptimizeMode = null,58 root_optimize_mode: ?std.builtin.OptimizeMode = null,
53 root_strip: ?bool = null,59 root_strip: ?bool = null,
60 root_error_tracing: ?bool = null,
54 link_mode: ?std.builtin.LinkMode = null,61 link_mode: ?std.builtin.LinkMode = null,
55 ensure_libc_on_non_freestanding: bool = false,62 ensure_libc_on_non_freestanding: bool = false,
56 ensure_libcpp_on_non_freestanding: bool = false,63 ensure_libcpp_on_non_freestanding: bool = false,
...@@ -60,6 +67,7 @@ pub const Options = struct {...@@ -60,6 +67,7 @@ pub const Options = struct {
60 any_dyn_libs: bool = false,67 any_dyn_libs: bool = false,
61 any_c_source_files: bool = false,68 any_c_source_files: bool = false,
62 any_non_stripped: bool = false,69 any_non_stripped: bool = false,
70 any_error_tracing: bool = false,
63 emit_llvm_ir: bool = false,71 emit_llvm_ir: bool = false,
64 emit_llvm_bc: bool = false,72 emit_llvm_bc: bool = false,
65 link_libc: ?bool = null,73 link_libc: ?bool = null,
...@@ -395,6 +403,17 @@ pub fn resolve(options: Options) !Config {...@@ -395,6 +403,17 @@ pub fn resolve(options: Options) !Config {
395 };403 };
396 };404 };
397405
406 const root_error_tracing = b: {
407 if (options.root_error_tracing) |x| break :b x;
408 if (root_strip) break :b false;
409 break :b switch (root_optimize_mode) {
410 .Debug => true,
411 .ReleaseSafe, .ReleaseFast, .ReleaseSmall => false,
412 };
413 };
414
415 const any_error_tracing = root_error_tracing or options.any_error_tracing;
416
398 return .{417 return .{
399 .output_mode = options.output_mode,418 .output_mode = options.output_mode,
400 .have_zcu = options.have_zcu,419 .have_zcu = options.have_zcu,
...@@ -407,6 +426,8 @@ pub fn resolve(options: Options) !Config {...@@ -407,6 +426,8 @@ pub fn resolve(options: Options) !Config {
407 .any_unwind_tables = any_unwind_tables,426 .any_unwind_tables = any_unwind_tables,
408 .any_c_source_files = options.any_c_source_files,427 .any_c_source_files = options.any_c_source_files,
409 .any_non_single_threaded = options.any_non_single_threaded,428 .any_non_single_threaded = options.any_non_single_threaded,
429 .any_error_tracing = any_error_tracing,
430 .root_error_tracing = root_error_tracing,
410 .pie = pie,431 .pie = pie,
411 .lto = lto,432 .lto = lto,
412 .import_memory = import_memory,433 .import_memory = import_memory,
...@@ -419,6 +440,7 @@ pub fn resolve(options: Options) !Config {...@@ -419,6 +440,7 @@ pub fn resolve(options: Options) !Config {
419 .entry = entry,440 .entry = entry,
420 .wasi_exec_model = wasi_exec_model,441 .wasi_exec_model = wasi_exec_model,
421 .debug_format = debug_format,442 .debug_format = debug_format,
443 .root_strip = root_strip,
422 };444 };
423}445}
424446
src/Package/Module.zig+2-8
...@@ -114,9 +114,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module {...@@ -114,9 +114,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module {
114 const strip = b: {114 const strip = b: {
115 if (options.inherited.strip) |x| break :b x;115 if (options.inherited.strip) |x| break :b x;
116 if (options.parent) |p| break :b p.strip;116 if (options.parent) |p| break :b p.strip;
117 if (optimize_mode == .ReleaseSmall) break :b true;117 break :b options.global.root_strip;
118 if (!target_util.hasDebugInfo(target)) break :b true;
119 break :b false;
120 };118 };
121119
122 const valgrind = b: {120 const valgrind = b: {
...@@ -156,11 +154,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module {...@@ -156,11 +154,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module {
156 const error_tracing = b: {154 const error_tracing = b: {
157 if (options.inherited.error_tracing) |x| break :b x;155 if (options.inherited.error_tracing) |x| break :b x;
158 if (options.parent) |p| break :b p.error_tracing;156 if (options.parent) |p| break :b p.error_tracing;
159 if (strip) break :b false;157 break :b options.global.root_error_tracing;
160 break :b switch (optimize_mode) {
161 .Debug => true,
162 .ReleaseSafe, .ReleaseFast, .ReleaseSmall => false,
163 };
164 };158 };
165159
166 const pic = b: {160 const pic = b: {
src/Sema.zig+32-32
...@@ -1329,13 +1329,13 @@ fn analyzeBodyInner(...@@ -1329,13 +1329,13 @@ fn analyzeBodyInner(
1329 },1329 },
1330 .dbg_block_begin => {1330 .dbg_block_begin => {
1331 dbg_block_begins += 1;1331 dbg_block_begins += 1;
1332 try sema.zirDbgBlockBegin(block);1332 try zirDbgBlockBegin(block);
1333 i += 1;1333 i += 1;
1334 continue;1334 continue;
1335 },1335 },
1336 .dbg_block_end => {1336 .dbg_block_end => {
1337 dbg_block_begins -= 1;1337 dbg_block_begins -= 1;
1338 try sema.zirDbgBlockEnd(block);1338 try zirDbgBlockEnd(block);
1339 i += 1;1339 i += 1;
1340 continue;1340 continue;
1341 },1341 },
...@@ -1830,17 +1830,17 @@ fn analyzeBodyInner(...@@ -1830,17 +1830,17 @@ fn analyzeBodyInner(
1830 };1830 };
18311831
1832 // balance out dbg_block_begins in case of early noreturn1832 // balance out dbg_block_begins in case of early noreturn
1833 const noreturn_inst = block.instructions.popOrNull();1833 if (!block.is_comptime and !block.ownerModule().strip) {
1834 while (dbg_block_begins > 0) {1834 const noreturn_inst = block.instructions.popOrNull();
1835 dbg_block_begins -= 1;1835 while (dbg_block_begins > 0) {
1836 if (block.is_comptime or mod.comp.bin_file.options.strip) continue;1836 dbg_block_begins -= 1;
18371837 _ = try block.addInst(.{
1838 _ = try block.addInst(.{1838 .tag = .dbg_block_end,
1839 .tag = .dbg_block_end,1839 .data = undefined,
1840 .data = undefined,1840 });
1841 });1841 }
1842 if (noreturn_inst) |some| try block.instructions.append(sema.gpa, some);
1842 }1843 }
1843 if (noreturn_inst) |some| try block.instructions.append(sema.gpa, some);
18441844
1845 // We may have overwritten the capture scope due to a `repeat` instruction where1845 // We may have overwritten the capture scope due to a `repeat` instruction where
1846 // the body had a capture; restore it now.1846 // the body had a capture; restore it now.
...@@ -6272,7 +6272,7 @@ fn zirDbgStmt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi...@@ -6272,7 +6272,7 @@ fn zirDbgStmt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi
6272 // ZIR code that possibly will need to generate runtime code. So error messages6272 // ZIR code that possibly will need to generate runtime code. So error messages
6273 // and other source locations must not rely on sema.src being set from dbg_stmt6273 // and other source locations must not rely on sema.src being set from dbg_stmt
6274 // instructions.6274 // instructions.
6275 if (block.is_comptime or sema.mod.comp.bin_file.options.strip) return;6275 if (block.is_comptime or block.ownerModule().strip) return;
62766276
6277 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].dbg_stmt;6277 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].dbg_stmt;
62786278
...@@ -6297,8 +6297,8 @@ fn zirDbgStmt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi...@@ -6297,8 +6297,8 @@ fn zirDbgStmt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi
6297 });6297 });
6298}6298}
62996299
6300fn zirDbgBlockBegin(sema: *Sema, block: *Block) CompileError!void {6300fn zirDbgBlockBegin(block: *Block) CompileError!void {
6301 if (block.is_comptime or sema.mod.comp.bin_file.options.strip) return;6301 if (block.is_comptime or block.ownerModule().strip) return;
63026302
6303 _ = try block.addInst(.{6303 _ = try block.addInst(.{
6304 .tag = .dbg_block_begin,6304 .tag = .dbg_block_begin,
...@@ -6306,8 +6306,8 @@ fn zirDbgBlockBegin(sema: *Sema, block: *Block) CompileError!void {...@@ -6306,8 +6306,8 @@ fn zirDbgBlockBegin(sema: *Sema, block: *Block) CompileError!void {
6306 });6306 });
6307}6307}
63086308
6309fn zirDbgBlockEnd(sema: *Sema, block: *Block) CompileError!void {6309fn zirDbgBlockEnd(block: *Block) CompileError!void {
6310 if (block.is_comptime or sema.mod.comp.bin_file.options.strip) return;6310 if (block.is_comptime or block.ownerModule().strip) return;
63116311
6312 _ = try block.addInst(.{6312 _ = try block.addInst(.{
6313 .tag = .dbg_block_end,6313 .tag = .dbg_block_end,
...@@ -6321,7 +6321,7 @@ fn zirDbgVar(...@@ -6321,7 +6321,7 @@ fn zirDbgVar(
6321 inst: Zir.Inst.Index,6321 inst: Zir.Inst.Index,
6322 air_tag: Air.Inst.Tag,6322 air_tag: Air.Inst.Tag,
6323) CompileError!void {6323) CompileError!void {
6324 if (block.is_comptime or sema.mod.comp.bin_file.options.strip) return;6324 if (block.is_comptime or block.ownerModule().strip) return;
63256325
6326 const str_op = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_op;6326 const str_op = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_op;
6327 const operand = try sema.resolveInst(str_op.operand);6327 const operand = try sema.resolveInst(str_op.operand);
...@@ -6519,7 +6519,7 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref...@@ -6519,7 +6519,7 @@ pub fn analyzeSaveErrRetIndex(sema: *Sema, block: *Block) SemaError!Air.Inst.Ref
6519 const src = sema.src;6519 const src = sema.src;
65206520
6521 if (!mod.backendSupportsFeature(.error_return_trace)) return .none;6521 if (!mod.backendSupportsFeature(.error_return_trace)) return .none;
6522 if (!mod.comp.bin_file.options.error_return_tracing) return .none;6522 if (!block.ownerModule().error_tracing) return .none;
65236523
6524 if (block.is_comptime)6524 if (block.is_comptime)
6525 return .none;6525 return .none;
...@@ -6703,7 +6703,7 @@ fn zirCall(...@@ -6703,7 +6703,7 @@ fn zirCall(
6703 input_is_error = false;6703 input_is_error = false;
6704 }6704 }
67056705
6706 if (mod.backendSupportsFeature(.error_return_trace) and mod.comp.bin_file.options.error_return_tracing and6706 if (mod.backendSupportsFeature(.error_return_trace) and block.ownerModule().error_tracing and
6707 !block.is_comptime and !block.is_typeof and (input_is_error or pop_error_return_trace))6707 !block.is_comptime and !block.is_typeof and (input_is_error or pop_error_return_trace))
6708 {6708 {
6709 const return_ty = sema.typeOf(call_inst);6709 const return_ty = sema.typeOf(call_inst);
...@@ -7456,7 +7456,7 @@ fn analyzeCall(...@@ -7456,7 +7456,7 @@ fn analyzeCall(
7456 new_fn_info.return_type = sema.fn_ret_ty.toIntern();7456 new_fn_info.return_type = sema.fn_ret_ty.toIntern();
7457 const new_func_resolved_ty = try mod.funcType(new_fn_info);7457 const new_func_resolved_ty = try mod.funcType(new_fn_info);
7458 if (!is_comptime_call and !block.is_typeof) {7458 if (!is_comptime_call and !block.is_typeof) {
7459 try sema.emitDbgInline(block, prev_fn_index, module_fn_index, new_func_resolved_ty, .dbg_inline_begin);7459 try emitDbgInline(block, prev_fn_index, module_fn_index, new_func_resolved_ty, .dbg_inline_begin);
74607460
7461 const zir_tags = sema.code.instructions.items(.tag);7461 const zir_tags = sema.code.instructions.items(.tag);
7462 for (fn_info.param_body) |param| switch (zir_tags[@intFromEnum(param)]) {7462 for (fn_info.param_body) |param| switch (zir_tags[@intFromEnum(param)]) {
...@@ -7494,7 +7494,7 @@ fn analyzeCall(...@@ -7494,7 +7494,7 @@ fn analyzeCall(
7494 if (!is_comptime_call and !block.is_typeof and7494 if (!is_comptime_call and !block.is_typeof and
7495 sema.typeOf(result).zigTypeTag(mod) != .NoReturn)7495 sema.typeOf(result).zigTypeTag(mod) != .NoReturn)
7496 {7496 {
7497 try sema.emitDbgInline(7497 try emitDbgInline(
7498 block,7498 block,
7499 module_fn_index,7499 module_fn_index,
7500 prev_fn_index,7500 prev_fn_index,
...@@ -8067,15 +8067,13 @@ fn resolveTupleLazyValues(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type)...@@ -8067,15 +8067,13 @@ fn resolveTupleLazyValues(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type)
8067}8067}
80688068
8069fn emitDbgInline(8069fn emitDbgInline(
8070 sema: *Sema,
8071 block: *Block,8070 block: *Block,
8072 old_func: InternPool.Index,8071 old_func: InternPool.Index,
8073 new_func: InternPool.Index,8072 new_func: InternPool.Index,
8074 new_func_ty: Type,8073 new_func_ty: Type,
8075 tag: Air.Inst.Tag,8074 tag: Air.Inst.Tag,
8076) CompileError!void {8075) CompileError!void {
8077 const mod = sema.mod;8076 if (block.ownerModule().strip) return;
8078 if (mod.comp.bin_file.options.strip) return;
80798077
8080 // Recursive inline call; no dbg_inline needed.8078 // Recursive inline call; no dbg_inline needed.
8081 if (old_func == new_func) return;8079 if (old_func == new_func) return;
...@@ -9109,7 +9107,7 @@ fn handleExternLibName(...@@ -9109,7 +9107,7 @@ fn handleExternLibName(
9109 );9107 );
9110 break :blk;9108 break :blk;
9111 }9109 }
9112 if (!target.isWasm() and !comp.bin_file.options.pic) {9110 if (!target.isWasm() and !block.ownerModule().pic) {
9113 return sema.fail(9111 return sema.fail(
9114 block,9112 block,
9115 src_loc,9113 src_loc,
...@@ -18738,16 +18736,16 @@ fn wantErrorReturnTracing(sema: *Sema, fn_ret_ty: Type) bool {...@@ -18738,16 +18736,16 @@ fn wantErrorReturnTracing(sema: *Sema, fn_ret_ty: Type) bool {
18738 const mod = sema.mod;18736 const mod = sema.mod;
18739 if (!mod.backendSupportsFeature(.error_return_trace)) return false;18737 if (!mod.backendSupportsFeature(.error_return_trace)) return false;
1874018738
18741 return fn_ret_ty.isError(mod) and18739 return fn_ret_ty.isError(mod) and mod.comp.config.any_error_tracing;
18742 mod.comp.bin_file.options.error_return_tracing;
18743}18740}
1874418741
18745fn zirSaveErrRetIndex(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {18742fn zirSaveErrRetIndex(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
18746 const mod = sema.mod;18743 const mod = sema.mod;
18747 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].save_err_ret_index;18744 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].save_err_ret_index;
1874818745
18746 // TODO: replace all of these checks with logic in module creation
18749 if (!mod.backendSupportsFeature(.error_return_trace)) return;18747 if (!mod.backendSupportsFeature(.error_return_trace)) return;
18750 if (!mod.comp.bin_file.options.error_return_tracing) return;18748 if (!block.ownerModule().error_tracing) return;
1875118749
18752 // This is only relevant at runtime.18750 // This is only relevant at runtime.
18753 if (block.is_comptime or block.is_typeof) return;18751 if (block.is_comptime or block.is_typeof) return;
...@@ -18774,7 +18772,7 @@ fn zirRestoreErrRetIndex(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index)...@@ -18774,7 +18772,7 @@ fn zirRestoreErrRetIndex(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index)
1877418772
18775 if (!mod.backendSupportsFeature(.error_return_trace)) return;18773 if (!mod.backendSupportsFeature(.error_return_trace)) return;
18776 if (!ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn) return;18774 if (!ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn) return;
18777 if (!mod.comp.bin_file.options.error_return_tracing) return;18775 if (!start_block.ownerModule().error_tracing) return;
1877818776
18779 const tracy = trace(@src());18777 const tracy = trace(@src());
18780 defer tracy.end();18778 defer tracy.end();
...@@ -20045,7 +20043,7 @@ fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref {...@@ -20045,7 +20043,7 @@ fn getErrorReturnTrace(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref {
2004520043
20046 if (sema.owner_func_index != .none and20044 if (sema.owner_func_index != .none and
20047 ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn and20045 ip.funcAnalysis(sema.owner_func_index).calls_or_awaits_errorable_fn and
20048 mod.comp.bin_file.options.error_return_tracing and20046 mod.ownerModule().error_tracing and
20049 mod.backendSupportsFeature(.error_return_trace))20047 mod.backendSupportsFeature(.error_return_trace))
20050 {20048 {
20051 return block.addTy(.err_return_trace, opt_ptr_stack_trace_ty);20049 return block.addTy(.err_return_trace, opt_ptr_stack_trace_ty);
...@@ -34504,7 +34502,9 @@ pub fn resolveFnTypes(sema: *Sema, fn_ty: Type) CompileError!void {...@@ -34504,7 +34502,9 @@ pub fn resolveFnTypes(sema: *Sema, fn_ty: Type) CompileError!void {
3450434502
34505 try sema.resolveTypeFully(Type.fromInterned(fn_ty_info.return_type));34503 try sema.resolveTypeFully(Type.fromInterned(fn_ty_info.return_type));
3450634504
34507 if (mod.comp.bin_file.options.error_return_tracing and Type.fromInterned(fn_ty_info.return_type).isError(mod)) {34505 if (mod.comp.config.any_error_tracing and
34506 Type.fromInterned(fn_ty_info.return_type).isError(mod))
34507 {
34508 // Ensure the type exists so that backends can assume that.34508 // Ensure the type exists so that backends can assume that.
34509 _ = try sema.getBuiltinType("StackTrace");34509 _ = try sema.getBuiltinType("StackTrace");
34510 }34510 }
src/codegen/llvm.zig+5-5
...@@ -1398,7 +1398,7 @@ pub const Object = struct {...@@ -1398,7 +1398,7 @@ pub const Object = struct {
1398 };1398 };
13991399
1400 const err_return_tracing = Type.fromInterned(fn_info.return_type).isError(mod) and1400 const err_return_tracing = Type.fromInterned(fn_info.return_type).isError(mod) and
1401 mod.comp.bin_file.options.error_return_tracing;1401 mod.comp.config.any_error_tracing;
14021402
1403 const err_ret_trace: Builder.Value = if (err_return_tracing) param: {1403 const err_ret_trace: Builder.Value = if (err_return_tracing) param: {
1404 const param = wip.arg(llvm_arg_i);1404 const param = wip.arg(llvm_arg_i);
...@@ -2820,7 +2820,7 @@ pub const Object = struct {...@@ -2820,7 +2820,7 @@ pub const Object = struct {
2820 }2820 }
28212821
2822 if (Type.fromInterned(fn_info.return_type).isError(mod) and2822 if (Type.fromInterned(fn_info.return_type).isError(mod) and
2823 o.module.comp.bin_file.options.error_return_tracing)2823 o.module.comp.config.any_error_tracing)
2824 {2824 {
2825 const ptr_ty = try mod.singleMutPtrType(try o.getStackTraceType());2825 const ptr_ty = try mod.singleMutPtrType(try o.getStackTraceType());
2826 try param_di_types.append(try o.lowerDebugType(ptr_ty, .full));2826 try param_di_types.append(try o.lowerDebugType(ptr_ty, .full));
...@@ -2988,7 +2988,7 @@ pub const Object = struct {...@@ -2988,7 +2988,7 @@ pub const Object = struct {
2988 }2988 }
29892989
2990 const err_return_tracing = Type.fromInterned(fn_info.return_type).isError(mod) and2990 const err_return_tracing = Type.fromInterned(fn_info.return_type).isError(mod) and
2991 mod.comp.bin_file.options.error_return_tracing;2991 mod.comp.config.any_error_tracing;
29922992
2993 if (err_return_tracing) {2993 if (err_return_tracing) {
2994 try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder);2994 try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder);
...@@ -3677,7 +3677,7 @@ pub const Object = struct {...@@ -3677,7 +3677,7 @@ pub const Object = struct {
3677 }3677 }
36783678
3679 if (Type.fromInterned(fn_info.return_type).isError(mod) and3679 if (Type.fromInterned(fn_info.return_type).isError(mod) and
3680 mod.comp.bin_file.options.error_return_tracing)3680 mod.comp.config.any_error_tracing)
3681 {3681 {
3682 const ptr_ty = try mod.singleMutPtrType(try o.getStackTraceType());3682 const ptr_ty = try mod.singleMutPtrType(try o.getStackTraceType());
3683 try llvm_params.append(o.gpa, try o.lowerType(ptr_ty));3683 try llvm_params.append(o.gpa, try o.lowerType(ptr_ty));
...@@ -5142,7 +5142,7 @@ pub const FuncGen = struct {...@@ -5142,7 +5142,7 @@ pub const FuncGen = struct {
5142 };5142 };
51435143
5144 const err_return_tracing = return_type.isError(mod) and5144 const err_return_tracing = return_type.isError(mod) and
5145 o.module.comp.bin_file.options.error_return_tracing;5145 o.module.comp.config.any_error_tracing;
5146 if (err_return_tracing) {5146 if (err_return_tracing) {
5147 assert(self.err_ret_trace != .none);5147 assert(self.err_ret_trace != .none);
5148 try llvm_args.append(self.err_ret_trace);5148 try llvm_args.append(self.err_ret_trace);
src/main.zig+5
...@@ -1055,6 +1055,8 @@ fn buildOutputType(...@@ -1055,6 +1055,8 @@ fn buildOutputType(
1055 create_module.opts.any_unwind_tables = true;1055 create_module.opts.any_unwind_tables = true;
1056 if (mod_opts.strip == false)1056 if (mod_opts.strip == false)
1057 create_module.opts.any_non_stripped = true;1057 create_module.opts.any_non_stripped = true;
1058 if (mod_opts.error_tracing == true)
1059 create_module.opts.any_error_tracing = true;
10581060
1059 const root_src = try introspect.resolvePath(arena, root_src_orig);1061 const root_src = try introspect.resolvePath(arena, root_src_orig);
1060 try create_module.modules.put(arena, mod_name, .{1062 try create_module.modules.put(arena, mod_name, .{
...@@ -2535,6 +2537,8 @@ fn buildOutputType(...@@ -2535,6 +2537,8 @@ fn buildOutputType(
2535 create_module.opts.any_unwind_tables = true;2537 create_module.opts.any_unwind_tables = true;
2536 if (mod_opts.strip == false)2538 if (mod_opts.strip == false)
2537 create_module.opts.any_non_stripped = true;2539 create_module.opts.any_non_stripped = true;
2540 if (mod_opts.error_tracing == true)
2541 create_module.opts.any_error_tracing = true;
25382542
2539 const src_path = try introspect.resolvePath(arena, unresolved_src_path);2543 const src_path = try introspect.resolvePath(arena, unresolved_src_path);
2540 try create_module.modules.put(arena, "main", .{2544 try create_module.modules.put(arena, "main", .{
...@@ -3741,6 +3745,7 @@ fn createModule(...@@ -3741,6 +3745,7 @@ fn createModule(
3741 create_module.opts.resolved_target = resolved_target;3745 create_module.opts.resolved_target = resolved_target;
3742 create_module.opts.root_optimize_mode = cli_mod.inherited.optimize_mode;3746 create_module.opts.root_optimize_mode = cli_mod.inherited.optimize_mode;
3743 create_module.opts.root_strip = cli_mod.inherited.strip;3747 create_module.opts.root_strip = cli_mod.inherited.strip;
3748 create_module.opts.root_error_tracing = cli_mod.inherited.error_tracing;
3744 const target = resolved_target.result;3749 const target = resolved_target.result;
37453750
3746 // First, remove libc, libc++, and compiler_rt libraries from the system libraries list.3751 // First, remove libc, libc++, and compiler_rt libraries from the system libraries list.