From ce48f5f396e37516e8f29680f4b5c7071375f2fc Mon Sep 17 00:00:00 2001 From: Chris Wailes Date: Wed, 29 Jan 2025 15:18:17 -0800 Subject: Do not perform LTO for Rust binaries during eng builds Test: TH Bug: 289094772 Change-Id: I4221a398a2afd3c83298ee9935634b7a6189f487 --- rust/compiler.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'rust/compiler.go') diff --git a/rust/compiler.go b/rust/compiler.go index 1d2fb58c3..8ea5769a0 100644 --- a/rust/compiler.go +++ b/rust/compiler.go @@ -450,6 +450,11 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag } } + // Enable LTO for non-engineering builds if the module supports and requests it. + if !ctx.Config().Eng() && !(ctx.RustModule().Rlib() || ctx.RustModule().ProcMacro()) && ctx.RustModule().compiler.Thinlto() { + flags.GlobalRustFlags = append(flags.GlobalRustFlags, "-C lto=thin") + } + flags.RustFlags = append(flags.RustFlags, lintFlags) flags.RustFlags = append(flags.RustFlags, compiler.Properties.Flags...) flags.RustFlags = append(flags.RustFlags, "--edition="+compiler.edition()) -- cgit v1.2.3-59-g8ed1b