Categories

# Box64 running on M1 with Asahi

Box64 running on mac M1 with Asahi

The Asahi project has now released a first alpha version, so I tried that on a MacBookPro. Asahi is a full linux distribution that can be installed on mac with an M1 processor, it installs alongside your current macOS. It’s an alpha release so many things are missing for now, including 3D hardware acceleration, but on the other hand, for an alpha release, many things are already working, and working fine!

After a (quite) long installation process, I got linux running on that mac. Note that I add to restart the installation process, as the mac went to sleep mode during “root expension” and that actually froze the installation. I needed to break, remove all the create partitions (a risky process) to be able to start again.

Now, the M1 processor is very fast ARM64 processor, but it only supports 64bits operations. No ARM32 there, so no box86. Also, the Asahi readme mentions that the Pagesize is 16K, instead of the standard 4K. That breaks a few things on the way. Fortunatly, I had already encountered a system with 16K pagesize (Loongarch64 systems), so there is some supporting code on box64 already for it. And after enabling it (plus some compilation options), box64, with dynarec, was running!

To try things, I wanted to install a simple linux game. Remember that there is no Hardware acceleration yet, so I choose WorldOfGoo, with its simple graphics (it’s still an OpenGL game). Launching the install didn’t work, as by default, the setup tries to run x86 code (32bits, so needing box86 not available here). To work around that, I created a simple uname script that spoofs the setup into thinking this is an x86_64 system:

the file simply contains

#!/bin/bash

if [ "$1" == "-m" ];then echo x86_64 exit 0 fi /bin/uname "$@"

And I created an x86_64 folder in my home directory to put some pc stuffs (and that uname script)

Then I launched the setup as PATH=~/x86_64:\$PATH ./WorldOfGoo.Linux.153.sh et voilà, the setup launched… But as text only… Ok, gtk2 libs are not installed. So sudo pacman -S gtk2 and try again…

And yeah, the game runs perfectly!

Quickly running a 7zip benchmark to see the brute force performance of that M1 chip (I just have a “regular” M1, not a Pro or Max version, but still, it’s already very powerfull)

The native version of 7z b gives me

7-Zip [64] 17.04 : Copyright (c) 1999-2021 Igor Pavlov : 2017-08-28
p7zip Version 17.04 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,8 CPUs LE)

LE
CPU Freq: - - - - - - - - -

RAM size:   15711 MB,  # CPU hardware threads:   8
RAM usage:   1765 MB,  # Benchmark threads:      8

Compressing  |                  Decompressing
Dict     Speed Usage    R/U Rating  |      Speed Usage    R/U Rating
KiB/s     %   MIPS   MIPS  |      KiB/s     %   MIPS   MIPS

22:      38534   693   5406  37486  |     303027   676   3821  25847
23:      34149   642   5423  34794  |     262583   620   3668  22723
24:      35741   710   5410  38429  |     296978   681   3828  26065
25:      35507   742   5461  40541  |     278509   644   3848  24786
----------------------------------  | ------------------------------
Avr:             697   5425  37813  |              655   3791  24855
Tot:             676   4608  31334
7z b  3:12,74 user 0,574 system 651% cpu (29,676 wasted time).

While the x86_64 version with box64 gives

Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS PageSize:16384
Box64 with Dynarec v0.1.7 7f7003c built on Mar 20 2022 15:21:29
Using default BOX64_LD_LIBRARY_PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/
Using default BOX64_PATH: ./:bin/
Counted 32 Env var
Looking for ./7z
argv[1]="b"
Using native(wrapped) libdl.so.2
Using emulated /lib/x86_64-linux-gnu/libstdc++.so.6
Using native(wrapped) libm.so.6
Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) librt.so.1

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,8 CPUs Intel(R) Pentium(R) 4 CPU 1000MHz (4000601),ASM,AES-NI)

Using emulated /home/seb/x86_64/p7zip64/7z.so
Intel(R) Pentium(R) 4 CPU 1000MHz (4000601)
CPU Freq:  2820  2984  2983  2983  2984  2984  2984  2984  2984

RAM size:   15711 MB,  # CPU hardware threads:   8
RAM usage:   1765 MB,  # Benchmark threads:      8

Compressing  |                  Decompressing
Dict     Speed Usage    R/U Rating  |      Speed Usage    R/U Rating
KiB/s     %   MIPS   MIPS  |      KiB/s     %   MIPS   MIPS

22:      20624   729   2754  20064  |     194010   662   2501  16548
23:      19046   701   2767  19406  |     190856   662   2496  16516
24:      19176   739   2790  20619  |     188568   663   2495  16550
25:      17013   677   2869  19426  |     185050   664   2481  16469
----------------------------------  | ------------------------------
Avr:             712   2795  19879  |              663   2493  16521
Tot:             687   2644  18200
./7z b  4:13,17 user 0,572 system 629% cpu (40,339 wasted time).

The performances penalty of box64 here is on par with what I already measured on other platforms.

That’s it for a quick test. That cpu is a beast, and even without 3D hardware support, it’s already quite usable and you can even use games on it! On box64 developement side, this platform will now enable me to use more advanced Arm64 CPU instruction in the dynarec, as there are some interesting opcodes in Arm 8.1 and more that are available on this cpu.