Skip to content

Commit

Permalink
Android: Add support for x86_64 architecture
Browse files Browse the repository at this point in the history
Like arm64v8, this is only supported by API 21 and later,
so we enforce 21 as min API for x86_64.

Part of #25030.
  • Loading branch information
akien-mga committed Jan 16, 2019
1 parent f089323 commit 7f4ee36
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions modules/webm/libvpx/SCsub
Expand Up @@ -272,9 +272,9 @@ else:
import platform
is_x11_or_server_arm = ((env["platform"] == 'x11' or env["platform"] == 'server') and (platform.machine().startswith('arm') or platform.machine().startswith('aarch')))
is_ios_x86 = (env["platform"] == 'iphone' and ("arch" in env and env["arch"].startswith('x86')))
is_android_x86 = (env["platform"] == 'android' and env["android_arch"] == 'x86')
is_android_x86 = (env["platform"] == 'android' and env["android_arch"].startswith('x86'))
if is_android_x86:
cpu_bits = '32'
cpu_bits = '32' if env["android_arch"] == 'x86' else '64'
webm_cpu_x86 = not is_x11_or_server_arm and (cpu_bits == '32' or cpu_bits == '64') and (env["platform"] == 'windows' or env["platform"] == 'x11' or env["platform"] == 'osx' or env["platform"] == 'haiku' or is_android_x86 or is_ios_x86)
webm_cpu_arm = is_x11_or_server_arm or (not is_ios_x86 and env["platform"] == 'iphone') or (not is_android_x86 and env["platform"] == 'android')

Expand Down
2 changes: 2 additions & 0 deletions platform/android/SCsub
Expand Up @@ -152,6 +152,8 @@ elif env['android_arch'] == 'arm64v8':
lib_arch_dir = 'arm64-v8a'
elif env['android_arch'] == 'x86':
lib_arch_dir = 'x86'
elif env['android_arch'] == 'x86_64':
lib_arch_dir = 'x86_64'
else:
print('WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin')

Expand Down
17 changes: 15 additions & 2 deletions platform/android/detect.py
Expand Up @@ -27,7 +27,7 @@ def get_opts():
return [
('ANDROID_NDK_ROOT', 'Path to the Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)),
('ndk_platform', 'Target platform (android-<api>, e.g. "android-18")', "android-18"),
EnumVariable('android_arch', 'Target architecture', "armv7", ('armv7', 'armv6', 'arm64v8', 'x86')),
EnumVariable('android_arch', 'Target architecture', "armv7", ('armv7', 'armv6', 'arm64v8', 'x86', 'x86_64')),
BoolVariable('android_neon', 'Enable NEON support (armv7 only)', True),
BoolVariable('android_stl', 'Enable Android STL support (for modules)', True)
]
Expand Down Expand Up @@ -94,7 +94,7 @@ def mySpawn(sh, escape, cmd, args, env):

## Architecture

if env['android_arch'] not in ['armv7', 'armv6', 'arm64v8', 'x86']:
if env['android_arch'] not in ['armv7', 'armv6', 'arm64v8', 'x86', 'x86_64']:
env['android_arch'] = 'armv7'

neon_text = ""
Expand All @@ -110,6 +110,16 @@ def mySpawn(sh, escape, cmd, args, env):
abi_subpath = "i686-linux-android"
arch_subpath = "x86"
env["x86_libtheora_opt_gcc"] = True
if env['android_arch'] == 'x86_64':
if get_platform(env["ndk_platform"]) < 21:
print("WARNING: android_arch=x86_64 is not supported by ndk_platform lower than android-21; setting ndk_platform=android-21")
env["ndk_platform"] = "android-21"
env['ARCH'] = 'arch-x86_64'
env.extra_suffix = ".x86_64" + env.extra_suffix
target_subpath = "x86_64-4.9"
abi_subpath = "x86_64-linux-android"
arch_subpath = "x86_64"
env["x86_libtheora_opt_gcc"] = True
elif env['android_arch'] == 'armv6':
env['ARCH'] = 'arch-arm'
env.extra_suffix = ".armv6" + env.extra_suffix
Expand Down Expand Up @@ -233,6 +243,9 @@ def mySpawn(sh, escape, cmd, args, env):
# The NDK adds this if targeting API < 21, so we can drop it when Godot targets it at least
env.Append(CPPFLAGS=['-mstackrealign'])

elif env['android_arch'] == 'x86_64':
target_opts = ['-target', 'x86_64-none-linux-android']

elif env["android_arch"] == "armv6":
target_opts = ['-target', 'armv6-none-linux-androideabi']
env.Append(CPPFLAGS='-D__ARM_ARCH_6__ -march=armv6 -mfpu=vfp -mfloat-abi=softfp'.split())
Expand Down
5 changes: 2 additions & 3 deletions platform/android/export/export.cpp
Expand Up @@ -552,14 +552,13 @@ class EditorExportAndroid : public EditorExportPlatform {

static Vector<String> get_abis() {
Vector<String> abis;
// We can still build armv7 in theory, but it doesn't make much
// We can still build armv6 in theory, but it doesn't make much
// sense for games, so disabling for now.
//abis.push_back("armeabi");
abis.push_back("armeabi-v7a");
abis.push_back("arm64-v8a");
abis.push_back("x86");
// Don't expose x86_64 for now, we don't support it in detect.py
//abis.push_back("x86_64");
abis.push_back("x86_64");
return abis;
}

Expand Down

0 comments on commit 7f4ee36

Please sign in to comment.