Merge "Modify the product variable Build_from_text_stub value" into main
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 11cd041..5b2519d 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -127,106 +127,107 @@
 		"development/samples/WiFiDirectDemo":          Bp2BuildDefaultTrue,
 		"development/sdk":                             Bp2BuildDefaultTrueRecursively,
 
-		"external/aac":                           Bp2BuildDefaultTrueRecursively,
-		"external/abseil-cpp":                    Bp2BuildDefaultTrueRecursively,
-		"external/arm-optimized-routines":        Bp2BuildDefaultTrueRecursively,
-		"external/auto":                          Bp2BuildDefaultTrue,
-		"external/auto/android-annotation-stubs": Bp2BuildDefaultTrueRecursively,
-		"external/auto/common":                   Bp2BuildDefaultTrueRecursively,
-		"external/auto/service":                  Bp2BuildDefaultTrueRecursively,
-		"external/auto/value":                    Bp2BuildDefaultTrueRecursively,
-		"external/boringssl":                     Bp2BuildDefaultTrueRecursively,
-		"external/bouncycastle":                  Bp2BuildDefaultTrue,
-		"external/brotli":                        Bp2BuildDefaultTrue,
-		"external/bsdiff":                        Bp2BuildDefaultTrueRecursively,
-		"external/bzip2":                         Bp2BuildDefaultTrueRecursively,
-		"external/clang/lib":                     Bp2BuildDefaultTrue,
-		"external/conscrypt":                     Bp2BuildDefaultTrue,
-		"external/dexmaker":                      Bp2BuildDefaultTrueRecursively,
-		"external/e2fsprogs":                     Bp2BuildDefaultTrueRecursively,
-		"external/eigen":                         Bp2BuildDefaultTrueRecursively,
-		"external/erofs-utils":                   Bp2BuildDefaultTrueRecursively,
-		"external/error_prone":                   Bp2BuildDefaultTrueRecursively,
-		"external/escapevelocity":                Bp2BuildDefaultTrueRecursively,
-		"external/expat":                         Bp2BuildDefaultTrueRecursively,
-		"external/f2fs-tools":                    Bp2BuildDefaultTrue,
-		"external/flac":                          Bp2BuildDefaultTrueRecursively,
-		"external/flatbuffers":                   Bp2BuildDefaultTrueRecursively,
-		"external/fmtlib":                        Bp2BuildDefaultTrueRecursively,
-		"external/fsverity-utils":                Bp2BuildDefaultTrueRecursively,
-		"external/gflags":                        Bp2BuildDefaultTrueRecursively,
-		"external/google-benchmark":              Bp2BuildDefaultTrueRecursively,
-		"external/googletest":                    Bp2BuildDefaultTrueRecursively,
-		"external/guava":                         Bp2BuildDefaultTrueRecursively,
-		"external/gwp_asan":                      Bp2BuildDefaultTrueRecursively,
-		"external/hamcrest":                      Bp2BuildDefaultTrueRecursively,
-		"external/icu":                           Bp2BuildDefaultTrueRecursively,
-		"external/icu/android_icu4j":             Bp2BuildDefaultFalse, // java rules incomplete
-		"external/icu/icu4j":                     Bp2BuildDefaultFalse, // java rules incomplete
-		"external/jacoco":                        Bp2BuildDefaultTrueRecursively,
-		"external/jarjar":                        Bp2BuildDefaultTrueRecursively,
-		"external/javaparser":                    Bp2BuildDefaultTrueRecursively,
-		"external/javapoet":                      Bp2BuildDefaultTrueRecursively,
-		"external/javassist":                     Bp2BuildDefaultTrueRecursively,
-		"external/jemalloc_new":                  Bp2BuildDefaultTrueRecursively,
-		"external/jsoncpp":                       Bp2BuildDefaultTrueRecursively,
-		"external/jsr305":                        Bp2BuildDefaultTrueRecursively,
-		"external/jsr330":                        Bp2BuildDefaultTrueRecursively,
-		"external/junit":                         Bp2BuildDefaultTrueRecursively,
-		"external/kotlinc":                       Bp2BuildDefaultTrueRecursively,
-		"external/kotlinx.coroutines":            Bp2BuildDefaultTrueRecursively,
-		"external/libaom":                        Bp2BuildDefaultTrueRecursively,
-		"external/libavc":                        Bp2BuildDefaultTrueRecursively,
-		"external/libcap":                        Bp2BuildDefaultTrueRecursively,
-		"external/libcxx":                        Bp2BuildDefaultTrueRecursively,
-		"external/libcxxabi":                     Bp2BuildDefaultTrueRecursively,
-		"external/libdivsufsort":                 Bp2BuildDefaultTrueRecursively,
-		"external/libdrm":                        Bp2BuildDefaultTrue,
-		"external/libevent":                      Bp2BuildDefaultTrueRecursively,
-		"external/libgav1":                       Bp2BuildDefaultTrueRecursively,
-		"external/libhevc":                       Bp2BuildDefaultTrueRecursively,
-		"external/libjpeg-turbo":                 Bp2BuildDefaultTrueRecursively,
-		"external/libmpeg2":                      Bp2BuildDefaultTrueRecursively,
-		"external/libphonenumber":                Bp2BuildDefaultTrueRecursively,
-		"external/libpng":                        Bp2BuildDefaultTrueRecursively,
-		"external/libvpx":                        Bp2BuildDefaultTrueRecursively,
-		"external/libyuv":                        Bp2BuildDefaultTrueRecursively,
-		"external/lz4/lib":                       Bp2BuildDefaultTrue,
-		"external/lz4/programs":                  Bp2BuildDefaultTrue,
-		"external/lzma/C":                        Bp2BuildDefaultTrueRecursively,
-		"external/mdnsresponder":                 Bp2BuildDefaultTrueRecursively,
-		"external/minijail":                      Bp2BuildDefaultTrueRecursively,
-		"external/mockito":                       Bp2BuildDefaultTrueRecursively,
-		"external/musl":                          Bp2BuildDefaultTrueRecursively,
-		"external/objenesis":                     Bp2BuildDefaultTrueRecursively,
-		"external/openscreen":                    Bp2BuildDefaultTrueRecursively,
-		"external/ow2-asm":                       Bp2BuildDefaultTrueRecursively,
-		"external/pcre":                          Bp2BuildDefaultTrueRecursively,
-		"external/perfmark/api":                  Bp2BuildDefaultTrueRecursively,
-		"external/perfetto":                      Bp2BuildDefaultTrue,
-		"external/protobuf":                      Bp2BuildDefaultTrueRecursively,
-		"external/python/jinja/src":              Bp2BuildDefaultTrueRecursively,
-		"external/python/markupsafe/src":         Bp2BuildDefaultTrueRecursively,
-		"external/python/pyfakefs/pyfakefs":      Bp2BuildDefaultTrueRecursively,
-		"external/python/pyyaml/lib/yaml":        Bp2BuildDefaultTrueRecursively,
-		"external/python/setuptools":             Bp2BuildDefaultTrueRecursively,
-		"external/python/six":                    Bp2BuildDefaultTrueRecursively,
-		"external/rappor":                        Bp2BuildDefaultTrueRecursively,
-		"external/rust/crates/rustc-demangle":    Bp2BuildDefaultTrueRecursively,
-		"external/scudo":                         Bp2BuildDefaultTrueRecursively,
-		"external/selinux/checkpolicy":           Bp2BuildDefaultTrueRecursively,
-		"external/selinux/libselinux":            Bp2BuildDefaultTrueRecursively,
-		"external/selinux/libsepol":              Bp2BuildDefaultTrueRecursively,
-		"external/speex":                         Bp2BuildDefaultTrueRecursively,
-		"external/sqlite":                        Bp2BuildDefaultTrueRecursively,
-		"external/tinyalsa":                      Bp2BuildDefaultTrueRecursively,
-		"external/tinyalsa_new":                  Bp2BuildDefaultTrueRecursively,
-		"external/toybox":                        Bp2BuildDefaultTrueRecursively,
-		"external/truth":                         Bp2BuildDefaultTrueRecursively,
-		"external/xz-java":                       Bp2BuildDefaultTrueRecursively,
-		"external/zlib":                          Bp2BuildDefaultTrueRecursively,
-		"external/zopfli":                        Bp2BuildDefaultTrueRecursively,
-		"external/zstd":                          Bp2BuildDefaultTrueRecursively,
+		"external/aac":                             Bp2BuildDefaultTrueRecursively,
+		"external/abseil-cpp":                      Bp2BuildDefaultTrueRecursively,
+		"external/arm-optimized-routines":          Bp2BuildDefaultTrueRecursively,
+		"external/auto":                            Bp2BuildDefaultTrue,
+		"external/auto/android-annotation-stubs":   Bp2BuildDefaultTrueRecursively,
+		"external/auto/common":                     Bp2BuildDefaultTrueRecursively,
+		"external/auto/service":                    Bp2BuildDefaultTrueRecursively,
+		"external/auto/value":                      Bp2BuildDefaultTrueRecursively,
+		"external/boringssl":                       Bp2BuildDefaultTrueRecursively,
+		"external/bouncycastle":                    Bp2BuildDefaultTrue,
+		"external/brotli":                          Bp2BuildDefaultTrue,
+		"external/bsdiff":                          Bp2BuildDefaultTrueRecursively,
+		"external/bzip2":                           Bp2BuildDefaultTrueRecursively,
+		"external/clang/lib":                       Bp2BuildDefaultTrue,
+		"external/conscrypt":                       Bp2BuildDefaultTrue,
+		"external/dexmaker":                        Bp2BuildDefaultTrueRecursively,
+		"external/e2fsprogs":                       Bp2BuildDefaultTrueRecursively,
+		"external/eigen":                           Bp2BuildDefaultTrueRecursively,
+		"external/erofs-utils":                     Bp2BuildDefaultTrueRecursively,
+		"external/error_prone":                     Bp2BuildDefaultTrueRecursively,
+		"external/escapevelocity":                  Bp2BuildDefaultTrueRecursively,
+		"external/expat":                           Bp2BuildDefaultTrueRecursively,
+		"external/f2fs-tools":                      Bp2BuildDefaultTrue,
+		"external/flac":                            Bp2BuildDefaultTrueRecursively,
+		"external/flatbuffers":                     Bp2BuildDefaultTrueRecursively,
+		"external/fmtlib":                          Bp2BuildDefaultTrueRecursively,
+		"external/fsverity-utils":                  Bp2BuildDefaultTrueRecursively,
+		"external/gflags":                          Bp2BuildDefaultTrueRecursively,
+		"external/google-benchmark":                Bp2BuildDefaultTrueRecursively,
+		"external/googletest":                      Bp2BuildDefaultTrueRecursively,
+		"external/guava":                           Bp2BuildDefaultTrueRecursively,
+		"external/gwp_asan":                        Bp2BuildDefaultTrueRecursively,
+		"external/hamcrest":                        Bp2BuildDefaultTrueRecursively,
+		"external/icu":                             Bp2BuildDefaultTrueRecursively,
+		"external/icu/android_icu4j":               Bp2BuildDefaultFalse, // java rules incomplete
+		"external/icu/icu4j":                       Bp2BuildDefaultFalse, // java rules incomplete
+		"external/jacoco":                          Bp2BuildDefaultTrueRecursively,
+		"external/jarjar":                          Bp2BuildDefaultTrueRecursively,
+		"external/javaparser":                      Bp2BuildDefaultTrueRecursively,
+		"external/javapoet":                        Bp2BuildDefaultTrueRecursively,
+		"external/javassist":                       Bp2BuildDefaultTrueRecursively,
+		"external/jemalloc_new":                    Bp2BuildDefaultTrueRecursively,
+		"external/jsoncpp":                         Bp2BuildDefaultTrueRecursively,
+		"external/jsr305":                          Bp2BuildDefaultTrueRecursively,
+		"external/jsr330":                          Bp2BuildDefaultTrueRecursively,
+		"external/junit":                           Bp2BuildDefaultTrueRecursively,
+		"external/kotlinc":                         Bp2BuildDefaultTrueRecursively,
+		"external/kotlinx.coroutines":              Bp2BuildDefaultTrueRecursively,
+		"external/libaom":                          Bp2BuildDefaultTrueRecursively,
+		"external/libavc":                          Bp2BuildDefaultTrueRecursively,
+		"external/libcap":                          Bp2BuildDefaultTrueRecursively,
+		"external/libcxx":                          Bp2BuildDefaultTrueRecursively,
+		"external/libcxxabi":                       Bp2BuildDefaultTrueRecursively,
+		"external/libdivsufsort":                   Bp2BuildDefaultTrueRecursively,
+		"external/libdrm":                          Bp2BuildDefaultTrue,
+		"external/libevent":                        Bp2BuildDefaultTrueRecursively,
+		"external/libgav1":                         Bp2BuildDefaultTrueRecursively,
+		"external/libhevc":                         Bp2BuildDefaultTrueRecursively,
+		"external/libjpeg-turbo":                   Bp2BuildDefaultTrueRecursively,
+		"external/libmpeg2":                        Bp2BuildDefaultTrueRecursively,
+		"external/libphonenumber":                  Bp2BuildDefaultTrueRecursively,
+		"external/libpng":                          Bp2BuildDefaultTrueRecursively,
+		"external/libvpx":                          Bp2BuildDefaultTrueRecursively,
+		"external/libyuv":                          Bp2BuildDefaultTrueRecursively,
+		"external/lz4/lib":                         Bp2BuildDefaultTrue,
+		"external/lz4/programs":                    Bp2BuildDefaultTrue,
+		"external/lzma/C":                          Bp2BuildDefaultTrueRecursively,
+		"external/mdnsresponder":                   Bp2BuildDefaultTrueRecursively,
+		"external/minijail":                        Bp2BuildDefaultTrueRecursively,
+		"external/mockito":                         Bp2BuildDefaultTrueRecursively,
+		"external/musl":                            Bp2BuildDefaultTrueRecursively,
+		"external/objenesis":                       Bp2BuildDefaultTrueRecursively,
+		"external/openscreen":                      Bp2BuildDefaultTrueRecursively,
+		"external/ow2-asm":                         Bp2BuildDefaultTrueRecursively,
+		"external/pcre":                            Bp2BuildDefaultTrueRecursively,
+		"external/perfmark/api":                    Bp2BuildDefaultTrueRecursively,
+		"external/perfetto":                        Bp2BuildDefaultTrue,
+		"external/protobuf":                        Bp2BuildDefaultTrueRecursively,
+		"external/python/jinja/src":                Bp2BuildDefaultTrueRecursively,
+		"external/python/markupsafe/src":           Bp2BuildDefaultTrueRecursively,
+		"external/python/pyfakefs/pyfakefs":        Bp2BuildDefaultTrueRecursively,
+		"external/python/pyyaml/lib/yaml":          Bp2BuildDefaultTrueRecursively,
+		"external/python/setuptools":               Bp2BuildDefaultTrueRecursively,
+		"external/python/six":                      Bp2BuildDefaultTrueRecursively,
+		"external/rappor":                          Bp2BuildDefaultTrueRecursively,
+		"external/rust/crates/rustc-demangle":      Bp2BuildDefaultTrueRecursively,
+		"external/rust/crates/rustc-demangle-capi": Bp2BuildDefaultTrueRecursively,
+		"external/scudo":                           Bp2BuildDefaultTrueRecursively,
+		"external/selinux/checkpolicy":             Bp2BuildDefaultTrueRecursively,
+		"external/selinux/libselinux":              Bp2BuildDefaultTrueRecursively,
+		"external/selinux/libsepol":                Bp2BuildDefaultTrueRecursively,
+		"external/speex":                           Bp2BuildDefaultTrueRecursively,
+		"external/sqlite":                          Bp2BuildDefaultTrueRecursively,
+		"external/tinyalsa":                        Bp2BuildDefaultTrueRecursively,
+		"external/tinyalsa_new":                    Bp2BuildDefaultTrueRecursively,
+		"external/toybox":                          Bp2BuildDefaultTrueRecursively,
+		"external/truth":                           Bp2BuildDefaultTrueRecursively,
+		"external/xz-java":                         Bp2BuildDefaultTrueRecursively,
+		"external/zlib":                            Bp2BuildDefaultTrueRecursively,
+		"external/zopfli":                          Bp2BuildDefaultTrueRecursively,
+		"external/zstd":                            Bp2BuildDefaultTrueRecursively,
 
 		"frameworks/av": Bp2BuildDefaultTrue,
 		"frameworks/av/media/audioaidlconversion":                              Bp2BuildDefaultTrueRecursively,
