diff options
Diffstat (limited to 'rust/compiler.go')
-rw-r--r-- | rust/compiler.go | 5 |
1 files changed, 5 insertions, 0 deletions
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()) |