From 17fbc895ec3e02d1044ece619696c67a8e7d28d1 Mon Sep 17 00:00:00 2001 From: Victor Khimenko Date: Thu, 17 Sep 2020 03:07:31 +0200 Subject: [PATCH] Add -D__ANDROID_NATIVE_BRIDGE__ to native_bridge targets And remove dual meaning from arm_on_x86 target. It was set for x86 targets with arm support and for arm targets with x86 support - and that 2nd one was abused for native_bridge version of RenderScript. It's much safer and cleaner to rely on __ANDROID_NATIVE_BRIDGE__ there while leaving arm_on_x86 to mean "x86 binary built in the image with arm support". It's only used by bcc compiler which is in canadian-cross situation here: it's pure x86-64 binary, but it needs to know about ALL supported architectures on device because it needs to include appropriate codegen module. Bug: http://b/153609531 Test: cts-tradefed run cts --abi armeabi-v7a -m CtsRsCppTestCases Test: cts-tradefed run cts --abi arm64-v8a -m CtsRsCppTestCases Change-Id: I869212e0b82eeaa30361a4e183d5c862ab40ef12 Merged-In: I869212e0b82eeaa30361a4e183d5c862ab40ef12 --- android/arch.go | 35 +++++------------------------------ cc/compiler.go | 4 ++++ 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/android/arch.go b/android/arch.go index d14221f7c..18ff13e9c 100644 --- a/android/arch.go +++ b/android/arch.go @@ -1440,20 +1440,15 @@ func (m *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) { // key: value, // }, // }, - // TODO(ccross): is this still necessary with native bridge? if os.Class == Device { - if (arch.ArchType == X86 && (hasArmAbi(arch) || - hasArmAndroidArch(ctx.Config().Targets[Android]))) || - (arch.ArchType == Arm && - hasX86AndroidArch(ctx.Config().Targets[Android])) { + if arch.ArchType == X86 && (hasArmAbi(arch) || + hasArmAndroidArch(ctx.Config().Targets[Android])) { field := "Arm_on_x86" prefix := "target.arm_on_x86" m.appendProperties(ctx, genProps, targetProp, field, prefix) } - if (arch.ArchType == X86_64 && (hasArmAbi(arch) || - hasArmAndroidArch(ctx.Config().Targets[Android]))) || - (arch.ArchType == Arm && - hasX8664AndroidArch(ctx.Config().Targets[Android])) { + if arch.ArchType == X86_64 && (hasArmAbi(arch) || + hasArmAndroidArch(ctx.Config().Targets[Android])) { field := "Arm_on_x86_64" prefix := "target.arm_on_x86_64" m.appendProperties(ctx, genProps, targetProp, field, prefix) @@ -1600,27 +1595,7 @@ func hasArmAbi(arch Arch) bool { // hasArmArch returns true if targets has at least non-native_bridge arm Android arch func hasArmAndroidArch(targets []Target) bool { for _, target := range targets { - if target.Os == Android && target.Arch.ArchType == Arm && target.NativeBridge == NativeBridgeDisabled { - return true - } - } - return false -} - -// hasX86Arch returns true if targets has at least x86 Android arch -func hasX86AndroidArch(targets []Target) bool { - for _, target := range targets { - if target.Os == Android && target.Arch.ArchType == X86 { - return true - } - } - return false -} - -// hasX8664Arch returns true if targets has at least x86_64 Android arch -func hasX8664AndroidArch(targets []Target) bool { - for _, target := range targets { - if target.Os == Android && target.Arch.ArchType == X86_64 { + if target.Os == Android && target.Arch.ArchType == Arm { return true } } diff --git a/cc/compiler.go b/cc/compiler.go index 08ce13392..f6c358775 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -333,6 +333,10 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps } } + if ctx.Target().NativeBridge == android.NativeBridgeEnabled { + flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_NATIVE_BRIDGE__") + } + instructionSet := String(compiler.Properties.Instruction_set) if flags.RequiredInstructionSet != "" { instructionSet = flags.RequiredInstructionSet