FEX-Emu / FEX

A fast usermode x86 and x86-64 emulator for Arm64 Linux
https://fex-emu.com
MIT License
2.03k stars 108 forks source link

Mingw compilation support #2399

Open Sonicadvance1 opened 1 year ago

Sonicadvance1 commented 1 year ago

This is going to require quite a bit of restructuring.

Step-0 - [ ] Get FEXCore compiling with GCC

Step-1

Step-2

Step-3

Investigation

Sonicadvance1 commented 1 year ago

Looks like building llvm-mingw is very straightforward. Their instructions for ./build-all.sh <target-dir> works out of the box locally. Might just take a while depending on environment.

anthony-linaro commented 1 year ago

Hello, just sticking my head in here, I have a reasonable amount of experience with this :)

You're far better off sticking with clang (GCC is a WIP), and unless you want ABI compatiblity with MSVC, you can use the standard aarch64-w64-windows-gnu target with reasonable success.

May I suggest you use msys2? If you have a Windows ARM64 machine, you can use it directly on that with the "clangarm64" packages. I incidentally am in the process of moving over blender from mingw -> msys2, as it's considerably easier.

AndreRH commented 1 year ago

Hi, this should help with my effort to get FEX into Hangover! What's your reason to make it mingw-w64 compatible? With having it as PE I think debugging will be improved, which is quite nice. While I already can run some games with Hangover/FEX, I stumble across odd crashes in FEXCores' libstdc++ which are really hard to debug across PE<->Unix boundaries. So +1 for this task :)

Sonicadvance1 commented 1 year ago

Hi, this should help with my effort to get FEX into Hangover! What's your reason to make it mingw-w64 compatible? With having it as PE I think debugging will be improved, which is quite nice. While I already can run some games with Hangover/FEX, I stumble across odd crashes in FEXCores' libstdc++ which are really hard to debug across PE<->Unix boundaries. So +1 for this task :)

The llvm-mingw support is specifically for helping with Wine integration. Since PE side will likely be the more optimal codepath. The current PR for getting llvm-mingw support is an initial build-tested path but there are still linux assumptions sprinkled around. Like calling convention and assuming we can read some EL1 MSRs. In at least the short-term I don't care about actually executing in a ARM64 Windows environment, so some of these assumptions are fine.

Sonicadvance1 commented 1 year ago

With all the llvm-mingw initial build PRs merged, this should now technically work to some extent. If you find anything that we can improve on our side for llvm-mingw support then we would be willing to facilitate that. Since we don't have any testing on our side for this yet, then I don't know the full scope of what is necessary yet.

AndreRH commented 1 year ago

I guess I need some build instructions, tried this, but didn't work: CC=x86_64-w64-mingw32-clang CXX=x86_64-w64-mingw32-clang++ cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Releaseu -DENABLE_LLD=True -DBUILD_TESTS=False -DENABLE_ASSERTIONS=False -DENABLE_X86_HOST_DEBUG=True .. make FEXCore

leads to error when building jemalloc

Sonicadvance1 commented 1 year ago

Yea, jemalloc needs to be disabled for mingw currently. cmake options: -DENABLE_JEMALLOC=False -DENABLE_JEMALLOC_GLIBC_ALLOC=False.

Implications of this just means that when executing a 32-bit application, FEX will have its memory usage also in the lower 32-bits. Which means that most things will exhaust VA since FEX uses a decent amount.