ptitSeb / box64

Box64 - Linux Userspace x86_64 Emulator with a twist, targeted at ARM64 Linux devices
https://box86.org
MIT License
3.71k stars 263 forks source link

Getting the native Linux version of steam working on Apple silicon #1780

Open m1m1k4tz opened 2 weeks ago

m1m1k4tz commented 2 weeks ago

The furthest I’ve been able to get is by running krun box64 ~/box64/tests/bash then steam after installing it from the rpm https://download1.rpmfusion.org/nonfree/el/updates/7/x86_64/s/ with this command sudo rpm -i steam-1.0.0.78-1.el7.i686.rpm —nodeps —ignorearch when I do that it gives me https://pastebin.com/0SGDhuhZ

ptitSeb commented 2 weeks ago

This is a known issue.

The box32 option of box64 is not yet abe to run steam. It's still a WIP and the first step is to be ablle to run SteamCMD. Steam will come later.

m1m1k4tz commented 1 week ago

Okay, I fixed the missing dependencies on the M1 by doing sudo dnf --installroot="$HOME/.local/share/asahi-krun/box64-sysroot" --forcearch=x86_64 --releasever 40 install steam then doing krun -e BOX64_LD_LIBRARY_PATH=/home/alex/.local/share/asahi-krun/box64-sysroot/lib/ box64 ~/box64/tests/bash finally I ran steamcmd but it gave me this

Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS SHA1 SHA2 USCAT FLAGM FLAGM2 FRINT PageSize:4096 Running on Firestorm-M1 with 4 Cores
Will use Hardware counter measured at 24.0 MHz emulating 3.0 GHz
Params database has 90 entries
Box64 with Dynarec v0.3.1 fc7f83c6 built on Sep 11 2024 23:53:10
BOX64: Detected 48bits at least of address space
Counted 28 Env var
BOX64 LIB PATH: BOX64 BIN PATH: ./:bin/:/home/alex/.cargo/bin/:/home/alex/.local/bin/:/home/alex/bin/:/usr/lib64/ccache/:/usr/local/bin/:/usr/bin/:/bin/:/usr/local/sbin/:/usr/sbin/:/sbin/:/usr/local/sbin/:/usr/local/bin/:/usr/sbin/:/usr/bin/:/sbin/:/bin/
Looking for /home/alex/box64/tests/bash
bash detected, disabling banner
Apply RC params for bash
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS SHA1 SHA2 USCAT FLAGM FLAGM2 FRINT PageSize:4096 Running on Firestorm-M1 with 4 Cores
Will use Hardware counter measured at 24.0 MHz emulating 3.0 GHz
Params database has 90 entries
Box64 with Dynarec v0.3.1 fc7f83c6 built on Sep 11 2024 23:53:10
steamcmd detected
BOX64: Detected 48bits at least of address space
Counted 28 Env var
BOX64 LIB PATH: BOX64 BIN PATH: ./:bin/:/home/alex/.cargo/bin/:/home/alex/.local/bin/:/home/alex/bin/:/usr/lib64/ccache/:/usr/local/bin/:/usr/bin/:/bin/:/usr/local/sbin/:/usr/sbin/:/sbin/:/usr/local/sbin/:/usr/local/bin/:/usr/sbin/:/usr/bin/:/sbin/:/bin/
Looking for /home/alex/steamcmd_linux/linux32/steamcmd
BOX64: Using Box32 to load 32bits elf
Memory higher than 32bits reserved
Rename process to "steamcmd"
Using native(wrapped) librt.so.1
Using native(wrapped) libdl.so.2
Using native(wrapped) libpthread.so.0
Using native(wrapped) libm.so.6
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux.so.2
Redirecting stderr to '/home/alex/.local/share/Steam/logs/stderr.txt'
Using native(wrapped) crashhandler.so
Looks like steam didn't shutdown cleanly, scheduling immediate update check
ILocalize::AddFile() failed to load file "public/steambootstrapper_english.txt".
[  0%] Checking for available update...
0346|SIGSEGV @0x34c93dd8 (my32_gethostbyname(/home/alex/steamcmd_linux/linux32/steamcmd)) (x64pc=(nil)/"???", rsp=0xf1190000, stack=0xf1090000:0xf1190000 own=0xf1090000 fp=(nil)), for accessing 0x36a1a000 (code=1/prot=0), db=(nil)((nil):(nil)/(nil):(nil)/???:clean, hash:0/0) handler=(nil)
RSP-0x20:0x0000000000000000 RSP-0x18:0x0000000000000000 RSP-0x10:0x0000000000000000 RSP-0x08:0x0000000000000000
RSP+0x00:0x8000200800000000 RSP+0x08:0x0000000034e30958 RSP+0x10:0x0000000034e30958 RSP+0x18:0x0000000034e30958
RAX:0x0000000000000000 RCX:0x0000000000000000 RDX:0x0000000000000000 RBX:0x0000000000000000 
RSP:0x00000000f1190000 RBP:0x0000000000000000 RSI:0x0000000000000000 RDI:0x0000000000000000 
 R8:0x0000000000000000  R9:0x0000000000000000 R10:0x0000000000000000 R11:0x0000000000000000 
