Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac: fix arm64 build #11730

Merged
merged 2 commits into from Apr 18, 2022
Merged

Mac: fix arm64 build #11730

merged 2 commits into from Apr 18, 2022

Conversation

sguo35
Copy link
Contributor

@sguo35 sguo35 commented Apr 4, 2022

Fixes the build to compile for arm64, but obviously nothing works yet. Current next step is to implement W^X which Apple enforces on arm64, then dealing with the virtual memory situation.

Build (make sure your brew is arm64):

brew install molten-vk vulkan-headers sdl2 nasm qt@5 ninja cmake glew ffmpeg
export Qt5_DIR=$(brew --prefix)/opt/qt5
export VULKAN_SDK=$(brew --prefix)/opt/molten-vk
# taken from build-mac.sh
ln -s "$VULKAN_SDK/lib/libMoltenVK.dylib" "$VULKAN_SDK/lib/libvulkan.dylib"
export VK_ICD_FILENAMES=$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json

git clone git@github.com:sguo35/rpcs3.git
cd rpcs3
# also taken from build-mac.sh
sed -i '' "s/extern const double NSAppKitVersionNumber;/const double NSAppKitVersionNumber = 1343;/g" 3rdparty/hidapi/hidapi/mac/hid.c

mkdir build
cd build
cmake .. -DPNG_ARM_NEON=on -DUSE_ALSA=OFF -DUSE_PULSE=OFF -DUSE_AUDIOUNIT=ON -DUSE_NATIVE_INSTRUCTIONS=OFF -DUSE_SYSTEM_FFMPEG=on -DCMAKE_OSX_ARCHITECTURES="arm64" -DLLVM_TARGETS_TO_BUILD="X86;AArch64;ARM" -GNinja
ninja

# Apple enforces codesigning on Apple Silicon
codesign --force --deep --sign - bin/rpcs3.app/Contents/MacOS/rpcs3
# will fail verification on memory_commit
./bin/rpcs3.app/Contents/MacOS/rpcs3

rpcs3/Emu/CPU/sse2neon.h Outdated Show resolved Hide resolved
3rdparty/llvm.cmake Outdated Show resolved Hide resolved
@Megamouse Megamouse added OS: Mac Build and CI Anything related to the build process and continuous integration labels Apr 4, 2022
@kd-11
Copy link
Contributor

kd-11 commented Apr 5, 2022

This patch will allow rpcs3 to actually load the GUI, but ofc nothing runs successfully.
kd-11@9b014a5#diff-37645c22f08af879d11df33551addfb65b4df9568bc3e02c956c7df5e020d759R273-R289
The #ifndef APPLE check should read #if !defined(APPLE) || defined(ARCH_X64) of course. The hacky set of patches there was from a few weeks ago when we were working on getting it working to see how far it would get.

Adds arm64 branches to some x86 specific code and modifies some casting
logic to make Clang happy
@sguo35
Copy link
Contributor Author

sguo35 commented Apr 5, 2022

@Nekotekina @Megamouse fixed

@kd-11 On Apple Silicon you have to invalidate the icache after toggling permissions, also in the future if we want to distribute Mac binaries then we need to sign the binary -> we need to pass MAP_JIT in mmap calls, see Apple docs.

@kd-11
Copy link
Contributor

kd-11 commented Apr 5, 2022

@Nekotekina @Megamouse fixed

@kd-11 On Apple Silicon you have to invalidate the icache after toggling permissions, also in the future if we want to distribute Mac binaries then we need to sign the binary -> we need to pass MAP_JIT in mmap calls, see Apple docs.

I know all of that, honestly I'm hoping someone else handles it. This isn't a mac-first product afterall, the design needs to not break the other 3 operating systems. Do not read too much into hacky "get me something working quickly" code on the repo, I was merely pointing out why it doesn't get to the GUI, in case you want to verify that the build works.

@sguo35
Copy link
Contributor Author

sguo35 commented Apr 5, 2022

I know all of that, honestly I'm hoping someone else handles it. This isn't a mac-first product afterall, the design needs to not break the other 3 operating systems. Do not read too much into hacky "get me something working quickly" code on the repo, I was merely pointing out why it doesn't get to the GUI, in case you want to verify that the build works.

Ah, I thought you were saying to integrate that patch, my bad. I was planning on incrementally putting up PRs for each issue I ran into as I fixed stuff so I expected the gui to fail to start.

@Nekotekina Nekotekina merged commit e761b32 into RPCS3:master Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build and CI Anything related to the build process and continuous integration OS: Mac
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants