Skip to content

Commit fd9b55a

Browse files
motiejusandrewrk
authored andcommitted
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 parent c1f3aca commit fd9b55a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/std/build.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

0 commit comments

Comments
 (0)