X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/waydroid.git/blobdiff_plain/80555aba69dd568aa989edea8480487e87d80aac..0841a74bf82f59e316d8fbcfdff415bb003bc84e:/tools/helpers/arch.py diff --git a/tools/helpers/arch.py b/tools/helpers/arch.py index 35e8516..c74ef90 100644 --- a/tools/helpers/arch.py +++ b/tools/helpers/arch.py @@ -1,6 +1,7 @@ # Copyright 2021 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later import platform +import logging def host(): machine = platform.machine() @@ -13,6 +14,20 @@ def host(): "armv8l": "arm" } if machine in mapping: - return mapping[machine] + return maybe_remap(mapping[machine]) raise ValueError("platform.machine '" + machine + "'" " architecture is not supported") + +def maybe_remap(target): + if target.startswith("x86"): + with open("/proc/cpuinfo") as f: + cpuinfo = f.read() + if "ssse3" not in cpuinfo: + raise ValueError("x86/x86_64 CPU must support SSSE3!") + if target == "x86_64" and "sse4_2" not in cpuinfo: + logging.info("x86_64 CPU does not support SSE4.2, falling back to x86...") + return "x86" + elif target == "arm64" and platform.architecture()[0] == "32bit": + return "arm" + + return target