The other thing they do, is put code in the full 64-bit address space, but then have the linker generate trampolines in first 32-bits which jump to the actual function location so 32-bit function pointers can be used for code living outside the 32-bit address space.
I believe VMS on Alpha and Itanium did similar things. Applications on VAX assumed 32-bit addresses. Even though Alpha was a 64-bit architecture, to make it easy to port apps from VAX, they had applications mostly use 32-bit pointers (which are really 64-bit pointers with half of their value fixed), if you need more memory, you have to change your application to call some new APIs which return arbitrary 64-bit pointers. And then the same setup was maintained when they ported to Itanium, and now x86-64.
Actually IBM z/OS does something similar. IBM mainframes originally used 24-bit addressing, in the early 1980s they moved to 31-bit addressing (not 32-bit, the MSB was used as a flag bit), then around 2000 they moved to 64-bit. However, even in a 64-bit process, they still have the rule that all code has to be in the first 2GB of memory, to simplify interoperation between 31-bit and 64-bit code. But even though all code pointers must be safely expressible in 31-bits, 64-bit applications can use the full 64-bit address space for data.
Seems like the kind of thing that OS X desperately needed...
On x86-64, Linux supports legacy 32-bit apps (i386 ABI) and native 64-bit apps (x86-64 ABI). However, the x32 ABI isn't either of those. x32 is actually a hybrid 32-bit/64-bit architecture, that lets you use some of the newer features of x86-64 (such as increased number of registers) while keeping 32-bit memory addresses. The theory behind it is that for apps that don't really need a 64-bit address space, 32-bit pointers consume less RAM than 64-bit ones. Using less RAM can have flow-on performance benefits – you fit more in the CPU cache, etc.
While x32 is a nice idea in theory, it never really took-off. It is adding a lot of complexity (a third architecture for distributions to support) in exchange for merely modest performance improvements. And it has nothing to do with backward compatibility – that is the role of the i386 ABI, not the x32 ABI. i386 ABI gives binary backward compatibility, x32 ABI requires a recompile. It might be a little bit easier to port from i386 to x32 than from i386 to x86-64, given the pointers remain 32-bit; however, in practice, people either just stick with the existing i386 ABI binaries, or skip it and make the code changes for 64-bit.
> Seems like the kind of thing that OS X desperately needed...
Apple didn't have to discontinue 32-bit application support for macOS. They made a commercial decision that doing so would save on engineering resources. It ultimately had a business/financial motivation not a purely technical one.
It possibly made their task of implementing x86 emulation on ARM somewhat easier. However, they always could have either (a) invested more to support emulating 32-bit x86 on ARM as well (b) limited x86 emulation on ARM to 64-bit but continue supporting 32-bit on native x86. The fact that they didn't do either (a) or (b) – again, ultimately a business/commercial decision about where to invest, not a technical one.
(And the truth is, 32-bit application support isn't completely discontinued. x86-64 macOS still supports running 32-bit code, as demonstrated by the Codeweavers branch of Wine. They removed the 32-bit libraries from the OS, and blocked the execution of 32-bit Mach-O executables, but there still exists an API which applications like Wine can use to manually set up a 32-bit address space and run some 32-bit code in it.)
Sounds like it’s easier to rebuild as a Win32 and have OS X users use wine then.
I know a company the size of Apple can’t be expected to be some kind of stable dev platform like how Microsoft treats Windows where I can still run Win32 stuff from 1993 on Windows 10 x64. Maybe one day Apple might take an interest in the desktop again but it seems so unlikely.
It wasn't easy, no. They had to do two things:
1) Fork clang and extensions to C to support mixed 32-bit and 64-bit address spaces
2) Get a special code-signing entitlement from Apple allowing them to call the API to enable 32-bit code execution (not required if you are okay with disabling SIP)
Lots of technical details here: https://www.winehq.org/pipermail/wine-devel/2019-December/15...
Yeah, this is a monumental effort that few other than Codeweavers could replicate, and I believe they got some help from Apple engineering to do it.
They've open sourced their code, but they aren't upstreaming it into mainstream Wine – having to use a forked C compiler is just a bit too much.
"Since the stack and static data on x86 is still allocated in 32-bit address space, a 32-bit pointer is sufficient to point to them."
It seems they're still expecting a lot of VAX users to migrate.
I do suspect as time goes by x86 is just becoming more synonymous with the 64 bit variant, the 32 bit and 16 bit modes are increasingly irrelevant to anyone except boot ROM authors and retro enthusiasts.
This isn't relevant just to VAX code -- because previous versions of VMS made these same accomodations, some programs simply never changed, up to Itanium, despite both alpha and Itanium being 64 bit (and only 64 bit, alpha didn't and I don't think Itanium had "true" 32 bit modes)
So "x86” is really referring more to the platform than the specific CPU or mode here, since it'll be a pretty seamless mixture of both.