diff --git a/android/sh_binary.go b/android/sh_binary.go index 6db9892fa..2b649c4a2 100644 --- a/android/sh_binary.go +++ b/android/sh_binary.go @@ -196,6 +196,9 @@ func InitShBinaryModule(s *ShBinary) { // executable binary to /bin. func ShBinaryFactory() Module { module := &ShBinary{} + module.Prefer32(func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool { + return class == Device && ctx.Config().DevicePrefer32BitExecutables() + }) InitShBinaryModule(module) InitAndroidArchModule(module, HostAndDeviceSupported, MultilibFirst) return module diff --git a/apex/apex.go b/apex/apex.go index b831333e6..4dfbdb4fa 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -598,10 +598,6 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { a.properties.Multilib.First.Tests, target, a.getImageVariation(config)) - - // When multilib.* is omitted for prebuilts, it implies multilib.first. - ctx.AddFarVariationDependencies(target.Variations(), - prebuiltTag, a.properties.Prebuilts...) } switch target.Arch.ArchType.Multilib { @@ -652,6 +648,22 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { } + // For prebuilt_etc, use the first variant (64 on 64/32bit device, + // 32 on 32bit device) regardless of the TARGET_PREFER_* setting. + // b/144532908 + archForPrebuiltEtc := config.Arches()[0] + for _, arch := range config.Arches() { + // Prefer 64-bit arch if there is any + if arch.ArchType.Multilib == "lib64" { + archForPrebuiltEtc = arch + break + } + } + ctx.AddFarVariationDependencies([]blueprint.Variation{ + {Mutator: "os", Variation: ctx.Os().String()}, + {Mutator: "arch", Variation: archForPrebuiltEtc.String()}, + }, prebuiltTag, a.properties.Prebuilts...) + ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), javaLibTag, a.properties.Java_libs...)