Skip to content

[macOS] [Arm] Build: List of issues when building locally on an M1 Mac  #15008

Open
@shinra-electric

Description

@shinra-electric

Quick summary

I haven't been able to build on macOS Sonoma and Xcode 15 since I upgraded. (I can't downgrade to Ventura as it's a work laptop).
But over Christmas I had access to an M1 with Ventura still installed and managed to work through some of the issues I was having. I was able to build a working app with Ventura and a broken app with Sonoma. I suspect the Sonoma app is broken due to the new Linker in Xcode 15. Fixed. See below for details

Note that the app built with Ventura will work fine on Sonoma.

I thought I'd list the issues and workarounds here so someone more knowledgeable than me might be able to fix some of them.

Details

  • Old-style-cast errors: Fixed by Fix Apple Clang build #15240

  • glslang: needs to be uninstalled from homebrew, or else the build will fail. This is documented in [macOS] [Arm] Building on Arm fails if glslang is installed locally via homebrew #13540 Fixed

  • cubeb: needs to be uninstalled from homebrew, or else the build will fail.
    Log file:
    cubeb.txt

  • llvm: CMake complains that llvm 17 or 18 are not acceptable, and that llvm@16 is required. However this warning can be ignored.

  • libfreetype.6.dylib: incorrect loader_path. brew reinstall freetype should fix this. If not, another workaround is in the comments below.

  • ffmpeg 7: There has been a change to a variable name in ffmpeg 7. (Workaround below) fixed.

It's possible to build with the following instructions:

# install dependencies
brew install cmake ffmpeg glew libusb llvm molten-vk nasm ninja pkg-config qt@6 sdl2 vulkan-headers
brew rm cubeb

export Qt6_DIR=$(brew --prefix)/opt/qt6
export VULKAN_SDK=$(brew --prefix)/opt/molten-vk
if [ ! -h "$VULKAN_SDK/lib/libvulkan.dylib" ]; then 
	ln -s "$VULKAN_SDK/lib/libMoltenVK.dylib" "$VULKAN_SDK/lib/libvulkan.dylib"
fi 
export VK_ICD_FILENAMES=$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json
export LLVM_DIR=$(brew --prefix)/opt/llvm

git clone --recursive https://github.com/RPCS3/rpcs3
cd rpcs3

# Fix hidapi
sed -i '' "s/extern const double NSAppKitVersionNumber;/const double NSAppKitVersionNumber = 1343;/g" 3rdparty/hidapi/hidapi/Mac/hid.c

# Configure build system
cmake . -B build -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="AArch64;ARM" \
	-GNinja \
	-DUSE_SYSTEM_MVK=on \
	-DUSE_SDL=ON \
	-DUSE_SYSTEM_SDL=ON \
	-DUSE_FAUDIO=OFF \
	-DBUILD_LLVM=OFF\
	-DUSE_SYSTEM_LIBPNG=ON \
	-Wno-deprecated

# Build
ninja -C build
codesign --force --deep --sign - build/bin/rpcs3.app/Contents/MacOS/rpcs3

Sonoma crash

The Sonoma build crashes on launch saying it cannot find the bundled libraries. However, they are correctly bundled within the app.
Crash report:
rpcs3 arm crash report sonoma.txt

This is fixed. The issue was with libfreetype.6.dylib. The @loader_path was incorrect. Referring back to the Ventura build with otool I could see it should be @executable_path, and it was pointing to the wrong place. But install_name_tool refused to change it, saying it would invalidate the signature. So I removed the signature and then changed it. This was successful.

Edit: Reinstalling with brew reinstall freetype seems to have fixed the underlying issue for me. The workaround may not be required.

System configuration

M1 Pro
Ventura 13.6.3 & Xcode 14.3.1
Sonoma 14.3 Beta & Xcode 15.1

Edit: Removed advice about using the interpreter. LLVM is now working.

Metadata

Metadata

Assignees

Labels

Build and CIAnything related to the build process and continuous integrationOS: macOS

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions