mirror of
https://github.com/ziglang/zig.git
synced 2025-12-17 03:33:06 +00:00
[ld] add --print-* for diagnostics
This adds the following for passthrough to lld: - `--print-gc-sections` - `--print-icf-sections` - `--print-map` I am not adding these to the cache manifest, since it does not change the produced artifacts. Tested with an example from #11398: it successfully prints the resulting map and the GC'd sections.
This commit is contained in:
parent
ab4b26d8a6
commit
a833bdcd7e
@ -878,6 +878,9 @@ pub const InitOptions = struct {
|
|||||||
linker_shared_memory: bool = false,
|
linker_shared_memory: bool = false,
|
||||||
linker_global_base: ?u64 = null,
|
linker_global_base: ?u64 = null,
|
||||||
linker_export_symbol_names: []const []const u8 = &.{},
|
linker_export_symbol_names: []const []const u8 = &.{},
|
||||||
|
linker_print_gc_sections: bool = false,
|
||||||
|
linker_print_icf_sections: bool = false,
|
||||||
|
linker_print_map: bool = false,
|
||||||
each_lib_rpath: ?bool = null,
|
each_lib_rpath: ?bool = null,
|
||||||
build_id: ?bool = null,
|
build_id: ?bool = null,
|
||||||
disable_c_depfile: bool = false,
|
disable_c_depfile: bool = false,
|
||||||
@ -1727,6 +1730,9 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
|
|||||||
.shared_memory = options.linker_shared_memory,
|
.shared_memory = options.linker_shared_memory,
|
||||||
.global_base = options.linker_global_base,
|
.global_base = options.linker_global_base,
|
||||||
.export_symbol_names = options.linker_export_symbol_names,
|
.export_symbol_names = options.linker_export_symbol_names,
|
||||||
|
.print_gc_sections = options.linker_print_gc_sections,
|
||||||
|
.print_icf_sections = options.linker_print_icf_sections,
|
||||||
|
.print_map = options.linker_print_map,
|
||||||
.z_nodelete = options.linker_z_nodelete,
|
.z_nodelete = options.linker_z_nodelete,
|
||||||
.z_notext = options.linker_z_notext,
|
.z_notext = options.linker_z_notext,
|
||||||
.z_defs = options.linker_z_defs,
|
.z_defs = options.linker_z_defs,
|
||||||
|
|||||||
@ -166,6 +166,9 @@ pub const Options = struct {
|
|||||||
version_script: ?[]const u8,
|
version_script: ?[]const u8,
|
||||||
soname: ?[]const u8,
|
soname: ?[]const u8,
|
||||||
llvm_cpu_features: ?[*:0]const u8,
|
llvm_cpu_features: ?[*:0]const u8,
|
||||||
|
print_gc_sections: bool,
|
||||||
|
print_icf_sections: bool,
|
||||||
|
print_map: bool,
|
||||||
|
|
||||||
objects: []Compilation.LinkObject,
|
objects: []Compilation.LinkObject,
|
||||||
framework_dirs: []const []const u8,
|
framework_dirs: []const []const u8,
|
||||||
|
|||||||
@ -1482,6 +1482,18 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
|
|||||||
try argv.append("--gc-sections");
|
try argv.append("--gc-sections");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self.base.options.print_gc_sections) {
|
||||||
|
try argv.append("--print-gc-sections");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.base.options.print_icf_sections) {
|
||||||
|
try argv.append("--print-icf-sections");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.base.options.print_map) {
|
||||||
|
try argv.append("--print-map");
|
||||||
|
}
|
||||||
|
|
||||||
if (self.base.options.eh_frame_hdr) {
|
if (self.base.options.eh_frame_hdr) {
|
||||||
try argv.append("--eh-frame-hdr");
|
try argv.append("--eh-frame-hdr");
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/main.zig
12
src/main.zig
@ -691,6 +691,9 @@ fn buildOutputType(
|
|||||||
var linker_max_memory: ?u64 = null;
|
var linker_max_memory: ?u64 = null;
|
||||||
var linker_shared_memory: bool = false;
|
var linker_shared_memory: bool = false;
|
||||||
var linker_global_base: ?u64 = null;
|
var linker_global_base: ?u64 = null;
|
||||||
|
var linker_print_gc_sections: bool = false;
|
||||||
|
var linker_print_icf_sections: bool = false;
|
||||||
|
var linker_print_map: bool = false;
|
||||||
var linker_z_nodelete = false;
|
var linker_z_nodelete = false;
|
||||||
var linker_z_notext = false;
|
var linker_z_notext = false;
|
||||||
var linker_z_defs = false;
|
var linker_z_defs = false;
|
||||||
@ -1816,6 +1819,12 @@ fn buildOutputType(
|
|||||||
linker_gc_sections = true;
|
linker_gc_sections = true;
|
||||||
} else if (mem.eql(u8, arg, "--no-gc-sections")) {
|
} else if (mem.eql(u8, arg, "--no-gc-sections")) {
|
||||||
linker_gc_sections = false;
|
linker_gc_sections = false;
|
||||||
|
} else if (mem.eql(u8, arg, "--print-gc-sections")) {
|
||||||
|
linker_print_gc_sections = true;
|
||||||
|
} else if (mem.eql(u8, arg, "--print-icf-sections")) {
|
||||||
|
linker_print_icf_sections = true;
|
||||||
|
} else if (mem.eql(u8, arg, "--print-map")) {
|
||||||
|
linker_print_map = true;
|
||||||
} else if (mem.eql(u8, arg, "--allow-shlib-undefined") or
|
} else if (mem.eql(u8, arg, "--allow-shlib-undefined") or
|
||||||
mem.eql(u8, arg, "-allow-shlib-undefined"))
|
mem.eql(u8, arg, "-allow-shlib-undefined"))
|
||||||
{
|
{
|
||||||
@ -2911,6 +2920,9 @@ fn buildOutputType(
|
|||||||
.linker_initial_memory = linker_initial_memory,
|
.linker_initial_memory = linker_initial_memory,
|
||||||
.linker_max_memory = linker_max_memory,
|
.linker_max_memory = linker_max_memory,
|
||||||
.linker_shared_memory = linker_shared_memory,
|
.linker_shared_memory = linker_shared_memory,
|
||||||
|
.linker_print_gc_sections = linker_print_gc_sections,
|
||||||
|
.linker_print_icf_sections = linker_print_icf_sections,
|
||||||
|
.linker_print_map = linker_print_map,
|
||||||
.linker_global_base = linker_global_base,
|
.linker_global_base = linker_global_base,
|
||||||
.linker_export_symbol_names = linker_export_symbol_names.items,
|
.linker_export_symbol_names = linker_export_symbol_names.items,
|
||||||
.linker_z_nodelete = linker_z_nodelete,
|
.linker_z_nodelete = linker_z_nodelete,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user