aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/platform/build_target.py
diff options
context:
space:
mode:
authorJonathan Schwender <55576758+jschwe@users.noreply.github.com>2025-02-18 19:47:11 +0100
committerGitHub <noreply@github.com>2025-02-18 18:47:11 +0000
commitb57eba29196f16f5fb4460532b64471790d249e8 (patch)
tree934b491b4a2856a864be605c2c3c586ab4a1903f /python/servo/platform/build_target.py
parent7d2437762fc20bbecc83d2520e19ec1176aba468 (diff)
downloadservo-b57eba29196f16f5fb4460532b64471790d249e8.tar.gz
servo-b57eba29196f16f5fb4460532b64471790d249e8.zip
Fix android build on arm macs (#35516)
The prebuilt directory only contains an `darwin-x86_64` toolchain, but that is perfectly fine, since that also works. In General, if there is only one prebuilt toolchain available, it should be a very safe assumption that it is usable on the host platform, especially if the OS matches. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Diffstat (limited to 'python/servo/platform/build_target.py')
-rw-r--r--python/servo/platform/build_target.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/python/servo/platform/build_target.py b/python/servo/platform/build_target.py
index cdf7755df27..a0b3908cdbf 100644
--- a/python/servo/platform/build_target.py
+++ b/python/servo/platform/build_target.py
@@ -149,18 +149,33 @@ class AndroidTarget(CrossBuildTarget):
if os_type not in ["linux", "darwin"]:
raise Exception("Android cross builds are only supported on Linux and macOS.")
+ llvm_prebuilt = path.join(env['ANDROID_NDK_ROOT'], "toolchains", "llvm", "prebuilt")
+
cpu_type = platform.machine().lower()
host_suffix = "unknown"
if cpu_type in ["i386", "i486", "i686", "i768", "x86"]:
host_suffix = "x86"
elif cpu_type in ["x86_64", "x86-64", "x64", "amd64"]:
host_suffix = "x86_64"
+ else:
+ available_prebuilts = os.listdir(llvm_prebuilt)
+ available_prebuilts = [prebuilt for prebuilt in available_prebuilts if prebuilt.startswith(os_type)]
+ # If there is only one prebuilt option available, it's probably the right one for the host
+ # platform. E.g. on Arm macs, only the x86 prebuilts are available, buts that perfectly fine,
+ # since there is rosetta.
+ if len(available_prebuilts) == 1:
+ host_suffix = available_prebuilts[0].removeprefix(f"{os_type}-")
+ else:
+ print(f"Error: Can't determine LLVM prebuilt. Unknown cpu type {cpu_type}.")
+ print(f"Hint: The LLVM prebuilts folder contains the following entries: {available_prebuilts}")
+ print("Please open an issue with the above information")
+ raise Exception("Can't determine LLVM prebuilt directory.")
host = os_type + "-" + host_suffix
host_cc = env.get('HOST_CC') or shutil.which("clang")
host_cxx = env.get('HOST_CXX') or shutil.which("clang++")
- llvm_toolchain = path.join(env['ANDROID_NDK_ROOT'], "toolchains", "llvm", "prebuilt", host)
+ llvm_toolchain = path.join(llvm_prebuilt, host)
env['PATH'] = (env['PATH'] + ':' + path.join(llvm_toolchain, "bin"))
def to_ndk_bin(prog):