R12:0x0000000000000000 R13:0x0000000000000000 R14:0x0000000000000000 R15:0x0000000000000000 
ES:0x002b CS:0x0023 SS:0x002b DS:0x002b FS:0x0053 GS:0x0033 0346|SIGSEGV @0x3486431c (???(/home/alex/steamcmd_linux/linux32/steamcmd+0x6431c)) (x64pc=(nil)/"???", rsp=0xf1190000, stack=0xf1090000:0xf1190000 own=0xf1090000 fp=(nil)), for accessing 0x5 (code=1/prot=0), db=(nil)((nil):(nil)/(nil):(nil)/???:clean, hash:0/0) handler=(nil)
RSP-0x20:0x0000000000000000 RSP-0x18:0x0000000000000000 RSP-0x10:0x0000000000000000 RSP-0x08:0x0000000000000000
RSP+0x00:0x8000200800000000 RSP+0x08:0x0000000034e30958 RSP+0x10:0x0000000034e30958 RSP+0x18:0x0000000034e30958
RAX:0x0000000000000000 RCX:0x0000000000000000 RDX:0x0000000000000000 RBX:0x0000000000000000 
RSP:0x00000000f1190000 RBP:0x0000000000000000 RSI:0x0000000000000000 RDI:0x0000000000000000 
 R8:0x0000000000000000  R9:0x0000000000000000 R10:0x0000000000000000 R11:0x0000000000000000 
R12:0x0000000000000000 R13:0x0000000000000000 R14:0x0000000000000000 R15:0x0000000000000000 
ES:0x002b CS:0x0023 SS:0x002b DS:0x002b FS:0x0053 GS:0x0033 0346|Double SIGSEGV (code=1, pc=0x3486431c, addr=0x5, prot=00)!
./steamcmd.sh: line 38:   336 Segmentation fault      $DEBUGGER "$STEAMEXE" "$@"
ptitSeb commented 1 week ago

Strange, I don't have this issue on my side (not on M1, but still on arm64 machine).

I wounder if it could be a buffer overflow happening? Can you try to add

printf_log(LOG_INFO, "gethostbyname: idx=%d\n", idx);

line 130 of libc_net32.c to see if idx>=128?

m1m1k4tz commented 1 week ago

Actually the steam app is the one that doesn’t detect the libraries not steamcmd my bad it still won’t detect it after using that env variable

m1m1k4tz commented 1 week ago

