| author | |
| committer | |
| log | a833bdcd7e6fcfee6e9cc33a3f7de78b16a36941 |
| tree | 5b45c1662789e9743d328356167b3dce72495bfd |
| parent | ab4b26d8a6a36ccf75af8e25f0a1f7b88063b76f |
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.4 files changed, 33 insertions(+), 0 deletions(-)
src/Compilation.zig+6| ... | ... | @@ -878,6 +878,9 @@ pub const InitOptions = struct { |
| 878 | 878 | linker_shared_memory: bool = false, |
| 879 | 879 | linker_global_base: ?u64 = null, |
| 880 | 880 | linker_export_symbol_names: []const []const u8 = &.{}, |
| 881 | linker_print_gc_sections: bool = false, | |
| 882 | linker_print_icf_sections: bool = false, | |
| 883 | linker_print_map: bool = false, | |
| 881 | 884 | each_lib_rpath: ?bool = null, |
| 882 | 885 | build_id: ?bool = null, |
| 883 | 886 | disable_c_depfile: bool = false, |
| ... | ... | @@ -1727,6 +1730,9 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1727 | 1730 | .shared_memory = options.linker_shared_memory, |
| 1728 | 1731 | .global_base = options.linker_global_base, |
| 1729 | 1732 | .export_symbol_names = options.linker_export_symbol_names, |
| 1733 | .print_gc_sections = options.linker_print_gc_sections, | |
| 1734 | .print_icf_sections = options.linker_print_icf_sections, | |
| 1735 | .print_map = options.linker_print_map, | |
| 1730 | 1736 | .z_nodelete = options.linker_z_nodelete, |
| 1731 | 1737 | .z_notext = options.linker_z_notext, |
| 1732 | 1738 | .z_defs = options.linker_z_defs, |
src/link.zig+3| ... | ... | @@ -166,6 +166,9 @@ pub const Options = struct { |
| 166 | 166 | version_script: ?[]const u8, |
| 167 | 167 | soname: ?[]const u8, |
| 168 | 168 | llvm_cpu_features: ?[*:0]const u8, |
| 169 | print_gc_sections: bool, | |
| 170 | print_icf_sections: bool, | |
| 171 | print_map: bool, | |
| 169 | 172 | |
| 170 | 173 | objects: []Compilation.LinkObject, |
| 171 | 174 | framework_dirs: []const []const u8, |
src/link/Elf.zig+12| ... | ... | @@ -1482,6 +1482,18 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v |
| 1482 | 1482 | try argv.append("--gc-sections"); |
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | if (self.base.options.print_gc_sections) { | |
| 1486 | try argv.append("--print-gc-sections"); | |
| 1487 | } | |
| 1488 | ||
| 1489 | if (self.base.options.print_icf_sections) { | |
| 1490 | try argv.append("--print-icf-sections"); | |
| 1491 | } | |
| 1492 | ||
| 1493 | if (self.base.options.print_map) { | |
| 1494 | try argv.append("--print-map"); | |
| 1495 | } | |
| 1496 | ||
| 1485 | 1497 | if (self.base.options.eh_frame_hdr) { |
| 1486 | 1498 | try argv.append("--eh-frame-hdr"); |
| 1487 | 1499 | } |
src/main.zig+12| ... | ... | @@ -691,6 +691,9 @@ fn buildOutputType( |
| 691 | 691 | var linker_max_memory: ?u64 = null; |
| 692 | 692 | var linker_shared_memory: bool = false; |
| 693 | 693 | var linker_global_base: ?u64 = null; |
| 694 | var linker_print_gc_sections: bool = false; | |
| 695 | var linker_print_icf_sections: bool = false; | |
| 696 | var linker_print_map: bool = false; | |
| 694 | 697 | var linker_z_nodelete = false; |
| 695 | 698 | var linker_z_notext = false; |
| 696 | 699 | var linker_z_defs = false; |
| ... | ... | @@ -1816,6 +1819,12 @@ fn buildOutputType( |
| 1816 | 1819 | linker_gc_sections = true; |
| 1817 | 1820 | } else if (mem.eql(u8, arg, "--no-gc-sections")) { |
| 1818 | 1821 | linker_gc_sections = false; |
| 1822 | } else if (mem.eql(u8, arg, "--print-gc-sections")) { | |
| 1823 | linker_print_gc_sections = true; | |
| 1824 | } else if (mem.eql(u8, arg, "--print-icf-sections")) { | |
| 1825 | linker_print_icf_sections = true; | |
| 1826 | } else if (mem.eql(u8, arg, "--print-map")) { | |
| 1827 | linker_print_map = true; | |
| 1819 | 1828 | } else if (mem.eql(u8, arg, "--allow-shlib-undefined") or |
| 1820 | 1829 | mem.eql(u8, arg, "-allow-shlib-undefined")) |
| 1821 | 1830 | { |
| ... | ... | @@ -2911,6 +2920,9 @@ fn buildOutputType( |
| 2911 | 2920 | .linker_initial_memory = linker_initial_memory, |
| 2912 | 2921 | .linker_max_memory = linker_max_memory, |
| 2913 | 2922 | .linker_shared_memory = linker_shared_memory, |
| 2923 | .linker_print_gc_sections = linker_print_gc_sections, | |
| 2924 | .linker_print_icf_sections = linker_print_icf_sections, | |
| 2925 | .linker_print_map = linker_print_map, | |
| 2914 | 2926 | .linker_global_base = linker_global_base, |
| 2915 | 2927 | .linker_export_symbol_names = linker_export_symbol_names.items, |
| 2916 | 2928 | .linker_z_nodelete = linker_z_nodelete, |