@@ -536,9 +537,6 @@
 		"tools/asuite/atest":/* recursive = */ false,
 		"tools/asuite/atest/bazel/reporter":/* recursive = */ true,
 
-		// TODO(b/266459895): remove this and the placeholder BUILD file after re-enabling libunwindstack
-		"external/rust/crates/rustc-demangle-capi":/* recursive = */ false,
-
 		// Used for testing purposes only. Should not actually exist in the real source tree.
 		"testpkg/keep_build_file":/* recursive = */ false,
 	}
diff --git a/android/plugin.go b/android/plugin.go
index 4672453..2c7f9ff 100644
--- a/android/plugin.go
+++ b/android/plugin.go
@@ -16,8 +16,6 @@
 
 import (
 	"encoding/json"
-	"fmt"
-	"io/ioutil"
 	"os"
 	"strings"
 
@@ -72,28 +70,31 @@
 	"xsdc-soong-rules":                       true,
 }
 
-const (
-	internalPluginsPath = "vendor/google/build/soong/internal_plugins.json"
-)
+var internalPluginsPaths = []string{
+	"vendor/google/build/soong/internal_plugins.json",
+	"vendor/google_clockwork/build/internal_plugins.json",
+}
 
 type pluginProvider interface {
 	IsPluginFor(string) bool
 }
 
 func maybeAddInternalPluginsToAllowlist(ctx SingletonContext) {
-	if path := ExistentPathForSource(ctx, internalPluginsPath); path.Valid() {
-		ctx.AddNinjaFileDeps(path.String())
-		absPath := absolutePath(path.String())
-		var moreAllowed map[string]bool
-		data, err := ioutil.ReadFile(absPath)
-		if err != nil {
-			ctx.Errorf("Failed to open internal plugins path %q %q", internalPluginsPath, err)
-		}
-		if err := json.Unmarshal(data, &moreAllowed); err != nil {
-			fmt.Fprintf(os.Stderr, "Internal plugins file %q did not parse correctly: %q", data, err)
-		}
-		for k, v := range moreAllowed {
-			allowedPluginsByName[k] = v
+	for _, internalPluginsPath := range internalPluginsPaths {
+		if path := ExistentPathForSource(ctx, internalPluginsPath); path.Valid() {
+			ctx.AddNinjaFileDeps(path.String())
+			absPath := absolutePath(path.String())
+			var moreAllowed map[string]bool
+			data, err := os.ReadFile(absPath)
+			if err != nil {
+				ctx.Errorf("Failed to open internal plugins path %q %q", internalPluginsPath, err)
+			}
+			if err := json.Unmarshal(data, &moreAllowed); err != nil {
+				ctx.Errorf("Internal plugins file %q did not parse correctly: %q", data, err)
+			}
+			for k, v := range moreAllowed {
+				allowedPluginsByName[k] = v
+			}
 		}
 	}
 }
diff --git a/cc/config/arm64_linux_host.go b/cc/config/arm64_linux_host.go
index 9f5124b..335ad56 100644
--- a/cc/config/arm64_linux_host.go
+++ b/cc/config/arm64_linux_host.go
@@ -46,6 +46,10 @@
 		"-Wl,--no-undefined-version",
 	}
 
+	linuxCrossLldflags = append(linuxCrossLdflags,
+		"-Wl,--compress-debug-sections=zstd",
+	)
+
 	// Embed the linker into host bionic binaries. This is needed to support host bionic,
 	// as the linux kernel requires that the ELF interpreter referenced by PT_INTERP be
 	// either an absolute path, or relative from CWD. To work around this, we extract
@@ -60,6 +64,7 @@
 func init() {
 	exportedVars.ExportStringListStaticVariable("LinuxBionicArm64Cflags", linuxCrossCflags)
 	exportedVars.ExportStringListStaticVariable("LinuxBionicArm64Ldflags", linuxCrossLdflags)
+	exportedVars.ExportStringListStaticVariable("LinuxBionicArm64Lldflags", linuxCrossLldflags)
 }
 
 // toolchain config for ARM64 Linux CrossHost. Almost everything is the same as the ARM64 Android
diff --git a/cc/config/arm_linux_host.go b/cc/config/arm_linux_host.go
index 525fb5d..e21c60d 100644
--- a/cc/config/arm_linux_host.go
+++ b/cc/config/arm_linux_host.go
@@ -27,16 +27,24 @@
 		"-march=armv7a",
 	}
 
+	linuxArmLldflags = append(linuxArmLdflags,
+		"-Wl,--compress-debug-sections=zstd",
+	)
+
 	linuxArm64Ldflags = []string{}
+
+	linuxArm64Lldflags = append(linuxArm64Ldflags,
+		"-Wl,--compress-debug-sections=zstd",
+	)
 )
 
 func init() {
 	exportedVars.ExportStringListStaticVariable("LinuxArmCflags", linuxArmCflags)
 	exportedVars.ExportStringListStaticVariable("LinuxArm64Cflags", linuxArm64Cflags)
 	exportedVars.ExportStringListStaticVariable("LinuxArmLdflags", linuxArmLdflags)
-	exportedVars.ExportStringListStaticVariable("LinuxArmLldflags", linuxArmLdflags)
+	exportedVars.ExportStringListStaticVariable("LinuxArmLldflags", linuxArmLldflags)
 	exportedVars.ExportStringListStaticVariable("LinuxArm64Ldflags", linuxArm64Ldflags)
-	exportedVars.ExportStringListStaticVariable("LinuxArm64Lldflags", linuxArm64Ldflags)
+	exportedVars.ExportStringListStaticVariable("LinuxArm64Lldflags", linuxArm64Lldflags)
 
 	exportedVars.ExportStringListStaticVariable("LinuxArmYasmFlags", []string{"-f elf32 -m arm"})
 	exportedVars.ExportStringListStaticVariable("LinuxArm64YasmFlags", []string{"-f elf64 -m aarch64"})
diff --git a/cc/config/global.go b/cc/config/global.go
index 62b008b..6668937 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -133,6 +133,9 @@
 		// Using simple template names reduces the size of debug builds.
 		"-gsimple-template-names",
 
+		// Use zstd to compress debug data.
+		"-gz=zstd",
+
 		// Make paths in deps files relative.
 		"-no-canonical-prefixes",
 	}