Okay

Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS SHA1 SHA2 USCAT FLAGM FLAGM2 FRINT PageSize:4096 Running on Firestorm-M1 with 4 Cores
Will use Hardware counter measured at 24.0 MHz emulating 3.0 GHz
Params database has 90 entries
Box64 with Dynarec v0.3.1 fc7f83c6 built on Sep 12 2024 07:57:08
BOX64: Detected 48bits at least of address space
Counted 27 Env var
BOX64 LIB PATH: BOX64 BIN PATH: ./:bin/:/home/alex/.cargo/bin/:/home/alex/.local/bin/:/home/alex/bin/:/usr/lib64/ccache/:/usr/local/bin/:/usr/bin/:/bin/:/usr/local/sbin/:/usr/sbin/:/sbin/:/usr/local/sbin/:/usr/local/bin/:/usr/sbin/:/usr/bin/:/sbin/:/bin/
Looking for /home/alex/box64/tests/bash
bash detected, disabling banner
Apply RC params for bash
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS SHA1 SHA2 USCAT FLAGM FLAGM2 FRINT PageSize:4096 Running on Firestorm-M1 with 4 Cores
Will use Hardware counter measured at 24.0 MHz emulating 3.0 GHz
Params database has 90 entries
Box64 with Dynarec v0.3.1 fc7f83c6 built on Sep 12 2024 07:57:08
steamcmd detected
BOX64: Detected 48bits at least of address space
Counted 28 Env var
BOX64 LIB PATH: BOX64 BIN PATH: ./:bin/:/home/alex/.cargo/bin/:/home/alex/.local/bin/:/home/alex/bin/:/usr/lib64/ccache/:/usr/local/bin/:/usr/bin/:/bin/:/usr/local/sbin/:/usr/sbin/:/sbin/:/usr/local/sbin/:/usr/local/bin/:/usr/sbin/:/usr/bin/:/sbin/:/bin/
Looking for /home/alex/steamcmd_linux/linux32/steamcmd
BOX64: Using Box32 to load 32bits elf
Memory higher than 32bits reserved
Rename process to "steamcmd"
Using native(wrapped) librt.so.1
Using native(wrapped) libdl.so.2
Using native(wrapped) libpthread.so.0
Using native(wrapped) libm.so.6
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux.so.2
Redirecting stderr to '/home/alex/.local/share/Steam/logs/stderr.txt'
Using native(wrapped) crashhandler.so
Looks like steam didn't shutdown cleanly, scheduling immediate update check
ILocalize::AddFile() failed to load file "public/steambootstrapper_english.txt".
[  0%] Checking for available update...
0349|SIGSEGV @0x34c93ddc (my32_gethostbyname(/home/alex/steamcmd_linux/linux32/steamcmd)) (x64pc=(nil)/"???", rsp=0xf11b0000, stack=0xf10b0000:0xf11b0000 own=0xf10b0000 fp=(nil)), for accessing 0x36a1a000 (code=1/prot=0), db=(nil)((nil):(nil)/(nil):(nil)/???:clean, hash:0/0) handler=(nil)
RSP-0x20:0x0000000000000000 RSP-0x18:0x0000000000000000 RSP-0x10:0x0000000000000000 RSP-0x08:0x0000000000000000
RSP+0x00:0x8000200800000000 RSP+0x08:0x0000000034e30998 RSP+0x10:0x0000000034e30998 RSP+0x18:0x0000000034e30998
RAX:0x0000000000000000 RCX:0x0000000000000000 RDX:0x0000000000000000 RBX:0x0000000000000000 
RSP:0x00000000f11b0000 RBP:0x0000000000000000 RSI:0x0000000000000000 RDI:0x0000000000000000 
 R8:0x0000000000000000  R9:0x0000000000000000 R10:0x0000000000000000 R11:0x0000000000000000 
R12:0x0000000000000000 R13:0x0000000000000000 R14:0x0000000000000000 R15:0x0000000000000000 
ES:0x002b CS:0x0023 SS:0x002b DS:0x002b FS:0x0053 GS:0x0033 0349|SIGSEGV @0x3486431c (???(/home/alex/steamcmd_linux/linux32/steamcmd+0x6431c)) (x64pc=(nil)/"???", rsp=0xf11b0000, stack=0xf10b0000:0xf11b0000 own=0xf10b0000 fp=(nil)), for accessing 0x5 (code=1/prot=0), db=(nil)((nil):(nil)/(nil):(nil)/???:clean, hash:0/0) handler=(nil)
RSP-0x20:0x0000000000000000 RSP-0x18:0x0000000000000000 RSP-0x10:0x0000000000000000 RSP-0x08:0x0000000000000000
RSP+0x00:0x8000200800000000 RSP+0x08:0x0000000034e30998 RSP+0x10:0x0000000034e30998 RSP+0x18:0x0000000034e30998
RAX:0x0000000000000000 RCX:0x0000000000000000 RDX:0x0000000000000000 RBX:0x0000000000000000 
RSP:0x00000000f11b0000 RBP:0x0000000000000000 RSI:0x0000000000000000 RDI:0x0000000000000000 
 R8:0x0000000000000000  R9:0x0000000000000000 R10:0x0000000000000000 R11:0x0000000000000000 
