Fix multilib first with multiple 64-bit architectures
Binaries that use multilib "first" expect zero or one architectures
because they will install to the same bin directory for any
architecture. Replace preferTargets with firstTarget that always
returns zero or one Target.
Test: OUT_DIR=out_ndk build/soong/scripts/build-ndk-prebuilts.sh
Test: m checkbuild
Change-Id: I6dcfa9ecda30177e1a262153d93a5a205d5c7076
diff --git a/android/arch.go b/android/arch.go
index 6971bc8..c5f242f 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -1100,11 +1100,11 @@
return ret
}
-func preferTargets(targets []Target, filters ...string) []Target {
+func firstTarget(targets []Target, filters ...string) []Target {
for _, filter := range filters {
buildTargets := filterMultilibTargets(targets, filter)
if len(buildTargets) > 0 {
- return buildTargets
+ return buildTargets[:1]
}
}
return nil
@@ -1120,9 +1120,9 @@
case "common_first":
buildTargets = getCommonTargets(targets)
if prefer32 {
- buildTargets = append(buildTargets, preferTargets(targets, "lib32", "lib64")...)
+ buildTargets = append(buildTargets, firstTarget(targets, "lib32", "lib64")...)
} else {
- buildTargets = append(buildTargets, preferTargets(targets, "lib64", "lib32")...)
+ buildTargets = append(buildTargets, firstTarget(targets, "lib64", "lib32")...)
}
case "both":
if prefer32 {
@@ -1138,12 +1138,15 @@
buildTargets = filterMultilibTargets(targets, "lib64")
case "first":
if prefer32 {
- buildTargets = preferTargets(targets, "lib32", "lib64")
+ buildTargets = firstTarget(targets, "lib32", "lib64")
} else {
- buildTargets = preferTargets(targets, "lib64", "lib32")
+ buildTargets = firstTarget(targets, "lib64", "lib32")
}
case "prefer32":
- buildTargets = preferTargets(targets, "lib32", "lib64")
+ buildTargets = filterMultilibTargets(targets, "lib32")
+ if len(buildTargets) == 0 {
+ buildTargets = filterMultilibTargets(targets, "lib64")
+ }
default:
return nil, fmt.Errorf(`compile_multilib must be "both", "first", "32", "64", or "prefer32" found %q`,
multilib)