summaryrefslogtreecommitdiff
path: root/rust/compiler.go
diff options
context:
space:
mode:
authorThiƩbaud Weksteen <tweek@google.com>2020-08-27 13:48:36 +0200
committerThiƩbaud Weksteen <tweek@google.com>2020-08-28 10:50:17 +0200
commitfabaff6bd74cda382dd7d5152df7362bffe233a3 (patch)
treeb411acff92ba05568af230b00db941bb03e9b7b5 /rust/compiler.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/compiler.go')
-rw-r--r--rust/compiler.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/rust/compiler.go b/rust/compiler.go
index 2600f4d0f..ddf1fac3a 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -129,8 +129,9 @@ type baseCompiler struct {
location installLocation
coverageOutputZipFile android.OptionalPath
- unstrippedOutputFile android.Path
distFile android.OptionalPath
+ // Stripped output file. If Valid(), this file will be installed instead of outputFile.
+ strippedOutputFile android.OptionalPath
}
func (compiler *baseCompiler) Disabled() bool {
@@ -269,8 +270,12 @@ func (compiler *baseCompiler) nativeCoverage() bool {
return false
}
-func (compiler *baseCompiler) install(ctx ModuleContext, file android.Path) {
- compiler.path = ctx.InstallFile(compiler.installDir(ctx), file.Base(), file)
+func (compiler *baseCompiler) install(ctx ModuleContext) {
+ path := ctx.RustModule().outputFile
+ if compiler.strippedOutputFile.Valid() {
+ path = compiler.strippedOutputFile
+ }
+ compiler.path = ctx.InstallFile(compiler.installDir(ctx), path.Path().Base(), path.Path())
}
func (compiler *baseCompiler) getStem(ctx ModuleContext) string {