summaryrefslogtreecommitdiff
path: root/rust/androidmk.go
diff options
context:
space:
mode:
author ThiƩbaud Weksteen <tweek@google.com> 2020-08-27 13:48:36 +0200
committer ThiƩbaud Weksteen <tweek@google.com> 2020-08-28 10:50:17 +0200
commitfabaff6bd74cda382dd7d5152df7362bffe233a3 (patch)
treeb411acff92ba05568af230b00db941bb03e9b7b5 /rust/androidmk.go
parent31f1bb80efe196f2340ec88a6cc374963e7aa7b5 (diff)
rust: strip libraries and binaries
Reuses the cc.Stripper logic. Abstracts Stripper to avoid the spreading of references to the cc package. rustc requires unstripped libraries (precisely, with the `.rustc` section) when building dependent targets. Contrary to cc, the output of a compiler module will remain unstripped and only an extra build rule will be added. This rule will be referenced at install time (in baseCompiler.install or androidmk). This change drastically reduces the size of the installed libraries: (unstripped, from out/target/product/crosshatch/system) $ find . -name \*.dylib.so -print0 | du -c --files0-from=- 149996 total (stripped, with this change) $ find . -name \*.dylib.so -print0 | du -c --files0-from=- 42380 total Bug: 153430439 Test: cd external/rust; mma Change-Id: I94fd8bbcec97e0610aa325d3db4460be84d01734
Diffstat (limited to 'rust/androidmk.go')
-rw-r--r--rust/androidmk.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/rust/androidmk.go b/rust/androidmk.go
index fda0a2579..10f10d86f 100644
--- a/rust/androidmk.go
+++ b/rust/androidmk.go
@@ -96,7 +96,6 @@ func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.Andr
ret.Class = "EXECUTABLES"
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
- fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", binary.unstrippedOutputFile.String())
if binary.coverageOutputZipFile.Valid() {
fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE := "+binary.coverageOutputZipFile.String())
}
@@ -139,9 +138,6 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
}
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
- if !library.rlib() {
- fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", library.unstrippedOutputFile.String())
- }
if library.coverageOutputZipFile.Valid() {
fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE := "+library.coverageOutputZipFile.String())
}
@@ -180,12 +176,19 @@ func (bindgen *bindgenDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
}
func (compiler *baseCompiler) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
+ var unstrippedOutputFile android.OptionalPath
// Soong installation is only supported for host modules. Have Make
// installation trigger Soong installation.
if ctx.Target().Os.Class == android.Host {
ret.OutputFile = android.OptionalPathForPath(compiler.path)
+ } else if compiler.strippedOutputFile.Valid() {
+ unstrippedOutputFile = ret.OutputFile
+ ret.OutputFile = compiler.strippedOutputFile
}
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
+ if compiler.strippedOutputFile.Valid() {
+ fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", unstrippedOutputFile)
+ }
path, file := filepath.Split(compiler.path.ToMakePath().String())
stem, suffix, _ := android.SplitFileExt(file)
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix)