aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


tools/client/test_portable_runtime.py (1339B)


      1 """Compare generated AO code on Windows x86 and Linux x86-64."""
      2 
      3 import pathlib
      4 import subprocess
      5 
      6 
      7 root = pathlib.Path(__file__).resolve().parents[2]
      8 compiler = root / "toolchains/llvm-mingw-20261006-ucrt-x86_64/bin/i686-w64-mingw32-clang.exe"
      9 reference = root / "client/build/linecrypt-reference.exe"
     10 sources = ["tests/linecrypt.c", "tests/reference_memory.c", "runtime/recomp_state.c",
     11            "game/yr.dll/lifted-0000.c", "data/yr_dll.c"]
     12 
     13 # The Windows reference retains the fixed-address, 32-bit memory model.
     14 subprocess.run([str(compiler), "-O2", "-fno-strict-aliasing", "-Iruntime",
     15                 *sources, "-o", str(reference)], cwd=root / "client", check=True)
     16 windows = subprocess.check_output([str(reference)], text=True).strip()
     17 
     18 # The same game function uses translated guest addresses on 64-bit Linux.
     19 linux_directory = "/mnt/" + root.drive[0].lower() + root.as_posix()[2:] + "/client"
     20 subprocess.run(["wsl", "-d", "Ubuntu-26.04", "--cd", linux_directory,
     21                 "--exec", "make", "-f", "Makefile.linux", "build/linux/linecrypt"], check=True)
     22 linux = subprocess.check_output(["wsl", "-d", "Ubuntu-26.04", "--cd", linux_directory,
     23                                  "--exec", "./build/linux/linecrypt"], text=True).strip()
     24 assert windows == linux, (windows, linux)
     25 print("Windows x86 == Linux x86-64: " + linux)