Use zstd to compress debug info in cc libraries
We can save a significant amount of disk space by compressing
debug info in `lld` cc builds. This change configures a build
flag to instruct lld to compress debug info when building cc
libraries. Rather than adding a global config we add this to
each target individually to avoid linker failures on windows
cross build targets.
Test: m
Bug: 305277519
Change-Id: I4ab3d47fb0de7e31a39fb671cccde1acee3a2018
diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go
index 93aa82e..f95da0b 100644
--- a/cc/config/x86_linux_host.go
+++ b/cc/config/x86_linux_host.go
@@ -59,6 +59,10 @@
"--gcc-toolchain=${LinuxGccRoot}",
}
+ linuxLldflags = append(linuxLdflags,
+ "-Wl,--compress-debug-sections=zstd",
+ )
+
linuxGlibcLdflags = []string{
"--sysroot ${LinuxGccRoot}/sysroot",
}
@@ -138,7 +142,7 @@
exportedVars.ExportStringListStaticVariable("LinuxCflags", linuxCflags)
exportedVars.ExportStringListStaticVariable("LinuxLdflags", linuxLdflags)
- exportedVars.ExportStringListStaticVariable("LinuxLldflags", linuxLdflags)
+ exportedVars.ExportStringListStaticVariable("LinuxLldflags", linuxLldflags)
exportedVars.ExportStringListStaticVariable("LinuxGlibcCflags", linuxGlibcCflags)
exportedVars.ExportStringListStaticVariable("LinuxGlibcLdflags", linuxGlibcLdflags)
exportedVars.ExportStringListStaticVariable("LinuxGlibcLldflags", linuxGlibcLdflags)