Hi,
I've tried out building and running wine on macOS on arm64, and gotten it working for small test executables at least.
Overall it seems to work, but getting it to work requires dealing with three main issues - some of them that can make it hard to use this with any unmodified windows executable:
- The page size on darwin on ARM64 is 16 KB, not 4 KB. For some bits, e.g. ntdll/unix, this is possible to handle, but e.g. if one were to build ntdll as a PE, this PE would need to know that it's supposed to run in a different environment. And this one makes it impossible to run normal executables, unless they've been linked with e.g. -Wl,--section-alignment,0x4000.
- Setting -pagezero_size to anything less than 4 GB seems to make macOS refuse to run the executable. So this makes it impossible to map anything into the lower 4 GB of the address space. For now, I've worked it around by moving the address at which user_shared_data is allocated.
- Memory mappings can't be writable and executable at the same time. If one mmap()s a page and request it to be both writable and executable, writing to it fails, same if changing protection with mprotect(). This requires changes in a few places, to avoid needlessly(?) allocating things as executable, or map buffers first in readwrite mode, while changing to read-execute after filling them.
And a potential fourth one that I haven't really dealt with yet:
- Darwin also treats x18 as reserved, just like windows, but IIRC the system can spuriously(?) overwrite the register to zero at some times. I haven't run into this in the context of wine on macOS yet though.
Regardless of these issues, I'll start off by sending the patches that are the most clean, that should fix compilation for this target at least.
Martin Storsjo (4): winebuild: Use the right arm64 page/pageoff relocation syntax for darwin ntdll: Trust libunwind's returned pc value on arm64 ntdll: Fix the arm64 use of libunwind for macOS ntdll: Implement arm64 sigcontext access for macOS
dlls/ntdll/unix/signal_arm64.c | 75 +++++++++++++++++++++++++++++++++- tools/winebuild/build.h | 2 + tools/winebuild/import.c | 34 +++++++-------- tools/winebuild/spec32.c | 4 +- tools/winebuild/utils.c | 32 +++++++++++++++ 5 files changed, 128 insertions(+), 19 deletions(-)