diff --git a/cc/compiler.go b/cc/compiler.go index d13cd9506..83080fd72 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -695,6 +695,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps if ctx.optimizeForSize() { flags.Local.CFlags = append(flags.Local.CFlags, "-Oz") + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-mllvm,-enable-ml-inliner=release") } // Exclude directories from manual binder interface allowed list. diff --git a/cc/lto.go b/cc/lto.go index a084db7be..60eb4d6b1 100644 --- a/cc/lto.go +++ b/cc/lto.go @@ -144,7 +144,7 @@ func (lto *lto) flags(ctx ModuleContext, flags Flags) Flags { if !ctx.Config().IsEnvFalse("THINLTO_USE_MLGO") { // Register allocation MLGO flags for ARM64. - if ctx.Arch().ArchType == android.Arm64 { + if ctx.Arch().ArchType == android.Arm64 && !ctx.optimizeForSize() { ltoLdFlags = append(ltoLdFlags, "-Wl,-mllvm,-regalloc-enable-advisor=release") } // Flags for training MLGO model.