diff options
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 48a0412b23..a07ac417e3 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -620,6 +620,7 @@ pub const InitOptions = struct { test_name_prefix: ?[]const u8 = null, test_runner_path: ?[]const u8 = null, subsystem: ?std.Target.SubSystem = null, + dwarf_format: ?std.dwarf.Format = null, /// WASI-only. Type of WASI execution model ("command" or "reactor"). wasi_exec_model: ?std.builtin.WasiExecModel = null, /// (Zig compiler development) Enable dumping linker's state as JSON. @@ -1111,6 +1112,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { cache.hash.add(link_libunwind); cache.hash.add(options.output_mode); cache.hash.add(options.machine_code_model); + cache.hash.addOptional(options.dwarf_format); cache_helpers.addOptionalEmitLoc(&cache.hash, options.emit_bin); cache_helpers.addOptionalEmitLoc(&cache.hash, options.emit_implib); cache.hash.addBytes(options.root_name); @@ -1517,6 +1519,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { .disable_lld_caching = options.disable_lld_caching or cache_mode == .whole, .subsystem = options.subsystem, .is_test = options.is_test, + .dwarf_format = options.dwarf_format, .wasi_exec_model = wasi_exec_model, .hash_style = options.hash_style, .enable_link_snapshots = options.enable_link_snapshots, @@ -4488,7 +4491,13 @@ pub fn addCCArgs( // generation, it only changes the type of information generated. try argv.appendSlice(&.{ "-g", "-gcodeview" }); }, - .elf, .macho => try argv.append("-gdwarf-4"), + .elf, .macho => { + try argv.append("-gdwarf-4"); + if (comp.bin_file.options.dwarf_format) |f| switch (f) { + .@"32" => try argv.append("-gdwarf32"), + .@"64" => try argv.append("-gdwarf64"), + }; + }, else => try argv.append("-g"), } } |
