Lines Matching full:lto
26 // LTO (link-time optimization) allows the compiler to optimize and generate
28 // unit. LTO is required for Clang CFI and other whole-program optimization
29 // techniques. LTO also allows cross-compilation unit optimizations that should
33 // To properly build a module with LTO, the module and all recursive static
39 // LTO, such as CFI.
41 // This file adds support to soong to automatically propagate LTO options to a
42 // new variant of all static dependencies for each module with LTO enabled.
45 // Lto must violate capitalization style for acronyms so that it can be
46 // referred to in blueprint files as "lto"
47 Lto struct { member
58 // Use --lto-O0 flag.
62 type lto struct { struct
66 func (lto *lto) props() []interface{} { argument
67 return []interface{}{<o.Properties}
70 func (lto *lto) begin(ctx BaseModuleContext) { argument
71 // First, determine the module independent default LTO mode.
75 } else if lto.Never() {
85 // Then, determine the actual LTO mode to use. If different from `ltoDefault`, a variant needs
88 if lto.Never() {
90 } else if lto.ThinLTO() {
91 // Module explicitly requests for LTO.
94 // Do not enable LTO for tests for better debugging.
98 lto.Properties.LtoDefault = ltoDefault
99 lto.Properties.LtoEnabled = ltoEnabled
102 func (lto *lto) flags(ctx ModuleContext, flags Flags) Flags { argument
103 // TODO(b/131771163): CFI and Fuzzer controls LTO flags by themselves.
108 if lto.Properties.LtoEnabled {
109 ltoCFlags := []string{"-flto=thin", "-fsplit-lto-unit"}
112 // Do not perform costly LTO optimizations for Eng builds.
113 if Bool(lto.Properties.Lto_O0) || ctx.Config().Eng() {
114 ltoLdFlags = append(ltoLdFlags, "-Wl,--lto-O0")
117 if Bool(lto.Properties.Whole_program_vtables) {
164 func (lto *lto) ThinLTO() bool { argument
165 return lto != nil && proptools.Bool(lto.Properties.Lto.Thin)
168 func (lto *lto) Never() bool { argument
169 return lto != nil && proptools.Bool(lto.Properties.Lto.Never)
182 // ltoTransitionMutator creates LTO variants of cc modules. Variant "" is the default variant, whi…
183 // or may not have LTO enabled depending on the config and the module's type and properties. "lto-…
184 // "lto-none" variants are created when a module needs to compile in the non-default state for that…
187 const LTO_NONE_VARIATION = "lto-none"
188 const LTO_THIN_VARIATION = "lto-thin"
195 if m, ok := ctx.Module().(*Module); ok && m.lto != nil {
206 if m.lto.Properties.LtoEnabled {
216 if m, ok := ctx.Module().(*Module); ok && m.lto != nil {
217 if m.lto.Never() {
221 if incomingVariation == LTO_THIN_VARIATION && m.lto.Properties.LtoDefault {
223 } else if incomingVariation == LTO_NONE_VARIATION && !m.lto.Properties.LtoDefault {
232 …// Default module which will be installed. Variation set above according to explicit LTO propertie…
237 if m, ok := ctx.Module().(*Module); ok && m.lto != nil {
238 // Non-default variation, set the LTO properties to match the variation.
241 m.lto.Properties.LtoEnabled = true
243 m.lto.Properties.LtoEnabled = false