| author | |
| committer | |
| log | ceff2782029672714ac2e04a7b3e25af23eb9a9b |
| tree | 959bfcee9176e487dfcd4488ada99364658f9a37 |
| parent | d026202a26e56e7e2ea20ca49509fdcf8b937020 |
* CompileStep: Avoid calling producesPdbFile() to determine whether the
option should be respected. If the user asks for it, put it on the
command line and let the Zig CLI deal with it appropriately.
* Make the namespace of `std.dwarf.Format.dwarf32` no longer have a
redundant "dwarf" in it.
* Add `zig cc` integration for `-gdwarf32` and `-gdwarf64`.
* Toss in a bonus bug fix for `-gdwarf-2`, `-gdwarf-3`, etc.
* Avoid using default init values for struct fields unnecessarily.
* Add missing cache hash addition for the new option.8 files changed, 98 insertions(+), 35 deletions(-)
lib/std/Build/CompileStep.zig+6-7| ... | ... | @@ -1450,13 +1450,12 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1450 | 1450 | |
| 1451 | 1451 | try addFlag(&zig_args, "strip", self.strip); |
| 1452 | 1452 | try addFlag(&zig_args, "unwind-tables", self.unwind_tables); |
| 1453 | if (!self.producesPdbFile()) { | |
| 1454 | if (self.dwarf_format) |dwarf_format| { | |
| 1455 | try zig_args.append(switch (dwarf_format) { | |
| 1456 | .dwarf32 => "-gdwarf32", | |
| 1457 | .dwarf64 => "-gdwarf64", | |
| 1458 | }); | |
| 1459 | } | |
| 1453 | ||
| 1454 | if (self.dwarf_format) |dwarf_format| { | |
| 1455 | try zig_args.append(switch (dwarf_format) { | |
| 1456 | .@"32" => "-gdwarf32", | |
| 1457 | .@"64" => "-gdwarf64", | |
| 1458 | }); | |
| 1460 | 1459 | } |
| 1461 | 1460 | |
| 1462 | 1461 | switch (self.compress_debug_sections) { |
lib/std/dwarf.zig+1-4| ... | ... | @@ -147,10 +147,7 @@ pub const CC = enum(u8) { |
| 147 | 147 | GNU_borland_fastcall_i386 = 0x41, |
| 148 | 148 | }; |
| 149 | 149 | |
| 150 | pub const Format = enum { | |
| 151 | dwarf32, | |
| 152 | dwarf64, | |
| 153 | }; | |
| 150 | pub const Format = enum { @"32", @"64" }; | |
| 154 | 151 | |
| 155 | 152 | const PcRange = struct { |
| 156 | 153 | start: u64, |
src/Compilation.zig+8-1| ... | ... | @@ -1112,6 +1112,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1112 | 1112 | cache.hash.add(link_libunwind); |
| 1113 | 1113 | cache.hash.add(options.output_mode); |
| 1114 | 1114 | cache.hash.add(options.machine_code_model); |
| 1115 | cache.hash.addOptional(options.dwarf_format); | |
| 1115 | 1116 | cache_helpers.addOptionalEmitLoc(&cache.hash, options.emit_bin); |
| 1116 | 1117 | cache_helpers.addOptionalEmitLoc(&cache.hash, options.emit_implib); |
| 1117 | 1118 | cache.hash.addBytes(options.root_name); |
| ... | ... | @@ -4490,7 +4491,13 @@ pub fn addCCArgs( |
| 4490 | 4491 | // generation, it only changes the type of information generated. |
| 4491 | 4492 | try argv.appendSlice(&.{ "-g", "-gcodeview" }); |
| 4492 | 4493 | }, |
| 4493 | .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 | }, | |
| 4494 | 4501 | else => try argv.append("-g"), |
| 4495 | 4502 | } |
| 4496 | 4503 | } |
src/clang_options_data.zig+56-7| ... | ... | @@ -3870,13 +3870,62 @@ flagpd1("gcodeview-command-line"), |
| 3870 | 3870 | flagpd1("gcodeview-ghash"), |
| 3871 | 3871 | flagpd1("gcolumn-info"), |
| 3872 | 3872 | flagpd1("gdbx"), |
| 3873 | flagpd1("gdwarf"), | |
| 3874 | flagpd1("gdwarf32"), | |
| 3875 | flagpd1("gdwarf64"), | |
| 3876 | flagpd1("gdwarf-2"), | |
| 3877 | flagpd1("gdwarf-3"), | |
| 3878 | flagpd1("gdwarf-4"), | |
| 3879 | flagpd1("gdwarf-5"), | |
| 3873 | .{ | |
| 3874 | .name = "gdwarf", | |
| 3875 | .syntax = .flag, | |
| 3876 | .zig_equivalent = .debug, | |
| 3877 | .pd1 = true, | |
| 3878 | .pd2 = false, | |
| 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 | 3929 | flagpd1("gdwarf-aranges"), |
| 3881 | 3930 | flagpd1("gembed-source"), |
| 3882 | 3931 | sepd1("gen-cdb-fragment-path"), |
src/codegen/llvm.zig+1-8| ... | ... | @@ -433,14 +433,7 @@ pub const Object = struct { |
| 433 | 433 | if (!options.strip) { |
| 434 | 434 | switch (options.target.ofmt) { |
| 435 | 435 | .coff => llvm_module.addModuleCodeViewFlag(), |
| 436 | else => { | |
| 437 | const dwarf_format = options.dwarf_format orelse .dwarf32; | |
| 438 | const produce_dwarf64 = switch (dwarf_format) { | |
| 439 | .dwarf32 => false, | |
| 440 | .dwarf64 => true, | |
| 441 | }; | |
| 442 | llvm_module.addModuleDebugInfoFlag(produce_dwarf64); | |
| 443 | }, | |
| 436 | else => llvm_module.addModuleDebugInfoFlag(options.dwarf_format == std.dwarf.Format.@"64"), | |
| 444 | 437 | } |
| 445 | 438 | const di_builder = llvm_module.createDIBuilder(true); |
| 446 | 439 | opt_di_builder = di_builder; |
src/link.zig+1-1| ... | ... | @@ -200,7 +200,7 @@ pub const Options = struct { |
| 200 | 200 | compatibility_version: ?std.builtin.Version, |
| 201 | 201 | libc_installation: ?*const LibCInstallation, |
| 202 | 202 | |
| 203 | dwarf_format: ?std.dwarf.Format = null, | |
| 203 | dwarf_format: ?std.dwarf.Format, | |
| 204 | 204 | |
| 205 | 205 | /// WASI-only. Type of WASI execution model ("command" or "reactor"). |
| 206 | 206 | wasi_exec_model: std.builtin.WasiExecModel = undefined, |
src/main.zig+12-2| ... | ... | @@ -1357,9 +1357,9 @@ fn buildOutputType( |
| 1357 | 1357 | } else if (mem.eql(u8, arg, "-fno-strip")) { |
| 1358 | 1358 | strip = false; |
| 1359 | 1359 | } else if (mem.eql(u8, arg, "-gdwarf32")) { |
| 1360 | dwarf_format = .dwarf32; | |
| 1360 | dwarf_format = .@"32"; | |
| 1361 | 1361 | } else if (mem.eql(u8, arg, "-gdwarf64")) { |
| 1362 | dwarf_format = .dwarf64; | |
| 1362 | dwarf_format = .@"64"; | |
| 1363 | 1363 | } else if (mem.eql(u8, arg, "-fformatted-panics")) { |
| 1364 | 1364 | formatted_panics = true; |
| 1365 | 1365 | } else if (mem.eql(u8, arg, "-fno-formatted-panics")) { |
| ... | ... | @@ -1767,6 +1767,14 @@ fn buildOutputType( |
| 1767 | 1767 | try clang_argv.appendSlice(it.other_args); |
| 1768 | 1768 | } |
| 1769 | 1769 | }, |
| 1770 | .gdwarf32 => { | |
| 1771 | strip = false; | |
| 1772 | dwarf_format = .@"32"; | |
| 1773 | }, | |
| 1774 | .gdwarf64 => { | |
| 1775 | strip = false; | |
| 1776 | dwarf_format = .@"64"; | |
| 1777 | }, | |
| 1770 | 1778 | .sanitize => { |
| 1771 | 1779 | if (mem.eql(u8, it.only_arg, "undefined")) { |
| 1772 | 1780 | want_sanitize_c = true; |
| ... | ... | @@ -5108,6 +5116,8 @@ pub const ClangArgIterator = struct { |
| 5108 | 5116 | asm_only, |
| 5109 | 5117 | optimize, |
| 5110 | 5118 | debug, |
| 5119 | gdwarf32, | |
| 5120 | gdwarf64, | |
| 5111 | 5121 | sanitize, |
| 5112 | 5122 | linker_script, |
| 5113 | 5123 | dry_run, |
tools/update_clang_options.zig+13-5| ... | ... | @@ -241,23 +241,31 @@ const known_options = [_]KnownOpt{ |
| 241 | 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 | 253 | .ident = "debug", |
| 246 | 254 | }, |
| 247 | 255 | .{ |
| 248 | .name = "g-dwarf-2", | |
| 256 | .name = "gdwarf-2", | |
| 249 | 257 | .ident = "debug", |
| 250 | 258 | }, |
| 251 | 259 | .{ |
| 252 | .name = "g-dwarf-3", | |
| 260 | .name = "gdwarf-3", | |
| 253 | 261 | .ident = "debug", |
| 254 | 262 | }, |
| 255 | 263 | .{ |
| 256 | .name = "g-dwarf-4", | |
| 264 | .name = "gdwarf-4", | |
| 257 | 265 | .ident = "debug", |
| 258 | 266 | }, |
| 259 | 267 | .{ |
| 260 | .name = "g-dwarf-5", | |
| 268 | .name = "gdwarf-5", | |
| 261 | 269 | .ident = "debug", |
| 262 | 270 | }, |
| 263 | 271 | .{ |