Skip to content

Commit 0316009

Browse files
committed
Support Apple Clang and fix building on macOS Sonoma
1 parent edf4f7e commit 0316009

File tree

4 files changed

+53
-16
lines changed

4 files changed

+53
-16
lines changed

.ci/build-mac.sh

+43-16
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
#!/bin/sh -ex
22

3-
export HOMEBREW_NO_AUTO_UPDATE=1
4-
brew install -f --overwrite nasm ninja git p7zip create-dmg ccache pipenv
5-
6-
#/usr/sbin/softwareupdate --install-rosetta --agree-to-license
7-
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
8-
arch -x86_64 /usr/local/bin/brew update
9-
arch -x86_64 /usr/local/bin/brew install -f --overwrite llvm@16 glew cmake sdl2 vulkan-headers ffmpeg
10-
arch -x86_64 /usr/local/bin/brew link -f llvm@16
11-
12-
# moltenvk based on commit for 1.2.4 release
13-
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/b233d4f9f40f26d81da11140defbfd578cfe4a69/Formula/molten-vk.rb
14-
arch -x86_64 /usr/local/bin/brew install -f --overwrite ./molten-vk.rb
3+
if [ "$(arch -x86_64 echo test)" == "test" ]; then
4+
echo "Rosetta is installed or building on Intel"
5+
else
6+
echo "Installing Rosetta"
7+
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
8+
fi
9+
10+
if [ -z "$INSTALL_DEPS" ]; then
11+
export INSTALL_DEPS="true"
12+
fi
13+
14+
if [ "$INSTALL_DEPS" = "true" ] ; then
15+
export HOMEBREW_NO_AUTO_UPDATE=1
16+
brew -v || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
17+
brew install -f --overwrite nasm ninja git p7zip create-dmg ccache pipenv
18+
19+
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)"
20+
arch -x86_64 /usr/local/bin/brew update
21+
arch -x86_64 /usr/local/bin/brew install -f --overwrite llvm@16 glew cmake sdl2 vulkan-headers ffmpeg
22+
arch -x86_64 /usr/local/bin/brew link -f llvm@16
23+
24+
# moltenvk based on commit for 1.2.4 release
25+
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/b233d4f9f40f26d81da11140defbfd578cfe4a69/Formula/molten-vk.rb
26+
arch -x86_64 /usr/local/bin/brew install -f --overwrite ./molten-vk.rb
27+
fi
28+
1529
#export MACOSX_DEPLOYMENT_TARGET=12.0
1630
export CXX=clang++
1731
export CC=clang
@@ -28,8 +42,13 @@ export WORKDIR;
2842
WORKDIR="$(pwd)"
2943

3044
# Get Qt
45+
if [ -z "$QT_VER" ]; then
46+
export QT_VER="6.5.2"
47+
fi
48+
3149
if [ ! -d "/tmp/Qt/$QT_VER" ]; then
3250
mkdir -p "/tmp/Qt"
51+
rm -rf qt-downloader
3352
git clone https://github.com/engnr/qt-downloader.git
3453
cd qt-downloader
3554
git checkout f52efee0f18668c6d6de2dec0234b8c4bc54c597
@@ -45,27 +64,35 @@ ditto "/tmp/Qt/$QT_VER" "qt-downloader/$QT_VER"
4564
export Qt6_DIR="$WORKDIR/qt-downloader/$QT_VER/clang_64/lib/cmake/Qt$QT_VER_MAIN"
4665
export SDL2_DIR="$BREW_X64_PATH/opt/sdl2/lib/cmake/SDL2"
4766

48-
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"
67+
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"
68+
69+
if [ "$USE_APPLE_CLANG" = "true" ]; then
70+
echo "Building using Apple Clang"
71+
else
72+
echo "Building using Homebrew Clang"
73+
export PATH="$BREW_X64_PATH/opt/llvm@16/bin:$PATH"
74+
fi
75+
4976
export LDFLAGS="-L$BREW_X64_PATH/lib -Wl,-rpath,$BREW_X64_PATH/lib"
5077
export CPPFLAGS="-I$BREW_X64_PATH/include -msse -msse2 -mcx16 -no-pie"
5178
export LIBRARY_PATH="$BREW_X64_PATH/lib"
5279
export LD_LIBRARY_PATH="$BREW_X64_PATH/lib"
5380

5481
export VULKAN_SDK
5582
VULKAN_SDK="$BREW_X64_PATH/opt/molten-vk"
56-
ln -s "$VULKAN_SDK/lib/libMoltenVK.dylib" "$VULKAN_SDK/lib/libvulkan.dylib"
83+
ln -s "$VULKAN_SDK/lib/libMoltenVK.dylib" "$VULKAN_SDK/lib/libvulkan.dylib" || echo "Using existing libvulkan.dylib"
5784
export VK_ICD_FILENAMES="$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json"
5885

5986
export LLVM_DIR
60-
LLVM_DIR="BREW_X64_PATH/opt/llvm@16"
87+
LLVM_DIR="$BREW_X64_PATH/opt/llvm@16"
6188
# exclude FAudio, SPIRV and LLVM, and sdl from submodule update
6289
# shellcheck disable=SC2046
6390
git submodule -q update --init --depth=1 --jobs=8 $(awk '/path/ && !/llvm/ && !/SPIRV/ && !/SDL/ { print $3 }' .gitmodules)
6491

6592
# 3rdparty fixes
6693
sed -i '' "s/extern const double NSAppKitVersionNumber;/const double NSAppKitVersionNumber = 1343;/g" 3rdparty/hidapi/hidapi/mac/hid.c
6794

68-
mkdir build && cd build || exit 1
95+
mkdir -p build && cd build || exit 1
6996

7097
"$BREW_X64_PATH/bin/cmake" .. \
7198
-DUSE_SDL=ON \

.cirrus.yml

+2
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ macos_task:
145145
UPLOAD_COMMIT_HASH: 51ae32f468089a8169aaf1567de355ff4a3e0842
146146
UPLOAD_REPO_FULL_NAME: "rpcs3/rpcs3-binaries-mac"
147147
RELEASE_MESSAGE: "../GitHubReleaseMessage.txt"
148+
INSTALL_DEPS: true
149+
USE_APPLE_CLANG: true
148150
artifacts:
149151
name: Artifact
150152
path: "artifacts/*"

darwin/util/sysinfo_darwin.mm

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#if defined(__clang__)
2+
#pragma clang diagnostic ignored "-Wold-style-cast"
3+
#endif
4+
15
#import <Foundation/Foundation.h>
26

37
namespace Darwin_Version

rpcs3/display_sleep_control.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include <windows.h>
55

66
#elif defined(__APPLE__)
7+
#if defined(__clang__)
8+
#pragma clang diagnostic ignored "-Wold-style-cast"
9+
#endif
10+
711
#include <IOKit/pwr_mgt/IOPMLib.h>
812

913
static IOPMAssertionID s_pm_assertion = kIOPMNullAssertionID;

0 commit comments

Comments
 (0)