authorgravatar for motiejus@jakstys.ltMotiejus Jakštys <motiejus@jakstys.lt> 2022-07-20 14:31:04+03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-20 18:26:17-04:00
logfd9b55a6405f908237285ee8280648ad368fccfc
treee3ca2fea54f5bad1c984c7c56004eb6c4ef17ef1
parentc1f3aca6027baaae781503af579767d208f8f172

build.zig: teach `--compress-debug-sections`

Now that #11863 is landed, let's expose it to the zig programs that build stuff via `build.zig`. "Benchmarks" with [turbonss](https://git.sr.ht/~motiejus/turbonss): Built with: $ zig build -Dtarget=x86_64-linux-gnu.2.19 -Dcpu=x86_64_v3 -Drelease-small=true *Debug, uncompressed* 174K turbonss-analyze 161K turbonss-getent 1.2M turbonss-unix2db 448K libnss_turbo.so.2.0.0 *Debug, compressed* 78K turbonss-analyze 86K turbonss-getent 572K turbonss-unix2db 190K libnss_turbo.so.2.0.0 *Stripped, for completeness* 17K turbonss-analyze 20K turbonss-getent 197K turbonss-unix2db 26K libnss_turbo.so.2.0.0

1 files changed, 8 insertions(+), 0 deletions(-)

lib/std/build.zig+8
......@@ -1474,6 +1474,8 @@ pub const LibExeObjStep = struct {
14741474 major_only_filename: ?[]const u8,
14751475 name_only_filename: ?[]const u8,
14761476 strip: bool,
1477 // keep in sync with src/link.zig:CompressDebugSections
1478 compress_debug_sections: enum { none, zlib } = .none,
14771479 lib_paths: ArrayList([]const u8),
14781480 rpaths: ArrayList([]const u8),
14791481 framework_dirs: ArrayList([]const u8),
......@@ -2688,6 +2690,12 @@ pub const LibExeObjStep = struct {
26882690 if (self.strip) {
26892691 try zig_args.append("--strip");
26902692 }
2693
2694 switch (self.compress_debug_sections) {
2695 .none => {},
2696 .zlib => try zig_args.append("--compress-debug-sections=zlib"),
2697 }
2698
26912699 if (self.link_eh_frame_hdr) {
26922700 try zig_args.append("--eh-frame-hdr");
26932701 }