@@ -200,7 +203,9 @@
 		"-Wl,-mllvm,-regalloc-enable-advisor=release",
 	}
 
-	deviceGlobalLldflags = append(deviceGlobalLdflags, commonGlobalLldflags...)
+	deviceGlobalLldflags = append(append(deviceGlobalLdflags, commonGlobalLldflags...),
+		"-Wl,--compress-debug-sections=zstd",
+	)
 
 	hostGlobalCflags = []string{}
 
diff --git a/cc/config/x86_linux_bionic_host.go b/cc/config/x86_linux_bionic_host.go
index e006471..f80be99 100644
--- a/cc/config/x86_linux_bionic_host.go
+++ b/cc/config/x86_linux_bionic_host.go
@@ -53,6 +53,10 @@
 		"--gcc-toolchain=${LinuxBionicGccRoot}",
 	}
 
+	linuxBionicLldflags = append(linuxBionicLdflags,
+		"-Wl,--compress-debug-sections=zstd",
+	)
+
 	// Embed the linker into host bionic binaries. This is needed to support host bionic,
 	// as the linux kernel requires that the ELF interpreter referenced by PT_INTERP be
 	// either an absolute path, or relative from CWD. To work around this, we extract
@@ -71,7 +75,7 @@
 func init() {
 	exportedVars.ExportStringListStaticVariable("LinuxBionicCflags", linuxBionicCflags)
 	exportedVars.ExportStringListStaticVariable("LinuxBionicLdflags", linuxBionicLdflags)
-	exportedVars.ExportStringListStaticVariable("LinuxBionicLldflags", linuxBionicLdflags)
+	exportedVars.ExportStringListStaticVariable("LinuxBionicLldflags", linuxBionicLldflags)
 
 	// Use the device gcc toolchain for now
 	exportedVars.ExportStringStaticVariable("LinuxBionicGccVersion", x86_64GccVersion)
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)
diff --git a/rust/config/global.go b/rust/config/global.go
index b94d92f..4d31121 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -65,6 +65,7 @@
 		"-lpthread",
 		"-lm",
 		"-lgcc_s",
