From 7751b63846ea17ac1c865ca5af3e8483b1397428 Mon Sep 17 00:00:00 2001 From: nastys Date: Tue, 8 Aug 2023 08:47:48 +0200 Subject: [PATCH] Support Apple Clang and fix building on macOS Sonoma --- .ci/build-mac.sh | 63 ++++++++++++++++++++++++--------- .cirrus.yml | 3 ++ darwin/util/sysinfo_darwin.mm | 4 +++ rpcs3/display_sleep_control.cpp | 4 +++ 4 files changed, 58 insertions(+), 16 deletions(-) diff --git a/.ci/build-mac.sh b/.ci/build-mac.sh index 0a945405376f..3bf4fbe1c2ac 100755 --- a/.ci/build-mac.sh +++ b/.ci/build-mac.sh @@ -1,17 +1,31 @@ #!/bin/sh -ex -export HOMEBREW_NO_AUTO_UPDATE=1 -brew install -f --overwrite nasm ninja git p7zip create-dmg ccache pipenv - -#/usr/sbin/softwareupdate --install-rosetta --agree-to-license -arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -arch -x86_64 /usr/local/bin/brew update -arch -x86_64 /usr/local/bin/brew install -f --overwrite llvm@16 glew cmake sdl2 vulkan-headers ffmpeg -arch -x86_64 /usr/local/bin/brew link -f llvm@16 - -# moltenvk based on commit for 1.2.4 release -wget https://raw.githubusercontent.com/Homebrew/homebrew-core/b233d4f9f40f26d81da11140defbfd578cfe4a69/Formula/molten-vk.rb -arch -x86_64 /usr/local/bin/brew install -f --overwrite ./molten-vk.rb +if [ "$(arch -x86_64 echo test)" = "test" ]; then + echo "Rosetta is installed or building on Intel" +else + echo "Installing Rosetta" + /usr/sbin/softwareupdate --install-rosetta --agree-to-license +fi + +if [ -z "$INSTALL_DEPS" ]; then + export INSTALL_DEPS="true" +fi + +if [ "$INSTALL_DEPS" = "true" ] ; then + export HOMEBREW_NO_AUTO_UPDATE=1 + brew -v || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + brew install -f --overwrite nasm ninja git p7zip create-dmg ccache pipenv + + arch -x86_64 /usr/local/bin/brew -v || arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + arch -x86_64 /usr/local/bin/brew update + arch -x86_64 /usr/local/bin/brew install -f --overwrite llvm@16 glew cmake sdl2 vulkan-headers ffmpeg + arch -x86_64 /usr/local/bin/brew link -f llvm@16 + + # moltenvk based on commit for 1.2.4 release + wget https://raw.githubusercontent.com/Homebrew/homebrew-core/b233d4f9f40f26d81da11140defbfd578cfe4a69/Formula/molten-vk.rb + arch -x86_64 /usr/local/bin/brew install -f --overwrite ./molten-vk.rb +fi + #export MACOSX_DEPLOYMENT_TARGET=12.0 export CXX=clang++ export CC=clang @@ -28,8 +42,13 @@ export WORKDIR; WORKDIR="$(pwd)" # Get Qt +if [ -z "$QT_VER" ]; then + export QT_VER="6.5.2" +fi + if [ ! -d "/tmp/Qt/$QT_VER" ]; then mkdir -p "/tmp/Qt" + rm -rf qt-downloader git clone https://github.com/engnr/qt-downloader.git cd qt-downloader git checkout f52efee0f18668c6d6de2dec0234b8c4bc54c597 @@ -45,7 +64,15 @@ ditto "/tmp/Qt/$QT_VER" "qt-downloader/$QT_VER" export Qt6_DIR="$WORKDIR/qt-downloader/$QT_VER/clang_64/lib/cmake/Qt$QT_VER_MAIN" export SDL2_DIR="$BREW_X64_PATH/opt/sdl2/lib/cmake/SDL2" -export PATH="$BREW_X64_PATH/opt/llvm@16/bin:$WORKDIR/qt-downloader/$QT_VER/clang_64/bin:$BREW_BIN:$BREW_SBIN:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin:$PATH" +export PATH="$WORKDIR/qt-downloader/$QT_VER/clang_64/bin:$BREW_BIN:$BREW_SBIN:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin:$PATH" + +if [ "$USE_APPLE_CLANG" = "true" ]; then + echo "Building using Apple Clang" +else + echo "Building using Homebrew Clang" + export PATH="$BREW_X64_PATH/opt/llvm@16/bin:$PATH" +fi + export LDFLAGS="-L$BREW_X64_PATH/lib -Wl,-rpath,$BREW_X64_PATH/lib" export CPPFLAGS="-I$BREW_X64_PATH/include -msse -msse2 -mcx16 -no-pie" export LIBRARY_PATH="$BREW_X64_PATH/lib" @@ -53,11 +80,11 @@ export LD_LIBRARY_PATH="$BREW_X64_PATH/lib" export VULKAN_SDK VULKAN_SDK="$BREW_X64_PATH/opt/molten-vk" -ln -s "$VULKAN_SDK/lib/libMoltenVK.dylib" "$VULKAN_SDK/lib/libvulkan.dylib" +ln -s "$VULKAN_SDK/lib/libMoltenVK.dylib" "$VULKAN_SDK/lib/libvulkan.dylib" || echo "Using existing libvulkan.dylib" export VK_ICD_FILENAMES="$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json" export LLVM_DIR -LLVM_DIR="BREW_X64_PATH/opt/llvm@16" +LLVM_DIR="$BREW_X64_PATH/opt/llvm@16" # exclude FAudio, SPIRV and LLVM, and sdl from submodule update # shellcheck disable=SC2046 git submodule -q update --init --depth=1 --jobs=8 $(awk '/path/ && !/llvm/ && !/SPIRV/ && !/SDL/ { print $3 }' .gitmodules) @@ -65,7 +92,11 @@ git submodule -q update --init --depth=1 --jobs=8 $(awk '/path/ && !/llvm/ && !/ # 3rdparty fixes sed -i '' "s/extern const double NSAppKitVersionNumber;/const double NSAppKitVersionNumber = 1343;/g" 3rdparty/hidapi/hidapi/mac/hid.c -mkdir build && cd build || exit 1 +if [ "$CLEAN_BUILDDIR" = "true" ]; then + rm -rf build || echo "build directory not deleted" +fi + +mkdir -p build && cd build || exit 1 "$BREW_X64_PATH/bin/cmake" .. \ -DUSE_SDL=ON \ diff --git a/.cirrus.yml b/.cirrus.yml index 437c7dbe901e..40edaae52699 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -145,6 +145,9 @@ macos_task: UPLOAD_COMMIT_HASH: 51ae32f468089a8169aaf1567de355ff4a3e0842 UPLOAD_REPO_FULL_NAME: "rpcs3/rpcs3-binaries-mac" RELEASE_MESSAGE: "../GitHubReleaseMessage.txt" + INSTALL_DEPS: true + USE_APPLE_CLANG: true + CLEAN_BUILDDIR: true artifacts: name: Artifact path: "artifacts/*" diff --git a/darwin/util/sysinfo_darwin.mm b/darwin/util/sysinfo_darwin.mm index e398b69d0382..86c2e8a7e33a 100644 --- a/darwin/util/sysinfo_darwin.mm +++ b/darwin/util/sysinfo_darwin.mm @@ -1,3 +1,7 @@ +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wold-style-cast" +#endif + #import namespace Darwin_Version diff --git a/rpcs3/display_sleep_control.cpp b/rpcs3/display_sleep_control.cpp index 8e51abb79f6b..683c1dc50f72 100644 --- a/rpcs3/display_sleep_control.cpp +++ b/rpcs3/display_sleep_control.cpp @@ -4,6 +4,10 @@ #include #elif defined(__APPLE__) +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wold-style-cast" +#endif + #include static IOPMAssertionID s_pm_assertion = kIOPMNullAssertionID;