]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
Downgrade x86_64 to x86 if no SSE4.2
authorAlessandro Astone <ales.astone@gmail.com>
Sun, 26 Jun 2022 15:15:22 +0000 (17:15 +0200)
committerErfan Abdi <erfangplus@gmail.com>
Wed, 6 Jul 2022 16:39:06 +0000 (21:09 +0430)
tools/helpers/arch.py

index 35e851601a8d34c726a14eeb5f10aa2b151362bf..af18e668515bbfe92c482a3fbac330a79495b23e 100644 (file)
@@ -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,15 @@ 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 == "x86_64":
+        with open("/proc/cpuinfo") as f:
+            if "sse4_2" not in f.read():
+                logging.info("x86_64 CPU does not support SSE4.2, falling back to x86...")
+                return "x86"
+
+    return target