+		"-Wl,--compress-debug-sections=zstd",
 	}
 
 	deviceGlobalRustFlags = []string{
@@ -86,6 +87,7 @@
 		"-Wl,--use-android-relr-tags",
 		"-Wl,--no-undefined",
 		"-B${cc_config.ClangBin}",
+		"-Wl,--compress-debug-sections=zstd",
 	}
 )
 
diff --git a/scripts/strip.sh b/scripts/strip.sh
index d09c187..71cb1c6 100755
--- a/scripts/strip.sh
+++ b/scripts/strip.sh
@@ -98,9 +98,17 @@
     "${CLANG_BIN}/llvm-strip" --strip-all --keep-section=.ARM.attributes --remove-section=.comment "${infile}" -o "${outfile}.tmp" || fail=true
 
     if [ -z $fail ]; then
-        "${CREATE_MINIDEBUGINFO}" "${infile}" "${outfile}.mini_debuginfo.xz"
+        # create_minidebuginfo has issues with compressed debug sections. Just
+        # decompress them for now using objcopy which understands compressed
+        # debug sections.
+        # b/306150780 tracks supporting this directly in create_minidebuginfo
+        decompressed="$(mktemp)"
+        "${CLANG_BIN}/llvm-objcopy" --decompress-debug-sections \
+                "${infile}" "${decompressed}"
+
+        "${CREATE_MINIDEBUGINFO}" "${decompressed}" "${outfile}.mini_debuginfo.xz"
         "${CLANG_BIN}/llvm-objcopy" --add-section .gnu_debugdata="${outfile}.mini_debuginfo.xz" "${outfile}.tmp"
-        rm -f "${outfile}.mini_debuginfo.xz"
+        rm -f "${outfile}.mini_debuginfo.xz" "${decompressed}"
     else
         cp -f "${infile}" "${outfile}.tmp"
     fi