summaryrefslogtreecommitdiff
path: root/rust/compiler.go
diff options
context:
space:
mode:
author Chris Wailes <chriswailes@google.com> 2025-01-30 14:21:13 -0800
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2025-01-30 14:21:13 -0800
commitedf2829f5072e84e63ff28a0b35bcd8fcba061b4 (patch)
treee15813d6f8121fa4ee05b8dc258c2a5410d79c7e /rust/compiler.go
parente068e0cb169335d5c76a27aba7f77088c52fb060 (diff)
parentce48f5f396e37516e8f29680f4b5c7071375f2fc (diff)
Merge "Do not perform LTO for Rust binaries during eng builds" into main
Diffstat (limited to 'rust/compiler.go')
-rw-r--r--rust/compiler.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/rust/compiler.go b/rust/compiler.go
index f186ef38f..62e53bf6e 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -477,6 +477,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())