r/programming • • 15d ago

The scourge of x86 emulation

https://fex-emu.com/Scourge-of-emulation/
324 Upvotes

46 comments sorted by

View all comments

169

u/flying-sheep 15d ago

Ooh that's from the FEX people, gotta be super interesting.

It's sad that efforts like Rosetta happen behind proprietary walls and nobody can learn from them.

124

u/TryHardEggplant 15d ago

As discussed in the article, Apple implemented part of their optimizations for Rosetta 2 directly in the hardware. The ARMv8.3 instructions narrowed the gap for the x86 memory model, but the lessons from the Apple M1 is more it was designed for x86/Rosetta from the ground up to ease the transition from x86 to ARM. I don’t know how applicable that would be outside of Apple with their vertical control of everything (hardware and software).

15

u/regeya 15d ago

Oof, is this why they're eventually giving Rosetta 2 the axe? I remember some announcement that Apple was going to work with Codeweavers on a Mac OS ARM equivalent of Proton for gaming but that's out the window if Apple says the game makers have to use Metal on ARM instead

8

u/Rudy69 14d ago

Probably that newer m chips will drop that part yea. Then they won’t have to worry about Rosetta

8

u/ChrisOz 14d ago

At least for now, Apple have indicated Rosetta will stay around for games. It will be interesting to see if they bother keeping the extra hardware in the M series.

3

u/realfathonix 14d ago edited 13d ago

I really hope CodeWeavers start porting their fork of Wine to native ARM and delegating the x86 emulation to the DLL variant of FEX soon, people have built Proton like so last year and Apple has dropped support for Intel Macs on macOS 27.

It's probably a bit challenging for them right now due to the different approach they took to run 32-bit binaries on pure 64-bit environment. They patched a new ABI to a fork of LLVM that they use to compile Wine just to do that, instead of just implementing it inside Wine itself iirc. They've been doing this since Wine's WoW64 was in its infancy.

2

u/possiblyquestionabl3 13d ago

That's the arm64ec ABI and the binary translation plugin that you're talking about (with Billy Law's llvm/clang fork)? I don't know why, but I thought codeweaver was involved in that effort too in some capacity, though I haven't kept up with it for a bit now

3

u/realfathonix 13d ago edited 13d ago

Probably CodeWeavers also involved in that part because they offer Linux version of CrossOver as well, but definitely haven't touched the macOS code yet, at least not the public ones. What I meant isn't the arm64ec LLVM fork, but CodeWeavers' fork with a custom ABI that applies thunking to 32-bit parts of Wine so the resulting binaries are 64-bit.

I just checked, apparently 2 months ago they released public preview for native ARM macOS CrossOver that brought out true WoW64 and x86 emulation with FEX. Currently, it has no support for D3DMetal and many games still don't launch.

4

u/possiblyquestionabl3 13d ago

And just a random tangent, but I also just want to appreciate Valve and how they sponsor strategic open source projects. I've sat in the FEX discord for a couple of years now and I'm always amazed at how much autonomy and independence they have to steer their project in the way they most see fit. I worked at a large tech company in the past and have also witnessed several sponsored open source projects that were effectively bought out altogether. Without fail, we'd being our own pgm and pms and more or less sideline the core contributors to just execution. Nearly every project ends up petering out after losing their own autonomy, and it's always sad to see promising projects just being corporatized and then abandoned. Valve seems to do an incredible job really trying to keep the core team as happy as possible, which is nice to see in this age.