R12:0x0000000000000000 R13:0x0000000000000000 R14:0x0000000000000000 R15:0x0000000000000000 
ES:0x002b CS:0x0023 SS:0x002b DS:0x002b FS:0x0053 GS:0x0033 0349|Double SIGSEGV (code=1, pc=0x3486431c, addr=0x5, prot=00)!
./steamcmd.sh: line 38:   339 Segmentation fault      $DEBUGGER "$STEAMEXE" "$@"
ptitSeb commented 1 week ago

I don't reproduce that exact issue on my side, but I do have network error with steamcmd anyway, so I'm working on that. Hopefully it will fix your issue in the process?

m1m1k4tz commented 1 week ago

I'll try deleting my container for krun and remake it from the guide and see

m1m1k4tz commented 1 week ago

Remaking it didn't seem to fix it for me

ptitSeb commented 6 days ago

I reproduce the issue on my M1, even without krun. I'm actively working on it...

m1m1k4tz commented 2 days ago

Okay thanks, I think that fixed it now I'm getting a network error like you are

📦[alex@asahi-krun ~]$ krun box64 ~/box64/tests/bash
Using default interface naming scheme 'v255'.
INFO <sommelier-scope-timer.cc:30> ~ScopeTimer: configure event loop: 0.000485292 seconds
INFO <sommelier-scope-timer.cc:30> ~ScopeTimer: drm device: 0.0418417 seconds
INFO <sommelier-scope-timer.cc:30> ~ScopeTimer: connect display: 1.875e-05 seconds
INFO <sommelier-scope-timer.cc:30> ~ScopeTimer: client create: 2.6791e-05 seconds
INFO <sommelier-scope-timer.cc:30> ~ScopeTimer: display implementation: 2.75e-06 seconds
INFO <sommelier-scope-timer.cc:30> ~ScopeTimer: spawn xwayland: 0.00032 seconds
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS SHA1 SHA2 USCAT FLAGM FLAGM2 FRINTThe XKEYBOARD keymap compiler (xkbcomp) reports:
> Warning:          Unsupported maximum keycode 708, clipping.
>                   X11 cannot support keycodes above 255.
Errors from xkbcomp are not fatal to the X server
 PageSize:4096 Running on Firestorm-M1 with 4 Cores
