[3.13] gh-146541: Allow building the Android testbed for 32-bit targets (GH-146542) (#148107)

Allows building the Android testbed for 32-bit targets, adding the target triplets
`arm-linux-androideabi` and `i686-linux-android`.
(cherry picked from commit 848bbe9ff2)

Co-authored-by: Robert Kirkman <31490854+robertkirkman@users.noreply.github.com>
This commit is contained in:
Malcolm Smith 2026-04-06 00:47:01 +01:00 committed by GitHub
parent 38e2470f56
commit 3ea97a26b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 21 additions and 7 deletions

View file

@ -34,7 +34,12 @@
TESTBED_DIR = ANDROID_DIR / "testbed"
CROSS_BUILD_DIR = PYTHON_DIR / "cross-build"
HOSTS = ["aarch64-linux-android", "x86_64-linux-android"]
HOSTS = [
"aarch64-linux-android",
"arm-linux-androideabi",
"i686-linux-android",
"x86_64-linux-android",
]
APP_ID = "org.python.testbed"
DECODE_ARGS = ("UTF-8", "backslashreplace")

View file

@ -15,6 +15,8 @@ val inSourceTree = (
val KNOWN_ABIS = mapOf(
"aarch64-linux-android" to "arm64-v8a",
"arm-linux-androideabi" to "armeabi-v7a",
"i686-linux-android" to "x86",
"x86_64-linux-android" to "x86_64",
)

View file

@ -647,12 +647,16 @@ def get_platform():
# When Python is running on 32-bit ARM Android on a 64-bit ARM kernel,
# 'os.uname().machine' is 'armv8l'. Such devices run the same userspace
# code as 'armv7l' devices.
# During the build process of the Android testbed when targeting 32-bit ARM,
# '_PYTHON_HOST_PLATFORM' is 'arm-linux-androideabi', so 'machine' becomes
# 'arm'.
machine = {
"x86_64": "x86_64",
"i686": "x86",
"aarch64": "arm64_v8a",
"arm": "armeabi_v7a",
"armv7l": "armeabi_v7a",
"armv8l": "armeabi_v7a",
"i686": "x86",
"x86_64": "x86_64",
}[machine]
else:
# At least on Linux/Intel, 'machine' is the processor --

View file

@ -373,11 +373,12 @@ def test_get_platform(self):
sys.platform = 'android'
get_config_vars()['ANDROID_API_LEVEL'] = 9
for machine, abi in {
'x86_64': 'x86_64',
'i686': 'x86',
'aarch64': 'arm64_v8a',
'arm': 'armeabi_v7a',
'armv7l': 'armeabi_v7a',
'armv8l': 'armeabi_v7a',
'i686': 'x86',
'x86_64': 'x86_64',
}.items():
with self.subTest(machine):
self._set_uname(('Linux', 'localhost', '3.18.91+',
@ -586,11 +587,12 @@ def test_android_ext_suffix(self):
machine = platform.machine()
suffix = sysconfig.get_config_var('EXT_SUFFIX')
expected_triplet = {
"x86_64": "x86_64-linux-android",
"i686": "i686-linux-android",
"aarch64": "aarch64-linux-android",
"arm": "arm-linux-androideabi",
"armv7l": "arm-linux-androideabi",
"armv8l": "arm-linux-androideabi",
"i686": "i686-linux-android",
"x86_64": "x86_64-linux-android",
}[machine]
self.assertTrue(suffix.endswith(f"-{expected_triplet}.so"),
f"{machine=}, {suffix=}")

View file

@ -0,0 +1 @@
The Android testbed can now be built for 32-bit ARM and x86 targets.