FEX-Emu X86 and x86_64 Emulator Packages

Post Reply
jgmdev
Posts: 368
Joined: Tue Jan 28, 2020 2:28 pm
languages_spoken: english, spanish
ODROIDs: U2, N2, N2+, C4, HC4
Has thanked: 151 times
Been thanked: 262 times
Contact:

FEX-Emu X86 and x86_64 Emulator Packages

Post by jgmdev »

For those that haven't heard about it FEX-Emu is a fast usermode x86 and x86-64 emulator for Arm64 that can allow our small single board computers to run applications developed for those intel and amd cpu's that haven't been ported to ARM64 like for example Steam, Spotify, etc... :)

The project seems to already boot some Triple A games as reported on this tweet (no jokes):
https://twitter.com/FEX_Emu/status/1423974617857748998

Screenshots from the tweet:
Image
Image
Image
Image

I wanted to experiment with this project for some time now and decided this week to build all the required packages to compile it. The project core it self is not hard to build but it also has optional support for using thunks which the project itself describes as a combination of Guest -> Host libraries that allow Fex-Emu to use your native system capabilities, which translates to better performance (similar to box86 and box64). Thunks is where the difficulty relies, archlinuxarm doesn't hosts cross-compiling toolchains that target x86_64 which is actually needed to build the library thunks (and I don't wanted to rely on a x86_64 machine to build them), so I had to build them by peeking at other cross compiling tool-chains and reading some docs which took some effort since I never had the need before of cross-compiling or building my own toolchains :)

Anyways I was able to get everything built and now it is hosted on the archdroid repositories, here are the relevant packages that allow one to build x86 applications directly on aarch64 (times are really changing, who would thought cross-compiling from aarch64 to x86_64 :D):

https://archdroid.org/packages/x86_64-binutils
https://archdroid.org/packages/x86_64-linux-api-headers
https://archdroid.org/packages/x86_64-gcc
https://archdroid.org/packages/x86_64-glibc

And the most important part, I setup some fex-emu git packages that are automatically built each time a new commit is made to the fex-emu git repository:

https://archdroid.org/packages/fex-emu-git <- core fex emulator
https://archdroid.org/packages/fex-emu-thunks-git <- Guest (x86_64) -> Host (aarch64) libraries for better performance.

Fex-Emu requires a x86_64 rootfs to run the applications, instructions on how to setup the rootfs and use it can be found at:
https://wiki.fex-emu.org/index.php/Deve ... _up_RootFS

I already have an ArchLinux x86_64 rootfs that I setup with qemu some time ago but gotta make some changes to it before use with fex. For now I just built Fex-Emu but haven't tested it since it took couple days to figure out the cross-compilers and now is time to sleep ;). Hope that some one can give it a try, hopefully before I do and report how it goes and if you can run Crysis :lol:!

User avatar
squidd
Posts: 82
Joined: Thu Jul 30, 2020 11:41 pm
languages_spoken: english
ODROIDs: N2+
Has thanked: 37 times
Been thanked: 9 times
Contact:

Re: FEX-Emu X86 and x86_64 Emulator Packages

Post by squidd »

Nice! I will be testing this over the weekend! Gotta wipe the dust off the N2+ first though

jgmdev
Posts: 368
Joined: Tue Jan 28, 2020 2:28 pm
languages_spoken: english, spanish
ODROIDs: U2, N2, N2+, C4, HC4
Has thanked: 151 times
Been thanked: 262 times
Contact:

Re: FEX-Emu X86 and x86_64 Emulator Packages

Post by jgmdev »

I was able to set my rootfs for fex, had to compile mesa with panfrost enabled for x86_64 and install it to the rootfs. After, ran some x86_64 only applications like zoom and spotify, zoom was rendered correctly but spotify window just rendered as plain white. The performance isn't great (at least on the N2 CPU) in comparison to box64 or box86 which offers better performance but the compatibility seems much better than box86/64 which isn't able to run these applications. It seems fex-emu developers are targeting some newer ARM instruction sets only found on armv8.1 cpu's for speed which aren't supported by the CPU used on the N2.

These are some of the messages that I got while running zoom in case some advanced user is reading this:

Code: Select all

[DEBUG] Host CPU doesn't support atomics. Expect bad performance
[ERROR] Missing OpDispatcher at 0x7ffffae6059e{'XBEGIN'}
[ERROR] Missing OpDispatcher at 0x7ffffae6063a{'XEND'}
[Info] clone: Unsuported flags w/o CLONE_THREAD (Shared Resources), 4111
[Info] 	Flag: CSIGNAL
[Info] 	Flag: CLONE_VM
[Info] 	Flag: CLONE_VFORK
[DEBUG] clone: WARNING: CLONE_VFORK w/o CLONE_THREAD
[DEBUG] Host CPU doesn't support atomics. Expect bad performance
[DEBUG] Host CPU doesn't support atomics. Expect bad performance
[ERROR] Missing OpDispatcher at 0x7fffe7c4159e{'XBEGIN'}
[ERROR] Missing OpDispatcher at 0x7fffe7c4163a{'XEND'}
An here is the screenshot of zoom succesfully running albeit with limited performance:
Image

Pretty interesting so far lets, see how far this project goes :)
These users thanked the author jgmdev for the post:
odroid (Sun Nov 14, 2021 6:05 pm)

crashoverride
Posts: 5484
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 484 times
Contact:

Re: FEX-Emu X86 and x86_64 Emulator Packages

Post by crashoverride »

jgmdev wrote:
Sat Nov 13, 2021 6:11 am
It seems fex-emu developers are targeting some newer ARM instruction sets only found on armv8.1 cpu's for speed which aren't supported by the CPU used on the N2.
There is an interesting article on atomics here:
https://cpufun.substack.com/p/atomics-in-aarch64
At up to 3 cores the LL-SC outperforms the single atomic, but above that (and overall) it is significantly slower.
I should also note, the ODROID-C4 is Armv8.2 and includes support for atomics.

Code: Select all

Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp
[edit]
The implication of the above was to try testing with only the four big (A-73) cores of the N2. If "taskset" does not work, the two little cores can be set "offline" using the /sys entry for them.

User avatar
mctom
Posts: 782
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: N2+, Game Advance, a few XU4
Location: Gdansk, Poland
Has thanked: 81 times
Been thanked: 97 times
Contact:

Re: FEX-Emu X86 and x86_64 Emulator Packages

Post by mctom »

crashoverride wrote:
Sat Nov 13, 2021 6:47 am
The implication of the above was to try testing with only the four big (A-73) cores of the N2.
And probably modify compiler flags to generate a73 code only. I'm not entirely sure how it works, but if I had to guess compiler would use only functions present in all cores.
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

User avatar
rooted
Posts: 8875
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 743 times
Been thanked: 407 times
Contact:

Re: FEX-Emu X86 and x86_64 Emulator Packages

Post by rooted »

Nice work, I need to switch out the N2+ with the C4 as my media center so I can give this a go.

Post Reply

Return to “Arch Linux ARM (ALARM)”

Who is online

Users browsing this forum: No registered users and 1 guest