Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 805e0a53 authored by Anton Hansson's avatar Anton Hansson
Browse files

Ignore native bridge archs for apex selection

This leads to an arm64 apex being used on a device that is mixed
x86_64 with nativebridge=arm64. A device like that doesn't appear
to work with arm64 binaries. For example, the boringssl-self-check
binary crashes on boot.

Bug: 260115309
Test: unit test
Test: boot emulator with this combination
Change-Id: Ic4a91974290a05b1799f755fcf52ef226d68f4c2
parent 7d78bad7
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -8413,6 +8413,30 @@ func TestApexSet(t *testing.T) {
	}
}

func TestApexSet_NativeBridge(t *testing.T) {
	ctx := testApex(t, `
		apex_set {
			name: "myapex",
			set: "myapex.apks",
			filename: "foo_v2.apex",
			overrides: ["foo"],
		}
	`,
		android.FixtureModifyConfig(func(config android.Config) {
			config.Targets[android.Android] = []android.Target{
				{Os: android.Android, Arch: android.Arch{ArchType: android.X86_64, ArchVariant: "", Abi: []string{"x86_64"}}},
				{Os: android.Android, Arch: android.Arch{ArchType: android.Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, NativeBridge: android.NativeBridgeEnabled},
			}
		}),
	)

	m := ctx.ModuleForTests("myapex.apex.extractor", "android_common")

	// Check extract_apks tool parameters. No native bridge arch expected
	extractedApex := m.Output("extracted/myapex.apks")
	android.AssertStringEquals(t, "abis", "X86_64", extractedApex.Args["abis"])
}

func TestNoStaticLinkingToStubsLib(t *testing.T) {
	testApexError(t, `.*required by "mylib" is a native library providing stub.*`, `
		apex {
+4 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import (
	"android/soong/android"
	"android/soong/java"
	"android/soong/provenance"

	"github.com/google/blueprint"
	"github.com/google/blueprint/proptools"
)
@@ -831,6 +832,8 @@ func (p *prebuiltApexExtractorModule) GenerateAndroidBuildActions(ctx android.Mo
	}
	apexSet := android.SingleSourcePathFromSupplier(ctx, srcsSupplier, "set")
	p.extractedApex = android.PathForModuleOut(ctx, "extracted", apexSet.Base())
	// Filter out NativeBridge archs (b/260115309)
	abis := java.SupportedAbis(ctx, true)
	ctx.Build(pctx,
		android.BuildParams{
			Rule:        extractMatchingApex,
@@ -838,7 +841,7 @@ func (p *prebuiltApexExtractorModule) GenerateAndroidBuildActions(ctx android.Mo
			Inputs:      android.Paths{apexSet},
			Output:      p.extractedApex,
			Args: map[string]string{
				"abis":              strings.Join(java.SupportedAbis(ctx), ","),
				"abis":              strings.Join(abis, ","),
				"allow-prereleased": strconv.FormatBool(proptools.Bool(p.properties.Prerelease)),
				"sdk-version":       ctx.Config().PlatformSdkVersion().String(),
			},
+5 −2
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ var TargetCpuAbi = map[string]string{
	"x86_64":  "X86_64",
}

func SupportedAbis(ctx android.ModuleContext) []string {
func SupportedAbis(ctx android.ModuleContext, excludeNativeBridgeAbis bool) []string {
	abiName := func(targetIdx int, deviceArch string) string {
		if abi, found := TargetCpuAbi[deviceArch]; found {
			return abi
@@ -109,6 +109,9 @@ func SupportedAbis(ctx android.ModuleContext) []string {

	var result []string
	for i, target := range ctx.Config().Targets[android.Android] {
		if target.NativeBridge == android.NativeBridgeEnabled && excludeNativeBridgeAbis {
			continue
		}
		result = append(result, abiName(i, target.Arch.ArchType.String()))
	}
	return result
@@ -135,7 +138,7 @@ func (as *AndroidAppSet) GenerateAndroidBuildActions(ctx android.ModuleContext)
			ImplicitOutputs: android.WritablePaths{as.packedOutput, as.apkcertsFile},
			Inputs:          android.Paths{as.prebuilt.SingleSourcePath(ctx)},
			Args: map[string]string{
				"abis":              strings.Join(SupportedAbis(ctx), ","),
				"abis":              strings.Join(SupportedAbis(ctx, false), ","),
				"allow-prereleased": strconv.FormatBool(proptools.Bool(as.properties.Prerelease)),
				"screen-densities":  screenDensities,
				"sdk-version":       ctx.Config().PlatformSdkVersion().String(),