Build for 64-bit ARM by default when compiling or exporting for Android

All Android devices that support Vulkan support 64-bit ARM.

This also removes NEON opt-out code for ARMv7 as pretty much all
ARMv7 devices also support NEON.
This commit is contained in:
Hugo Locurcio 2021-10-12 15:27:30 +02:00
parent d5409e32f1
commit b1b14e5fd7
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
3 changed files with 13 additions and 21 deletions

View file

@ -36,7 +36,8 @@ if env["builtin_libpng"]:
# Currently .ASM filter_neon.S does not compile on NT. # Currently .ASM filter_neon.S does not compile on NT.
import os import os
use_neon = "neon_enabled" in env and env["neon_enabled"] and os.name != "nt" # Enable ARM NEON instructions on 32-bit Android to compile more optimized code.
use_neon = "android_arch" in env and env["android_arch"] == "armv7" and os.name != "nt"
if use_neon: if use_neon:
env_png.Append(CPPDEFINES=[("PNG_ARM_NEON_OPT", 2)]) env_png.Append(CPPDEFINES=[("PNG_ARM_NEON_OPT", 2)])
else: else:

View file

@ -27,8 +27,7 @@ def get_opts():
("ANDROID_NDK_ROOT", "Path to the Android NDK", get_android_ndk_root()), ("ANDROID_NDK_ROOT", "Path to the Android NDK", get_android_ndk_root()),
("ANDROID_SDK_ROOT", "Path to the Android SDK", get_android_sdk_root()), ("ANDROID_SDK_ROOT", "Path to the Android SDK", get_android_sdk_root()),
("ndk_platform", 'Target platform (android-<api>, e.g. "android-24")', "android-24"), ("ndk_platform", 'Target platform (android-<api>, e.g. "android-24")', "android-24"),
EnumVariable("android_arch", "Target architecture", "armv7", ("armv7", "arm64v8", "x86", "x86_64")), EnumVariable("android_arch", "Target architecture", "arm64v8", ("armv7", "arm64v8", "x86", "x86_64")),
BoolVariable("android_neon", "Enable NEON support (armv7 only)", True),
] ]
@ -143,10 +142,7 @@ def configure(env):
if env["android_arch"] not in ["armv7", "arm64v8", "x86", "x86_64"]: if env["android_arch"] not in ["armv7", "arm64v8", "x86", "x86_64"]:
env["android_arch"] = "armv7" env["android_arch"] = "armv7"
neon_text = "" print("Building for Android, platform " + env["ndk_platform"] + " (" + env["android_arch"] + ")")
if env["android_arch"] == "armv7" and env["android_neon"]:
neon_text = " (with NEON)"
print("Building for Android, platform " + env["ndk_platform"] + " (" + env["android_arch"] + ")" + neon_text)
can_vectorize = True can_vectorize = True
if env["android_arch"] == "x86": if env["android_arch"] == "x86":
@ -174,10 +170,7 @@ def configure(env):
target_subpath = "arm-linux-androideabi-4.9" target_subpath = "arm-linux-androideabi-4.9"
abi_subpath = "arm-linux-androideabi" abi_subpath = "arm-linux-androideabi"
arch_subpath = "armeabi-v7a" arch_subpath = "armeabi-v7a"
if env["android_neon"]: env.extra_suffix = ".armv7" + env.extra_suffix
env.extra_suffix = ".armv7.neon" + env.extra_suffix
else:
env.extra_suffix = ".armv7" + env.extra_suffix
elif env["android_arch"] == "arm64v8": elif env["android_arch"] == "arm64v8":
if get_platform(env["ndk_platform"]) < 21: if get_platform(env["ndk_platform"]) < 21:
print( print(
@ -288,7 +281,6 @@ def configure(env):
if get_platform(env["ndk_platform"]) >= 24: if get_platform(env["ndk_platform"]) >= 24:
env.Append(CPPDEFINES=[("_FILE_OFFSET_BITS", 64)]) env.Append(CPPDEFINES=[("_FILE_OFFSET_BITS", 64)])
env["neon_enabled"] = False
if env["android_arch"] == "x86": if env["android_arch"] == "x86":
target_opts = ["-target", "i686-none-linux-android"] target_opts = ["-target", "i686-none-linux-android"]
# The NDK adds this if targeting API < 21, so we can drop it when Godot targets it at least # The NDK adds this if targeting API < 21, so we can drop it when Godot targets it at least
@ -301,12 +293,9 @@ def configure(env):
target_opts = ["-target", "armv7-none-linux-androideabi"] target_opts = ["-target", "armv7-none-linux-androideabi"]
env.Append(CCFLAGS="-march=armv7-a -mfloat-abi=softfp".split()) env.Append(CCFLAGS="-march=armv7-a -mfloat-abi=softfp".split())
env.Append(CPPDEFINES=["__ARM_ARCH_7__", "__ARM_ARCH_7A__"]) env.Append(CPPDEFINES=["__ARM_ARCH_7__", "__ARM_ARCH_7A__"])
if env["android_neon"]: # Enable ARM NEON instructions to compile more optimized code.
env["neon_enabled"] = True env.Append(CCFLAGS=["-mfpu=neon"])
env.Append(CCFLAGS=["-mfpu=neon"]) env.Append(CPPDEFINES=["__ARM_NEON__"])
env.Append(CPPDEFINES=["__ARM_NEON__"])
else:
env.Append(CCFLAGS=["-mfpu=vfpv3-d16"])
elif env["android_arch"] == "arm64v8": elif env["android_arch"] == "arm64v8":
target_opts = ["-target", "aarch64-none-linux-android"] target_opts = ["-target", "aarch64-none-linux-android"]

View file

@ -1644,10 +1644,12 @@ void EditorExportPlatformAndroid::get_export_options(List<ExportOption> *r_optio
} }
plugins_changed.clear(); plugins_changed.clear();
Vector<String> abis = get_abis(); const Vector<String> abis = get_abis();
for (int i = 0; i < abis.size(); ++i) { for (int i = 0; i < abis.size(); ++i) {
String abi = abis[i]; const String abi = abis[i];
bool is_default = (abi == "armeabi-v7a" || abi == "arm64-v8a"); // All Android devices supporting Vulkan run 64-bit Android,
// so there is usually no point in exporting for 32-bit Android.
const bool is_default = abi == "arm64-v8a";
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "architectures/" + abi), is_default)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "architectures/" + abi), is_default));
} }