Skip to content

Commit 246c990

Browse files
committed
Auto merge of #116702 - durin42:compress-debuginfo, r=compiler-errors
linker: also pass debuginfo compression flags We support compressing debuginfo during codegen, but until this patch we didn't pass the flag to the linker. Doing so means we'll respect the requested compression even when building binaries or dylibs. This produces much smaller binaries: in my testing a debug build of ripgrep goes from 85M to 32M, and the target/ directory (after a clean build in both cases) goes from 508M to 329M just by enabling zlib compression of debuginfo.
2 parents fcab248 + 3215725 commit 246c990

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

compiler/rustc_codegen_ssa/src/back/linker.rs

+9
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,15 @@ impl<'a> Linker for GccLinker<'a> {
626626
self.linker_arg("--strip-all");
627627
}
628628
}
629+
match self.sess.opts.unstable_opts.debuginfo_compression {
630+
config::DebugInfoCompression::None => {}
631+
config::DebugInfoCompression::Zlib => {
632+
self.linker_arg("--compress-debug-sections=zlib");
633+
}
634+
config::DebugInfoCompression::Zstd => {
635+
self.linker_arg("--compress-debug-sections=zstd");
636+
}
637+
}
629638
}
630639

631640
fn no_crt_objects(&mut self) {

0 commit comments

Comments
 (0)