mirror of
https://github.com/ziglang/zig.git
synced 2025-02-10 06:30:18 +00:00
fixes to the previous commit
* 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.
This commit is contained in:
parent
d026202a26
commit
ceff278202
@ -1450,13 +1450,12 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
|
||||
try addFlag(&zig_args, "strip", self.strip);
|
||||
try addFlag(&zig_args, "unwind-tables", self.unwind_tables);
|
||||
if (!self.producesPdbFile()) {
|
||||
if (self.dwarf_format) |dwarf_format| {
|
||||
try zig_args.append(switch (dwarf_format) {
|
||||
.dwarf32 => "-gdwarf32",
|
||||
.dwarf64 => "-gdwarf64",
|
||||
});
|
||||
}
|
||||
|
||||
if (self.dwarf_format) |dwarf_format| {
|
||||
try zig_args.append(switch (dwarf_format) {
|
||||
.@"32" => "-gdwarf32",
|
||||
.@"64" => "-gdwarf64",
|
||||
});
|
||||
}
|
||||
|
||||
switch (self.compress_debug_sections) {
|
||||
|
@ -147,10 +147,7 @@ pub const CC = enum(u8) {
|
||||
GNU_borland_fastcall_i386 = 0x41,
|
||||
};
|
||||
|
||||
pub const Format = enum {
|
||||
dwarf32,
|
||||
dwarf64,
|
||||
};
|
||||
pub const Format = enum { @"32", @"64" };
|
||||
|
||||
const PcRange = struct {
|
||||
start: u64,
|
||||
|
@ -1112,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);
|
||||
@ -4490,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"),
|
||||
}
|
||||
}
|
||||
|
@ -3870,13 +3870,62 @@ flagpd1("gcodeview-command-line"),
|
||||
flagpd1("gcodeview-ghash"),
|
||||
flagpd1("gcolumn-info"),
|
||||
flagpd1("gdbx"),
|
||||
flagpd1("gdwarf"),
|
||||
flagpd1("gdwarf32"),
|
||||
flagpd1("gdwarf64"),
|
||||
flagpd1("gdwarf-2"),
|
||||
flagpd1("gdwarf-3"),
|
||||
flagpd1("gdwarf-4"),
|
||||
flagpd1("gdwarf-5"),
|
||||
.{
|
||||
.name = "gdwarf",
|
||||
.syntax = .flag,
|
||||
.zig_equivalent = .debug,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
.{
|
||||
.name = "gdwarf32",
|
||||
.syntax = .flag,
|
||||
.zig_equivalent = .gdwarf32,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
.{
|
||||
.name = "gdwarf64",
|
||||
.syntax = .flag,
|
||||
.zig_equivalent = .gdwarf64,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
.{
|
||||
.name = "gdwarf-2",
|
||||
.syntax = .flag,
|
||||
.zig_equivalent = .debug,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
.{
|
||||
.name = "gdwarf-3",
|
||||
.syntax = .flag,
|
||||
.zig_equivalent = .debug,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
.{
|
||||
.name = "gdwarf-4",
|
||||
.syntax = .flag,
|
||||
.zig_equivalent = .debug,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
.{
|
||||
.name = "gdwarf-5",
|
||||
.syntax = .flag,
|
||||
.zig_equivalent = .debug,
|
||||
.pd1 = true,
|
||||
.pd2 = false,
|
||||
.psl = false,
|
||||
},
|
||||
flagpd1("gdwarf-aranges"),
|
||||
flagpd1("gembed-source"),
|
||||
sepd1("gen-cdb-fragment-path"),
|
||||
|
@ -433,14 +433,7 @@ pub const Object = struct {
|
||||
if (!options.strip) {
|
||||
switch (options.target.ofmt) {
|
||||
.coff => llvm_module.addModuleCodeViewFlag(),
|
||||
else => {
|
||||
const dwarf_format = options.dwarf_format orelse .dwarf32;
|
||||
const produce_dwarf64 = switch (dwarf_format) {
|
||||
.dwarf32 => false,
|
||||
.dwarf64 => true,
|
||||
};
|
||||
llvm_module.addModuleDebugInfoFlag(produce_dwarf64);
|
||||
},
|
||||
else => llvm_module.addModuleDebugInfoFlag(options.dwarf_format == std.dwarf.Format.@"64"),
|
||||
}
|
||||
const di_builder = llvm_module.createDIBuilder(true);
|
||||
opt_di_builder = di_builder;
|
||||
|
@ -200,7 +200,7 @@ pub const Options = struct {
|
||||
compatibility_version: ?std.builtin.Version,
|
||||
libc_installation: ?*const LibCInstallation,
|
||||
|
||||
dwarf_format: ?std.dwarf.Format = null,
|
||||
dwarf_format: ?std.dwarf.Format,
|
||||
|
||||
/// WASI-only. Type of WASI execution model ("command" or "reactor").
|
||||
wasi_exec_model: std.builtin.WasiExecModel = undefined,
|
||||
|
14
src/main.zig
14
src/main.zig
@ -1357,9 +1357,9 @@ fn buildOutputType(
|
||||
} else if (mem.eql(u8, arg, "-fno-strip")) {
|
||||
strip = false;
|
||||
} else if (mem.eql(u8, arg, "-gdwarf32")) {
|
||||
dwarf_format = .dwarf32;
|
||||
dwarf_format = .@"32";
|
||||
} else if (mem.eql(u8, arg, "-gdwarf64")) {
|
||||
dwarf_format = .dwarf64;
|
||||
dwarf_format = .@"64";
|
||||
} else if (mem.eql(u8, arg, "-fformatted-panics")) {
|
||||
formatted_panics = true;
|
||||
} else if (mem.eql(u8, arg, "-fno-formatted-panics")) {
|
||||
@ -1767,6 +1767,14 @@ fn buildOutputType(
|
||||
try clang_argv.appendSlice(it.other_args);
|
||||
}
|
||||
},
|
||||
.gdwarf32 => {
|
||||
strip = false;
|
||||
dwarf_format = .@"32";
|
||||
},
|
||||
.gdwarf64 => {
|
||||
strip = false;
|
||||
dwarf_format = .@"64";
|
||||
},
|
||||
.sanitize => {
|
||||
if (mem.eql(u8, it.only_arg, "undefined")) {
|
||||
want_sanitize_c = true;
|
||||
@ -5108,6 +5116,8 @@ pub const ClangArgIterator = struct {
|
||||
asm_only,
|
||||
optimize,
|
||||
debug,
|
||||
gdwarf32,
|
||||
gdwarf64,
|
||||
sanitize,
|
||||
linker_script,
|
||||
dry_run,
|
||||
|
@ -241,23 +241,31 @@ const known_options = [_]KnownOpt{
|
||||
.ident = "debug",
|
||||
},
|
||||
.{
|
||||
.name = "g-dwarf",
|
||||
.name = "gdwarf32",
|
||||
.ident = "gdwarf32",
|
||||
},
|
||||
.{
|
||||
.name = "gdwarf64",
|
||||
.ident = "gdwarf64",
|
||||
},
|
||||
.{
|
||||
.name = "gdwarf",
|
||||
.ident = "debug",
|
||||
},
|
||||
.{
|
||||
.name = "g-dwarf-2",
|
||||
.name = "gdwarf-2",
|
||||
.ident = "debug",
|
||||
},
|
||||
.{
|
||||
.name = "g-dwarf-3",
|
||||
.name = "gdwarf-3",
|
||||
.ident = "debug",
|
||||
},
|
||||
.{
|
||||
.name = "g-dwarf-4",
|
||||
.name = "gdwarf-4",
|
||||
.ident = "debug",
|
||||
},
|
||||
.{
|
||||
.name = "g-dwarf-5",
|
||||
.name = "gdwarf-5",
|
||||
.ident = "debug",
|
||||
},
|
||||
.{
|
||||
|
Loading…
Reference in New Issue
Block a user