| author | |
| committer | |
| log | 304e4082a0a50c2a6dfbba2a1985cf772edb9e73 |
| tree | 959bfcee9176e487dfcd4488ada99364658f9a37 |
| parent | fac120bc3ad58a10ab80952e42becd0084aec059 |
| parent | ceff2782029672714ac2e04a7b3e25af23eb9a9b |
| signature |
Expose an option for producing 64-bit DWARF format11 files changed, 115 insertions(+), 17 deletions(-)
lib/std/Build/CompileStep.zig+8| ... | @@ -69,6 +69,7 @@ disable_stack_probing: bool, | ... | @@ -69,6 +69,7 @@ disable_stack_probing: bool, |
| 69 | disable_sanitize_c: bool, | 69 | disable_sanitize_c: bool, |
| 70 | sanitize_thread: bool, | 70 | sanitize_thread: bool, |
| 71 | rdynamic: bool, | 71 | rdynamic: bool, |
| 72 | dwarf_format: ?std.dwarf.Format = null, | ||
| 72 | import_memory: bool = false, | 73 | import_memory: bool = false, |
| 73 | /// For WebAssembly targets, this will allow for undefined symbols to | 74 | /// For WebAssembly targets, this will allow for undefined symbols to |
| 74 | /// be imported from the host environment. | 75 | /// be imported from the host environment. |
| ... | @@ -1450,6 +1451,13 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { | ... | @@ -1450,6 +1451,13 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1450 | try addFlag(&zig_args, "strip", self.strip); | 1451 | try addFlag(&zig_args, "strip", self.strip); |
| 1451 | try addFlag(&zig_args, "unwind-tables", self.unwind_tables); | 1452 | try addFlag(&zig_args, "unwind-tables", self.unwind_tables); |
| 1452 | 1453 | ||
| 1454 | if (self.dwarf_format) |dwarf_format| { | ||
| 1455 | try zig_args.append(switch (dwarf_format) { | ||
| 1456 | .@"32" => "-gdwarf32", | ||
| 1457 | .@"64" => "-gdwarf64", | ||
| 1458 | }); | ||
| 1459 | } | ||
| 1460 | |||
| 1453 | switch (self.compress_debug_sections) { | 1461 | switch (self.compress_debug_sections) { |
| 1454 | .none => {}, | 1462 | .none => {}, |
| 1455 | .zlib => try zig_args.append("--compress-debug-sections=zlib"), | 1463 | .zlib => try zig_args.append("--compress-debug-sections=zlib"), |
lib/std/dwarf.zig+2| ... | @@ -147,6 +147,8 @@ pub const CC = enum(u8) { | ... | @@ -147,6 +147,8 @@ pub const CC = enum(u8) { |
| 147 | GNU_borland_fastcall_i386 = 0x41, | 147 | GNU_borland_fastcall_i386 = 0x41, |
| 148 | }; | 148 | }; |
| 149 | 149 | ||
| 150 | pub const Format = enum { @"32", @"64" }; | ||
| 151 | |||
| 150 | const PcRange = struct { | 152 | const PcRange = struct { |
| 151 | start: u64, | 153 | start: u64, |
| 152 | end: u64, | 154 | end: u64, |
src/Compilation.zig+10-1| ... | @@ -620,6 +620,7 @@ pub const InitOptions = struct { | ... | @@ -620,6 +620,7 @@ pub const InitOptions = struct { |
| 620 | test_name_prefix: ?[]const u8 = null, | 620 | test_name_prefix: ?[]const u8 = null, |
| 621 | test_runner_path: ?[]const u8 = null, | 621 | test_runner_path: ?[]const u8 = null, |
| 622 | subsystem: ?std.Target.SubSystem = null, | 622 | subsystem: ?std.Target.SubSystem = null, |
| 623 | dwarf_format: ?std.dwarf.Format = null, | ||
| 623 | /// WASI-only. Type of WASI execution model ("command" or "reactor"). | 624 | /// WASI-only. Type of WASI execution model ("command" or "reactor"). |
| 624 | wasi_exec_model: ?std.builtin.WasiExecModel = null, | 625 | wasi_exec_model: ?std.builtin.WasiExecModel = null, |
| 625 | /// (Zig compiler development) Enable dumping linker's state as JSON. | 626 | /// (Zig compiler development) Enable dumping linker's state as JSON. |
| ... | @@ -1111,6 +1112,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { | ... | @@ -1111,6 +1112,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1111 | cache.hash.add(link_libunwind); | 1112 | cache.hash.add(link_libunwind); |
| 1112 | cache.hash.add(options.output_mode); | 1113 | cache.hash.add(options.output_mode); |
| 1113 | cache.hash.add(options.machine_code_model); | 1114 | cache.hash.add(options.machine_code_model); |
| 1115 | cache.hash.addOptional(options.dwarf_format); | ||
| 1114 | cache_helpers.addOptionalEmitLoc(&cache.hash, options.emit_bin); | 1116 | cache_helpers.addOptionalEmitLoc(&cache.hash, options.emit_bin); |
| 1115 | cache_helpers.addOptionalEmitLoc(&cache.hash, options.emit_implib); | 1117 | cache_helpers.addOptionalEmitLoc(&cache.hash, options.emit_implib); |
| 1116 | cache.hash.addBytes(options.root_name); | 1118 | cache.hash.addBytes(options.root_name); |
| ... | @@ -1517,6 +1519,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { | ... | @@ -1517,6 +1519,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1517 | .disable_lld_caching = options.disable_lld_caching or cache_mode == .whole, | 1519 | .disable_lld_caching = options.disable_lld_caching or cache_mode == .whole, |
| 1518 | .subsystem = options.subsystem, | 1520 | .subsystem = options.subsystem, |
| 1519 | .is_test = options.is_test, | 1521 | .is_test = options.is_test, |
| 1522 | .dwarf_format = options.dwarf_format, | ||
| 1520 | .wasi_exec_model = wasi_exec_model, | 1523 | .wasi_exec_model = wasi_exec_model, |
| 1521 | .hash_style = options.hash_style, | 1524 | .hash_style = options.hash_style, |
| 1522 | .enable_link_snapshots = options.enable_link_snapshots, | 1525 | .enable_link_snapshots = options.enable_link_snapshots, |
| ... | @@ -4488,7 +4491,13 @@ pub fn addCCArgs( | ... | @@ -4488,7 +4491,13 @@ pub fn addCCArgs( |
| 4488 | // generation, it only changes the type of information generated. | 4491 | // generation, it only changes the type of information generated. |
| 4489 | try argv.appendSlice(&.{ "-g", "-gcodeview" }); | 4492 | try argv.appendSlice(&.{ "-g", "-gcodeview" }); |
| 4490 | }, | 4493 | }, |
| 4491 | .elf, .macho => try argv.append("-gdwarf-4"), | 4494 | .elf, .macho => { |
| 4495 | try argv.append("-gdwarf-4"); | ||
| 4496 | if (comp.bin_file.options.dwarf_format) |f| switch (f) { | ||
| 4497 | .@"32" => try argv.append("-gdwarf32"), | ||
| 4498 | .@"64" => try argv.append("-gdwarf64"), | ||
| 4499 | }; | ||
| 4500 | }, | ||
| 4492 | else => try argv.append("-g"), | 4501 | else => try argv.append("-g"), |
| 4493 | } | 4502 | } |
| 4494 | } | 4503 | } |
src/clang_options_data.zig+56-7| ... | @@ -3870,13 +3870,62 @@ flagpd1("gcodeview-command-line"), | ... | @@ -3870,13 +3870,62 @@ flagpd1("gcodeview-command-line"), |
| 3870 | flagpd1("gcodeview-ghash"), | 3870 | flagpd1("gcodeview-ghash"), |
| 3871 | flagpd1("gcolumn-info"), | 3871 | flagpd1("gcolumn-info"), |
| 3872 | flagpd1("gdbx"), | 3872 | flagpd1("gdbx"), |
| 3873 | flagpd1("gdwarf"), | 3873 | .{ |
| 3874 | flagpd1("gdwarf32"), | 3874 | .name = "gdwarf", |
| 3875 | flagpd1("gdwarf64"), | 3875 | .syntax = .flag, |
| 3876 | flagpd1("gdwarf-2"), | 3876 | .zig_equivalent = .debug, |
| 3877 | flagpd1("gdwarf-3"), | 3877 | .pd1 = true, |
| 3878 | flagpd1("gdwarf-4"), | 3878 | .pd2 = false, |
| 3879 | flagpd1("gdwarf-5"), | 3879 | .psl = false, |
| 3880 | }, | ||
| 3881 | .{ | ||
| 3882 | .name = "gdwarf32", | ||
| 3883 | .syntax = .flag, | ||
| 3884 | .zig_equivalent = .gdwarf32, | ||
| 3885 | .pd1 = true, | ||
| 3886 | .pd2 = false, | ||
| 3887 | .psl = false, | ||
| 3888 | }, | ||
| 3889 | .{ | ||
| 3890 | .name = "gdwarf64", | ||
| 3891 | .syntax = .flag, | ||
| 3892 | .zig_equivalent = .gdwarf64, | ||
| 3893 | .pd1 = true, | ||
| 3894 | .pd2 = false, | ||
| 3895 | .psl = false, | ||
| 3896 | }, | ||
| 3897 | .{ | ||
| 3898 | .name = "gdwarf-2", | ||
| 3899 | .syntax = .flag, | ||
| 3900 | .zig_equivalent = .debug, | ||
| 3901 | .pd1 = true, | ||
| 3902 | .pd2 = false, | ||
| 3903 | .psl = false, | ||
| 3904 | }, | ||
| 3905 | .{ | ||
| 3906 | .name = "gdwarf-3", | ||
| 3907 | .syntax = .flag, | ||
| 3908 | .zig_equivalent = .debug, | ||
| 3909 | .pd1 = true, | ||
| 3910 | .pd2 = false, | ||
| 3911 | .psl = false, | ||
| 3912 | }, | ||
| 3913 | .{ | ||
| 3914 | .name = "gdwarf-4", | ||
| 3915 | .syntax = .flag, | ||
| 3916 | .zig_equivalent = .debug, | ||
| 3917 | .pd1 = true, | ||
| 3918 | .pd2 = false, | ||
| 3919 | .psl = false, | ||
| 3920 | }, | ||
| 3921 | .{ | ||
| 3922 | .name = "gdwarf-5", | ||
| 3923 | .syntax = .flag, | ||
| 3924 | .zig_equivalent = .debug, | ||
| 3925 | .pd1 = true, | ||
| 3926 | .pd2 = false, | ||
| 3927 | .psl = false, | ||
| 3928 | }, | ||
| 3880 | flagpd1("gdwarf-aranges"), | 3929 | flagpd1("gdwarf-aranges"), |
| 3881 | flagpd1("gembed-source"), | 3930 | flagpd1("gembed-source"), |
| 3882 | sepd1("gen-cdb-fragment-path"), | 3931 | sepd1("gen-cdb-fragment-path"), |
src/codegen/llvm.zig+1-1| ... | @@ -433,7 +433,7 @@ pub const Object = struct { | ... | @@ -433,7 +433,7 @@ pub const Object = struct { |
| 433 | if (!options.strip) { | 433 | if (!options.strip) { |
| 434 | switch (options.target.ofmt) { | 434 | switch (options.target.ofmt) { |
| 435 | .coff => llvm_module.addModuleCodeViewFlag(), | 435 | .coff => llvm_module.addModuleCodeViewFlag(), |
| 436 | else => llvm_module.addModuleDebugInfoFlag(), | 436 | else => llvm_module.addModuleDebugInfoFlag(options.dwarf_format == std.dwarf.Format.@"64"), |
| 437 | } | 437 | } |
| 438 | const di_builder = llvm_module.createDIBuilder(true); | 438 | const di_builder = llvm_module.createDIBuilder(true); |
| 439 | opt_di_builder = di_builder; | 439 | opt_di_builder = di_builder; |
src/codegen/llvm/bindings.zig+1-1| ... | @@ -409,7 +409,7 @@ pub const Module = opaque { | ... | @@ -409,7 +409,7 @@ pub const Module = opaque { |
| 409 | extern fn LLVMSetTarget(M: *Module, Triple: [*:0]const u8) void; | 409 | extern fn LLVMSetTarget(M: *Module, Triple: [*:0]const u8) void; |
| 410 | 410 | ||
| 411 | pub const addModuleDebugInfoFlag = ZigLLVMAddModuleDebugInfoFlag; | 411 | pub const addModuleDebugInfoFlag = ZigLLVMAddModuleDebugInfoFlag; |
| 412 | extern fn ZigLLVMAddModuleDebugInfoFlag(module: *Module) void; | 412 | extern fn ZigLLVMAddModuleDebugInfoFlag(module: *Module, dwarf64: bool) void; |
| 413 | 413 | ||
| 414 | pub const addModuleCodeViewFlag = ZigLLVMAddModuleCodeViewFlag; | 414 | pub const addModuleCodeViewFlag = ZigLLVMAddModuleCodeViewFlag; |
| 415 | extern fn ZigLLVMAddModuleCodeViewFlag(module: *Module) void; | 415 | extern fn ZigLLVMAddModuleCodeViewFlag(module: *Module) void; |
src/link.zig+2| ... | @@ -200,6 +200,8 @@ pub const Options = struct { | ... | @@ -200,6 +200,8 @@ pub const Options = struct { |
| 200 | compatibility_version: ?std.builtin.Version, | 200 | compatibility_version: ?std.builtin.Version, |
| 201 | libc_installation: ?*const LibCInstallation, | 201 | libc_installation: ?*const LibCInstallation, |
| 202 | 202 | ||
| 203 | dwarf_format: ?std.dwarf.Format, | ||
| 204 | |||
| 203 | /// WASI-only. Type of WASI execution model ("command" or "reactor"). | 205 | /// WASI-only. Type of WASI execution model ("command" or "reactor"). |
| 204 | wasi_exec_model: std.builtin.WasiExecModel = undefined, | 206 | wasi_exec_model: std.builtin.WasiExecModel = undefined, |
| 205 | 207 |
src/main.zig+16| ... | @@ -844,6 +844,7 @@ fn buildOutputType( | ... | @@ -844,6 +844,7 @@ fn buildOutputType( |
| 844 | var reference_trace: ?u32 = null; | 844 | var reference_trace: ?u32 = null; |
| 845 | var error_tracing: ?bool = null; | 845 | var error_tracing: ?bool = null; |
| 846 | var pdb_out_path: ?[]const u8 = null; | 846 | var pdb_out_path: ?[]const u8 = null; |
| 847 | var dwarf_format: ?std.dwarf.Format = null; | ||
| 847 | 848 | ||
| 848 | // e.g. -m3dnow or -mno-outline-atomics. They correspond to std.Target llvm cpu feature names. | 849 | // e.g. -m3dnow or -mno-outline-atomics. They correspond to std.Target llvm cpu feature names. |
| 849 | // This array is populated by zig cc frontend and then has to be converted to zig-style | 850 | // This array is populated by zig cc frontend and then has to be converted to zig-style |
| ... | @@ -1355,6 +1356,10 @@ fn buildOutputType( | ... | @@ -1355,6 +1356,10 @@ fn buildOutputType( |
| 1355 | strip = true; | 1356 | strip = true; |
| 1356 | } else if (mem.eql(u8, arg, "-fno-strip")) { | 1357 | } else if (mem.eql(u8, arg, "-fno-strip")) { |
| 1357 | strip = false; | 1358 | strip = false; |
| 1359 | } else if (mem.eql(u8, arg, "-gdwarf32")) { | ||
| 1360 | dwarf_format = .@"32"; | ||
| 1361 | } else if (mem.eql(u8, arg, "-gdwarf64")) { | ||
| 1362 | dwarf_format = .@"64"; | ||
| 1358 | } else if (mem.eql(u8, arg, "-fformatted-panics")) { | 1363 | } else if (mem.eql(u8, arg, "-fformatted-panics")) { |
| 1359 | formatted_panics = true; | 1364 | formatted_panics = true; |
| 1360 | } else if (mem.eql(u8, arg, "-fno-formatted-panics")) { | 1365 | } else if (mem.eql(u8, arg, "-fno-formatted-panics")) { |
| ... | @@ -1762,6 +1767,14 @@ fn buildOutputType( | ... | @@ -1762,6 +1767,14 @@ fn buildOutputType( |
| 1762 | try clang_argv.appendSlice(it.other_args); | 1767 | try clang_argv.appendSlice(it.other_args); |
| 1763 | } | 1768 | } |
| 1764 | }, | 1769 | }, |
| 1770 | .gdwarf32 => { | ||
| 1771 | strip = false; | ||
| 1772 | dwarf_format = .@"32"; | ||
| 1773 | }, | ||
| 1774 | .gdwarf64 => { | ||
| 1775 | strip = false; | ||
| 1776 | dwarf_format = .@"64"; | ||
| 1777 | }, | ||
| 1765 | .sanitize => { | 1778 | .sanitize => { |
| 1766 | if (mem.eql(u8, it.only_arg, "undefined")) { | 1779 | if (mem.eql(u8, it.only_arg, "undefined")) { |
| 1767 | want_sanitize_c = true; | 1780 | want_sanitize_c = true; |
| ... | @@ -3145,6 +3158,7 @@ fn buildOutputType( | ... | @@ -3145,6 +3158,7 @@ fn buildOutputType( |
| 3145 | .test_runner_path = test_runner_path, | 3158 | .test_runner_path = test_runner_path, |
| 3146 | .disable_lld_caching = !output_to_cache, | 3159 | .disable_lld_caching = !output_to_cache, |
| 3147 | .subsystem = subsystem, | 3160 | .subsystem = subsystem, |
| 3161 | .dwarf_format = dwarf_format, | ||
| 3148 | .wasi_exec_model = wasi_exec_model, | 3162 | .wasi_exec_model = wasi_exec_model, |
| 3149 | .debug_compile_errors = debug_compile_errors, | 3163 | .debug_compile_errors = debug_compile_errors, |
| 3150 | .enable_link_snapshots = enable_link_snapshots, | 3164 | .enable_link_snapshots = enable_link_snapshots, |
| ... | @@ -5102,6 +5116,8 @@ pub const ClangArgIterator = struct { | ... | @@ -5102,6 +5116,8 @@ pub const ClangArgIterator = struct { |
| 5102 | asm_only, | 5116 | asm_only, |
| 5103 | optimize, | 5117 | optimize, |
| 5104 | debug, | 5118 | debug, |
| 5119 | gdwarf32, | ||
| 5120 | gdwarf64, | ||
| 5105 | sanitize, | 5121 | sanitize, |
| 5106 | linker_script, | 5122 | linker_script, |
| 5107 | dry_run, | 5123 | dry_run, |
src/zig_llvm.cpp+5-1| ... | @@ -1163,9 +1163,13 @@ void ZigLLVMGetNativeTarget(ZigLLVM_ArchType *arch_type, | ... | @@ -1163,9 +1163,13 @@ void ZigLLVMGetNativeTarget(ZigLLVM_ArchType *arch_type, |
| 1163 | free(native_triple); | 1163 | free(native_triple); |
| 1164 | } | 1164 | } |
| 1165 | 1165 | ||
| 1166 | void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module) { | 1166 | void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module, bool produce_dwarf64) { |
| 1167 | unwrap(module)->addModuleFlag(Module::Warning, "Debug Info Version", DEBUG_METADATA_VERSION); | 1167 | unwrap(module)->addModuleFlag(Module::Warning, "Debug Info Version", DEBUG_METADATA_VERSION); |
| 1168 | unwrap(module)->addModuleFlag(Module::Warning, "Dwarf Version", 4); | 1168 | unwrap(module)->addModuleFlag(Module::Warning, "Dwarf Version", 4); |
| 1169 | |||
| 1170 | if (produce_dwarf64) { | ||
| 1171 | unwrap(module)->addModuleFlag(Module::Warning, "DWARF64", 1); | ||
| 1172 | } | ||
| 1169 | } | 1173 | } |
| 1170 | 1174 | ||
| 1171 | void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module) { | 1175 | void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module) { |
src/zig_llvm.h+1-1| ... | @@ -238,7 +238,7 @@ ZIG_EXTERN_C unsigned ZigLLVMTag_DW_union_type(void); | ... | @@ -238,7 +238,7 @@ ZIG_EXTERN_C unsigned ZigLLVMTag_DW_union_type(void); |
| 238 | 238 | ||
| 239 | ZIG_EXTERN_C struct ZigLLVMDIBuilder *ZigLLVMCreateDIBuilder(LLVMModuleRef module, bool allow_unresolved); | 239 | ZIG_EXTERN_C struct ZigLLVMDIBuilder *ZigLLVMCreateDIBuilder(LLVMModuleRef module, bool allow_unresolved); |
| 240 | ZIG_EXTERN_C void ZigLLVMDisposeDIBuilder(struct ZigLLVMDIBuilder *dbuilder); | 240 | ZIG_EXTERN_C void ZigLLVMDisposeDIBuilder(struct ZigLLVMDIBuilder *dbuilder); |
| 241 | ZIG_EXTERN_C void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module); | 241 | ZIG_EXTERN_C void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module, bool produce_dwarf64); |
| 242 | ZIG_EXTERN_C void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module); | 242 | ZIG_EXTERN_C void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module); |
| 243 | ZIG_EXTERN_C void ZigLLVMSetModulePICLevel(LLVMModuleRef module); | 243 | ZIG_EXTERN_C void ZigLLVMSetModulePICLevel(LLVMModuleRef module); |
| 244 | ZIG_EXTERN_C void ZigLLVMSetModulePIELevel(LLVMModuleRef module); | 244 | ZIG_EXTERN_C void ZigLLVMSetModulePIELevel(LLVMModuleRef module); |
tools/update_clang_options.zig+13-5| ... | @@ -241,23 +241,31 @@ const known_options = [_]KnownOpt{ | ... | @@ -241,23 +241,31 @@ const known_options = [_]KnownOpt{ |
| 241 | .ident = "debug", | 241 | .ident = "debug", |
| 242 | }, | 242 | }, |
| 243 | .{ | 243 | .{ |
| 244 | .name = "g-dwarf", | 244 | .name = "gdwarf32", |
| 245 | .ident = "gdwarf32", | ||
| 246 | }, | ||
| 247 | .{ | ||
| 248 | .name = "gdwarf64", | ||
| 249 | .ident = "gdwarf64", | ||
| 250 | }, | ||
| 251 | .{ | ||
| 252 | .name = "gdwarf", | ||
| 245 | .ident = "debug", | 253 | .ident = "debug", |
| 246 | }, | 254 | }, |
| 247 | .{ | 255 | .{ |
| 248 | .name = "g-dwarf-2", | 256 | .name = "gdwarf-2", |
| 249 | .ident = "debug", | 257 | .ident = "debug", |
| 250 | }, | 258 | }, |
| 251 | .{ | 259 | .{ |
| 252 | .name = "g-dwarf-3", | 260 | .name = "gdwarf-3", |
| 253 | .ident = "debug", | 261 | .ident = "debug", |
| 254 | }, | 262 | }, |
| 255 | .{ | 263 | .{ |
| 256 | .name = "g-dwarf-4", | 264 | .name = "gdwarf-4", |
| 257 | .ident = "debug", | 265 | .ident = "debug", |
| 258 | }, | 266 | }, |
| 259 | .{ | 267 | .{ |
| 260 | .name = "g-dwarf-5", | 268 | .name = "gdwarf-5", |
| 261 | .ident = "debug", | 269 | .ident = "debug", |
| 262 | }, | 270 | }, |
| 263 | .{ | 271 | .{ |