Browse Source

Enable LTO for Rust dylibs

Test: m rust
Test: TH
Change-Id: I2257fe9fce1457821a5cf7df644c73f3137a62bb
Chris Wailes 1 year ago
parent
commit
5f78840308
2 changed files with 3 additions and 0 deletions
  1. 2 0
      rust/builder.go
  2. 1 0
      rust/config/global.go

+ 2 - 0
rust/builder.go

@@ -134,6 +134,8 @@ func TransformSrctoRlib(ctx ModuleContext, mainSrc android.Path, deps PathDeps,
 
 func TransformSrctoDylib(ctx ModuleContext, mainSrc android.Path, deps PathDeps, flags Flags,
 	outputFile android.WritablePath) buildOutput {
+	flags.GlobalRustFlags = append(flags.GlobalRustFlags, "-C lto=thin")
+
 	return transformSrctoCrate(ctx, mainSrc, deps, flags, outputFile, "dylib")
 }
 

+ 1 - 0
rust/config/global.go

@@ -54,6 +54,7 @@ var (
 		// TODO (b/267698452): Temporary workaround until the "no unstable
 		// features" policy is enforced.
 		"-A stable-features",
+		"-Zdylib-lto",
 	}
 
 	deviceGlobalRustFlags = []string{