Disable more of AFDO for host modules

afdo.addDep would never add a depencency on a profile for a host
module, but afdoDepsMutator would still propagate AfdoRDeps to
dependencies, afdoMutator would still create afdo variants, and
afdo.flags would still add the -funique-internal-linkage-names
flag.  Exit early from all of these functions, since the afdo
variations will never be useful.

Test: afdo_test.go
Change-Id: I255fcbb86c99871916e571fbc74075d918b24745
This commit is contained in:
Colin Cross
2024-02-07 15:09:08 -08:00
parent da4c89f750
commit 15fa814560
2 changed files with 61 additions and 0 deletions

View File

@@ -68,6 +68,10 @@ func (afdo *afdo) afdoEnabled() bool {
}
func (afdo *afdo) flags(ctx ModuleContext, flags Flags) Flags {
if ctx.Host() {
return flags
}
if afdo.Properties.Afdo {
// We use `-funique-internal-linkage-names` to associate profiles to the right internal
// functions. This option should be used before generating a profile. Because a profile
@@ -147,6 +151,10 @@ var _ FdoProfileMutatorInterface = (*Module)(nil)
// Propagate afdo requirements down from binaries and shared libraries
func afdoDepsMutator(mctx android.TopDownMutatorContext) {
if mctx.Host() {
return
}
if m, ok := mctx.Module().(*Module); ok && m.afdo.afdoEnabled() {
path := m.afdo.Properties.FdoProfilePath
mctx.WalkDeps(func(dep android.Module, parent android.Module) bool {
@@ -181,6 +189,10 @@ func afdoDepsMutator(mctx android.TopDownMutatorContext) {
// Create afdo variants for modules that need them
func afdoMutator(mctx android.BottomUpMutatorContext) {
if mctx.Host() {
return
}
if m, ok := mctx.Module().(*Module); ok && m.afdo != nil {
if !m.static() && m.afdo.Properties.Afdo {
mctx.SetDependencyVariation(encodeTarget(m.Name()))