Will use Hardware counter measured at 24.0 MHz emulating 3.0 GHz
Params database has 90 entries
Box64 with Dynarec v0.3.1 f674953b built on Sep 17 2024 06:49:51
BOX64: Detected 48bits at least of address space
Counted 18 Env var
BOX64 LIB PATH: BOX64 BIN PATH: ./:bin/:/home/alex/.cargo/bin/:/home/alex/.local/bin/:/home/alex/bin/:/usr/lib64/ccache/:/usr/local/bin/:/usr/bin/:/bin/:/usr/local/sbin/:/usr/sbin/:/sbin/:/usr/local/sbin/:/usr/local/bin/:/usr/sbin/:/usr/bin/:/sbin/:/bin/
Looking for /home/alex/box64/tests/bash
bash detected, disabling banner
Apply RC params for bash
[alex@macbookair ~]$ cd steamcmd_linux/
[alex@macbookair steamcmd_linux]$ ./steamcmd.sh 
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS SHA1 SHA2 USCAT FLAGM FLAGM2 FRINT PageSize:4096 Running on Firestorm-M1 with 4 Cores
Will use Hardware counter measured at 24.0 MHz emulating 3.0 GHz
Params database has 90 entries
Box64 with Dynarec v0.3.1 f674953b built on Sep 17 2024 06:49:51
BOX64: Detected 48bits at least of address space
Counted 27 Env var
BOX64 LIB PATH: BOX64 BIN PATH: ./:bin/:/home/alex/.cargo/bin/:/home/alex/.local/bin/:/home/alex/bin/:/usr/lib64/ccache/:/usr/local/bin/:/usr/bin/:/bin/:/usr/local/sbin/:/usr/sbin/:/sbin/:/usr/local/sbin/:/usr/local/bin/:/usr/sbin/:/usr/bin/:/sbin/:/bin/
Looking for /home/alex/box64/tests/bash
bash detected, disabling banner
Apply RC params for bash
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS SHA1 SHA2 USCAT FLAGM FLAGM2 FRINT PageSize:4096 Running on Firestorm-M1 with 4 Cores
Will use Hardware counter measured at 24.0 MHz emulating 3.0 GHz
Params database has 90 entries
Box64 with Dynarec v0.3.1 f674953b built on Sep 17 2024 06:49:51
steamcmd detected
BOX64: Detected 48bits at least of address space
Counted 28 Env var
BOX64 LIB PATH: BOX64 BIN PATH: ./:bin/:/home/alex/.cargo/bin/:/home/alex/.local/bin/:/home/alex/bin/:/usr/lib64/ccache/:/usr/local/bin/:/usr/bin/:/bin/:/usr/local/sbin/:/usr/sbin/:/sbin/:/usr/local/sbin/:/usr/local/bin/:/usr/sbin/:/usr/bin/:/sbin/:/bin/
Looking for /home/alex/steamcmd_linux/linux32/steamcmd
BOX64: Using Box32 to load 32bits elf
Memory higher than 32bits reserved
Rename process to "steamcmd"
Using native(wrapped) libdl.so.2
Using native(wrapped) librt.so.1
Using native(wrapped) libm.so.6
Using native(wrapped) libpthread.so.0
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux.so.2
Using native(wrapped) crashhandler.so
Redirecting stderr to '/home/alex/.local/share/Steam/logs/stderr.txt'
Logging directory: '/home/alex/.local/share/Steam/logs'
[  0%] Checking for available updates...
[----] Verifying installation...
[  0%] Downloading update...
[  0%] Checking for available updates...
UpdateUI: skip show logo[----] !!! Fatal Error: Steamcmd needs to be online to update. Please confirm your network connection and try again.
src/tier0/threadtools.cpp (3465) : Assertion Failed: Illegal termination of worker thread 'Thread(0x0x61e576e0/0x0xf13f7f'
ptitSeb commented 2 days ago

Yep, I have the exact same log... I have started debugging but still haven't found the source cause of the issue. I'm also adding some more libs support so I can run a few more program. For now, I can run zsnes (the 32bits linux version, and Unreal (the original version, 32bits linux build, but without sound for now), both using SDL1.2 to setup the display, because X11 is not wrapped. But OpenGL is. And both are running on my M1 as-is (no need for krun). image

m1m1k4tz commented 1 day ago

The network problem looks like a krun issue so I've opened a bug there https://github.com/AsahiLinux/krun/issues/61

ptitSeb commented 1 day ago

The network problem looks like a krun issue so I've opened a bug there AsahiLinux/krun#61

No it's not. I have the exact same issue without krun! It's a box64 issue. You can try yourself, you can run it without krun you will get the same result as with krun.

m1m1k4tz commented 1 day ago

Oh okay I guess I found a different one then with krun I don’t think the network would work on the m1 right now even if you fixed it on box64

ptitSeb commented 1 day ago

mmm, have you tried without krun? you get a different a output?

ptitSeb commented 1 day ago

Oh, you mean those error:

ping: socktype: SOCK_DGRAM
ping: socket: Address family not supported by protocol

Yes, that seems krun related indeed!

m1m1k4tz commented 1 day ago

I tested out ping and it gave me this in krun

ping: socktype: SOCK_DGRAM
ping: socket: Address family not supported by protocol