diff --git a/.ci/build-mac-arm64.sh b/.ci/build-mac-arm64.sh index 9a23fdee55..65772708b0 100755 --- a/.ci/build-mac-arm64.sh +++ b/.ci/build-mac-arm64.sh @@ -6,14 +6,15 @@ export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 export HOMEBREW_NO_ENV_HINTS=1 export HOMEBREW_NO_INSTALL_CLEANUP=1 -/opt/homebrew/bin/brew install -f --overwrite --quiet nasm ninja p7zip ccache pipenv gnutls freetype googletest #create-dmg -/opt/homebrew/bin/brew install -f --quiet ffmpeg@5 -/opt/homebrew/bin/brew install --quiet "llvm@$LLVM_COMPILER_VER" glew cmake sdl3 vulkan-headers coreutils -/opt/homebrew/bin/brew link -f --quiet "llvm@$LLVM_COMPILER_VER" ffmpeg@5 +brew install -f --overwrite --quiet ccache pipenv googletest ffmpeg@5 "llvm@$LLVM_COMPILER_VER" glew sdl3 vulkan-headers +brew link -f --quiet "llvm@$LLVM_COMPILER_VER" ffmpeg@5 # moltenvk based on commit for 1.3.0 release +export HOMEBREW_DEVELOPER=1 # Prevents blocking of local formulae wget https://raw.githubusercontent.com/Homebrew/homebrew-core/7255441cbcafabaa8950f67c7ec55ff499dbb2d3/Formula/m/molten-vk.rb /opt/homebrew/bin/brew install -f --overwrite --formula --quiet ./molten-vk.rb +export HOMEBREW_DEVELOPER=0 + export CXX=clang++ export CC=clang @@ -32,17 +33,17 @@ if [ ! -d "/tmp/Qt/$QT_VER" ]; then git clone https://github.com/engnr/qt-downloader.git cd qt-downloader git checkout f52efee0f18668c6d6de2dec0234b8c4bc54c597 - # nested Qt 6.9.1 URL workaround + # nested Qt 6.10.0 URL workaround # sed -i '' "s/'qt{0}_{0}{1}{2}'.format(major, minor, patch)]))/'qt{0}_{0}{1}{2}'.format(major, minor, patch), 'qt{0}_{0}{1}{2}'.format(major, minor, patch)]))/g" qt-downloader # sed -i '' "s/'{}\/{}\/qt{}_{}\/'/'{0}\/{1}\/qt{2}_{3}\/qt{2}_{3}\/'/g" qt-downloader # archived Qt 6.7.3 URL workaround sed -i '' "s/official_releases/archive/g" qt-downloader cd "/tmp/Qt" - arch -arm64 "$BREW_PATH/bin/pipenv" run pip3 uninstall py7zr requests semantic_version lxml - arch -arm64 "$BREW_PATH/bin/pipenv" run pip3 install py7zr requests semantic_version lxml --no-cache + "$BREW_PATH/bin/pipenv" run pip3 uninstall py7zr requests semantic_version lxml + "$BREW_PATH/bin/pipenv" run pip3 install py7zr requests semantic_version lxml --no-cache mkdir -p "$QT_VER/macos" ; ln -s "macos" "$QT_VER/clang_64" - # sed -i '' 's/args\.version \/ derive_toolchain_dir(args) \/ //g' "$WORKDIR/qt-downloader/qt-downloader" # Qt 6.9.1 workaround - arch -arm64 "$BREW_PATH/bin/pipenv" run "$WORKDIR/qt-downloader/qt-downloader" macos desktop "$QT_VER" clang_64 --opensource --addons qtmultimedia qtimageformats # -o "$QT_VER/clang_64" + # sed -i '' 's/args\.version \/ derive_toolchain_dir(args) \/ //g' "$WORKDIR/qt-downloader/qt-downloader" # Qt 6.10.0 workaround + "$BREW_PATH/bin/pipenv" run "$WORKDIR/qt-downloader/qt-downloader" macos desktop "$QT_VER" clang_64 --opensource --addons qtmultimedia qtimageformats # -o "$QT_VER/clang_64" fi cd "$WORKDIR" diff --git a/.ci/build-mac.sh b/.ci/build-mac.sh index bf520891ce..aa1151a058 100755 --- a/.ci/build-mac.sh +++ b/.ci/build-mac.sh @@ -6,18 +6,17 @@ export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 export HOMEBREW_NO_ENV_HINTS=1 export HOMEBREW_NO_INSTALL_CLEANUP=1 -#/usr/sbin/softwareupdate --install-rosetta --agree-to-license +brew install -f --overwrite --quiet ccache pipenv "llvm@$LLVM_COMPILER_VER" +brew link -f --overwrite --quiet "llvm@$LLVM_COMPILER_VER" 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 --quiet python || arch -x86_64 /usr/local/bin/brew link --overwrite python -arch -x86_64 /usr/local/bin/brew install -f --overwrite --quiet nasm ninja p7zip ccache pipenv gnutls freetype #create-dmg -arch -x86_64 /usr/local/bin/brew install -f --quiet ffmpeg@5 -arch -x86_64 /usr/local/bin/brew install --quiet "llvm@$LLVM_COMPILER_VER" glew cmake sdl3 vulkan-headers coreutils -arch -x86_64 /usr/local/bin/brew link -f --quiet "llvm@$LLVM_COMPILER_VER" ffmpeg@5 +arch -x86_64 /usr/local/bin/brew install -f --overwrite --quiet ffmpeg@5 "llvm@$LLVM_COMPILER_VER" glew sdl3 vulkan-headers +arch -x86_64 /usr/local/bin/brew link -f --overwrite --quiet "llvm@$LLVM_COMPILER_VER" ffmpeg@5 # moltenvk based on commit for 1.3.0 release +export HOMEBREW_DEVELOPER=1 # Prevents blocking of local formulae wget https://raw.githubusercontent.com/Homebrew/homebrew-core/7255441cbcafabaa8950f67c7ec55ff499dbb2d3/Formula/m/molten-vk.rb arch -x86_64 /usr/local/bin/brew install -f --overwrite --formula --quiet ./molten-vk.rb +export HOMEBREW_DEVELOPER=0 export CXX=clang++ export CC=clang @@ -36,16 +35,16 @@ if [ ! -d "/tmp/Qt/$QT_VER" ]; then git clone https://github.com/engnr/qt-downloader.git cd qt-downloader git checkout f52efee0f18668c6d6de2dec0234b8c4bc54c597 - # nested Qt 6.9.1 URL workaround + # nested Qt 6.10.0 URL workaround # sed -i '' "s/'qt{0}_{0}{1}{2}'.format(major, minor, patch)]))/'qt{0}_{0}{1}{2}'.format(major, minor, patch), 'qt{0}_{0}{1}{2}'.format(major, minor, patch)]))/g" qt-downloader # sed -i '' "s/'{}\/{}\/qt{}_{}\/'/'{0}\/{1}\/qt{2}_{3}\/qt{2}_{3}\/'/g" qt-downloader # archived Qt 6.7.3 URL workaround sed -i '' "s/official_releases/archive/g" qt-downloader cd "/tmp/Qt" - arch -x86_64 "$BREW_X64_PATH/bin/pipenv" --python "$BREW_X64_PATH/bin/python3" run pip3 install py7zr requests semantic_version lxml + "/opt/homebrew/bin/pipenv" --python "/opt/homebrew/bin/python3" run pip3 install py7zr requests semantic_version lxml mkdir -p "$QT_VER/macos" ; ln -s "macos" "$QT_VER/clang_64" - # sed -i '' 's/args\.version \/ derive_toolchain_dir(args) \/ //g' "$WORKDIR/qt-downloader/qt-downloader" # Qt 6.9.1 workaround - arch -x86_64 "$BREW_X64_PATH/bin/pipenv" --python "$BREW_X64_PATH/bin/python3" run "$WORKDIR/qt-downloader/qt-downloader" macos desktop "$QT_VER" clang_64 --opensource --addons qtmultimedia qtimageformats # -o "$QT_VER/clang_64" + # sed -i '' 's/args\.version \/ derive_toolchain_dir(args) \/ //g' "$WORKDIR/qt-downloader/qt-downloader" # Qt 6.10.0 workaround + "/opt/homebrew/bin/pipenv" --python "/opt/homebrew/bin/python3" run "$WORKDIR/qt-downloader/qt-downloader" macos desktop "$QT_VER" clang_64 --opensource --addons qtmultimedia qtimageformats # -o "$QT_VER/clang_64" fi cd "$WORKDIR" @@ -54,12 +53,12 @@ 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 SDL3_DIR="$BREW_X64_PATH/opt/sdl3/lib/cmake/SDL3" -export PATH="$BREW_X64_PATH/opt/llvm@$LLVM_COMPILER_VER/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="/opt/homebrew/opt/llvm@$LLVM_COMPILER_VER/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 LDFLAGS="-L$BREW_X64_PATH/lib -Wl,-rpath,$BREW_X64_PATH/lib" export CPPFLAGS="-I$BREW_X64_PATH/include -msse -msse2 -mcx16 -no-pie -D__MAC_OS_X_VERSION_MIN_REQUIRED=140000" export CFLAGS="-D__MAC_OS_X_VERSION_MIN_REQUIRED=140000" -export LIBRARY_PATH="$BREW_X64_PATH/lib" -export LD_LIBRARY_PATH="$BREW_X64_PATH/lib" +export LIBRARY_PATH="$BREW_X64_PATH/opt/llvm@$LLVM_COMPILER_VER/lib:$BREW_X64_PATH/lib" +export LD_LIBRARY_PATH="$BREW_X64_PATH/opt/llvm@$LLVM_COMPILER_VER/lib:$BREW_X64_PATH/lib" export VULKAN_SDK VULKAN_SDK="$BREW_X64_PATH/opt/molten-vk" @@ -67,7 +66,7 @@ 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" export LLVM_DIR -LLVM_DIR="BREW_X64_PATH/opt/llvm@$LLVM_COMPILER_VER" +LLVM_DIR="$BREW_X64_PATH/opt/llvm@$LLVM_COMPILER_VER" # exclude ffmpeg, LLVM, opencv, and sdl from submodule update # shellcheck disable=SC2046 git submodule -q update --init --depth=1 --jobs=8 $(awk '/path/ && !/ffmpeg/ && !/llvm/ && !/opencv/ && !/SDL/ && !/feralinteractive/ { print $3 }' .gitmodules) @@ -79,7 +78,7 @@ mkdir build && cd build || exit 1 export MACOSX_DEPLOYMENT_TARGET=14.0 -"$BREW_X64_PATH/bin/cmake" .. \ +"/opt/homebrew/bin/cmake" .. \ -DBUILD_RPCS3_TESTS=OFF \ -DRUN_RPCS3_TESTS=OFF \ -DUSE_SDL=ON \ @@ -107,6 +106,8 @@ export MACOSX_DEPLOYMENT_TARGET=14.0 "$CMAKE_EXTRA_OPTS" \ -DLLVM_TARGET_ARCH=X86_64 \ -DCMAKE_OSX_ARCHITECTURES=x86_64 \ + -DCMAKE_SYSTEM_PROCESSOR=x86_64 \ + -DCMAKE_TOOLCHAIN_FILE=buildfiles/cmake/TCDarwinX86_64.cmake \ -DCMAKE_IGNORE_PATH="$BREW_X64_PATH/lib" \ -DCMAKE_IGNORE_PREFIX_PATH=/usr/local/opt \ -DCMAKE_CXX_FLAGS="-D__MAC_OS_X_VERSION_MIN_REQUIRED=140000" \ @@ -114,7 +115,7 @@ export MACOSX_DEPLOYMENT_TARGET=14.0 -DCMAKE_OSX_SYSROOT="$(xcrun --sdk macosx --show-sdk-path)" \ -G Ninja -"$BREW_X64_PATH/bin/ninja"; build_status=$?; +"/opt/homebrew/bin/ninja"; build_status=$?; cd .. diff --git a/.ci/build-windows-clang-cl.ps1 b/.ci/build-windows-clang-cl.ps1 new file mode 100644 index 0000000000..367f2feaed --- /dev/null +++ b/.ci/build-windows-clang-cl.ps1 @@ -0,0 +1,143 @@ +# .ci/build-windows-clang-cl.ps1 +# Enable strict error handling +$ErrorActionPreference = "Stop" + +trap { + Write-Host "ERROR: $($_.Exception.Message)" + exit 1 +} + +Write-Host "Starting RPCS3 build (PowerShell script)" + +# Automatically find clang_rt.builtins-x86_64.lib +Write-Host "Searching for clang_rt.builtins-x86_64.lib ..." +$clangBuiltinsLibPath = Get-ChildItem -Path "C:/Program Files/LLVM/lib/clang" -Recurse -Filter "clang_rt.builtins-x86_64.lib" -ErrorAction SilentlyContinue | + Where-Object { $_.FullName -match "windows\\clang_rt\.builtins-x86_64\.lib$" } | + Select-Object -First 1 + +if (-not $clangBuiltinsLibPath) { + Write-Error "Could not find clang_rt.builtins-x86_64.lib in LLVM installation." + exit 1 +} + +function Get-ShortPath([string]$path) { + $fso = New-Object -ComObject Scripting.FileSystemObject + return $fso.GetFolder($path).ShortPath +} + +$clangBuiltinsDir = Split-Path -Parent $clangBuiltinsLibPath.FullName +$clangBuiltinsDirShort = Get-ShortPath $clangBuiltinsDir +$clangBuiltinsLib = Split-Path -Leaf $clangBuiltinsLibPath.FullName +$clangPath = "C:\Program Files\LLVM\bin" +#$clangPath = Get-ChildItem -Path "D:\a\rpcs3\rpcs3\llvm-*\bin" +#$llvmPath = Get-ChildItem -Path "D:\a\rpcs3\rpcs3\llvm-*\lib\cmake\llvm" + +Write-Host "Found Clang builtins library: $clangBuiltinsLib in $clangBuiltinsDir or short $clangBuiltinsDirShort" +Write-Host "Found Clang Path: $clangPath" + +# Get Windows Kits root from registry +$kitsRoot = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -Name "KitsRoot10" +$kitsRootPath = $kitsRoot.KitsRoot10 + +# Search for mt.exe in x64 SDK bin directories +Write-Host "Searching for mt.exe ..." +$mtPath = Get-ChildItem -Path "$clangPath" -Recurse -Filter "llvm-mt.exe" -ErrorAction SilentlyContinue | + Where-Object { $_.FullName -match "\\llvm-mt\.exe$" } | + Sort-Object FullName -Descending | + Select-Object -First 1 + +if (-not $mtPath) { + Write-Error "Could not find mt.exe in Windows Kits directories." + exit 1 +} + +$mtExePath = "$mtPath" + +Write-Host "Found mt.exe at: $mtExePath" + +$VcpkgRoot="$(Get-Location)/vcpkg" +$VcpkgTriplet=$env:VCPKG_TRIPLET +$VcpkgInstall="$VcpkgRoot/installed/$VcpkgTriplet" +$VcpkgInclude="$VcpkgInstall/include" +$VcpkgLib="$VcpkgInstall/lib" +$VcpkgBin="$VcpkgInstall/bin" + +# Configure git safe directory +Write-Host "Configuring git safe directory" +& git config --global --add safe.directory '*' + +# Initialize submodules except certain ones +Write-Host "Initializing submodules" +$excludedSubs = @('llvm','opencv','ffmpeg','FAudio','zlib','libpng','feralinteractive') + +# Get submodule paths excluding those in $excludedSubs +$submodules = Select-String -Path .gitmodules -Pattern 'path = (.+)' | ForEach-Object { + $_.Matches[0].Groups[1].Value +} | Where-Object { + $path = $_ + -not ($excludedSubs | Where-Object { $path -like "*$_*" }) +} + +Write-Host "Updating submodules: $($submodules -join ', ')" +& git submodule update --init --quiet $submodules +& git -C 3rdparty/OpenAL/openal-soft reset --hard master + +# Create and enter build directory +Write-Host "Creating build directory" +if (!(Test-Path build)) { + New-Item -ItemType Directory -Path build | Out-Null +} +Set-Location build +Write-Host "Changed directory to: $(Get-Location)" + +# Run CMake with Ninja generator and required flags +Write-Host "Running CMake configuration" +& cmake .. ` + -G Ninja ` + -DCMAKE_BUILD_TYPE=Release ` + -DCMAKE_C_COMPILER="$clangPath/clang-cl.exe" ` + -DCMAKE_CXX_COMPILER="$clangPath/clang-cl.exe" ` + -DCMAKE_LINKER="$clangPath/lld-link.exe" ` + -DCMAKE_INSTALL_PREFIX=/usr ` + -DCMAKE_TOOLCHAIN_FILE="$VcpkgRoot/scripts/buildsystems/vcpkg.cmake" ` + -DCMAKE_EXE_LINKER_FLAGS="/LIBPATH:$clangBuiltinsDirShort /defaultlib:$clangBuiltinsLib" ` + -DCMAKE_MT="$clangPath/llvm-mt.exe" ` + -DUSE_NATIVE_INSTRUCTIONS=OFF ` + -DUSE_PRECOMPILED_HEADERS=OFF ` + -DVCPKG_TARGET_TRIPLET="$VcpkgTriplet" ` + -DFFMPEG_INCLUDE_DIR="$VcpkgInclude" ` + -DFFMPEG_LIBAVCODEC="$VcpkgLib/avcodec.lib" ` + -DFFMPEG_LIBAVFORMAT="$VcpkgLib/avformat.lib" ` + -DFFMPEG_LIBAVUTIL="$VcpkgLib/avutil.lib" ` + -DFFMPEG_LIBSWSCALE="$VcpkgLib/swscale.lib" ` + -DFFMPEG_LIBSWRESAMPLE="$VcpkgLib/swresample.lib" ` + -DUSE_SYSTEM_CURL=OFF ` + -DUSE_FAUDIO=OFF ` + -DUSE_SDL=ON ` + -DUSE_SYSTEM_SDL=OFF ` + -DUSE_SYSTEM_FFMPEG=ON ` + -DUSE_SYSTEM_OPENCV=ON ` + -DUSE_SYSTEM_OPENAL=OFF ` + -DUSE_SYSTEM_LIBPNG=ON ` + -DUSE_DISCORD_RPC=ON ` + -DUSE_SYSTEM_ZSTD=ON ` + -DWITH_LLVM=ON ` + -DSTATIC_LINK_LLVM=ON ` + -DBUILD_RPCS3_TESTS=OFF + +Write-Host "CMake configuration complete" + +# Build with ninja +Write-Host "Starting build with Ninja..." +& ninja +if ($LASTEXITCODE -ne 0) { + Write-Host "Build failed with exit code $LASTEXITCODE" + exit 1 +} + +Write-Host "Build succeeded" + +# Go back to root directory +Set-Location .. +Write-Host "Returned to root directory: $(Get-Location)" + diff --git a/.ci/build-windows-clang.sh b/.ci/build-windows-clang.sh index 0880e7f5ed..75054cc66b 100644 --- a/.ci/build-windows-clang.sh +++ b/.ci/build-windows-clang.sh @@ -6,6 +6,7 @@ git config --global --add safe.directory '*' # Note: Tried to use git submodule status, but it takes over 20 seconds # shellcheck disable=SC2046 git submodule -q update --init $(awk '/path/ && !/llvm/ && !/opencv/ && !/ffmpeg/ && !/curl/ && !/FAudio/ && !/zlib/ { print $3 }' .gitmodules) +git -C 3rdparty/OpenAL/openal-soft reset --hard master mkdir build && cd build || exit 1 @@ -57,5 +58,5 @@ cd .. # If it compiled succesfully let's deploy. if [ "$build_status" -eq 0 ]; then - .ci/deploy-windows-clang.sh "x86_64" + echo "Build succeeded" fi diff --git a/.ci/deploy-windows-clang-cl.sh b/.ci/deploy-windows-clang-cl.sh new file mode 100644 index 0000000000..08bc60a66f --- /dev/null +++ b/.ci/deploy-windows-clang-cl.sh @@ -0,0 +1,42 @@ +#!/bin/sh -ex + +# source ci-vars.env +# shellcheck disable=SC1091 +. .ci/ci-vars.env + +cd build || exit 1 + +CPU_ARCH="${1:-x86_64}" + +echo "Deploying rpcs3 windows clang-cl $CPU_ARCH" + +# First let's print some info about our caches +C:/Strawberry/c/bin/ccache.exe --show-stats -v + +# BUILD_blablabla is CI specific, so we wrap it for portability +ARTIFACT_DIR="$BUILD_ARTIFACTSTAGINGDIRECTORY" + +# Remove unecessary files +rm -f ./bin/vulkan-1.dll + +# Prepare compatibility and SDL database for packaging +mkdir ./bin/config +mkdir ./bin/config/input_configs +curl -fsSL 'https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt' 1> ./bin/config/input_configs/gamecontrollerdb.txt +curl -fsSL 'https://rpcs3.net/compatibility?api=v1&export' | iconv -t UTF-8 1> ./bin/GuiConfigs/compat_database.dat + +# Download SSL certificate (not needed with CURLSSLOPT_NATIVE_CA) +#curl -fsSL 'https://curl.haxx.se/ca/cacert.pem' 1> ./bin/cacert.pem + +# Package artifacts +7z a -m0=LZMA2 -mx9 "$BUILD" ./bin/* + +# Generate sha256 hashes +# Write to file for GitHub releases +sha256sum "$BUILD" | awk '{ print $1 }' | tee "$BUILD.sha256" +echo "$(cat "$BUILD.sha256");$(stat -c %s "$BUILD")B" > GitHubReleaseMessage.txt + +# Move files to publishing directory +mkdir "$ARTIFACT_DIR" +cp -- "$BUILD" "$ARTIFACT_DIR" +cp -- "$BUILD.sha256" "$ARTIFACT_DIR" diff --git a/.github/workflows/rpcs3.yml b/.github/workflows/rpcs3.yml index 1981f78edb..6457334be8 100644 --- a/.github/workflows/rpcs3.yml +++ b/.github/workflows/rpcs3.yml @@ -5,8 +5,8 @@ defaults: shell: bash on: push: - branches: - - master # Only trigger push event on 'master' branch + #branches: + # - master # Only trigger push event on 'master' branch pull_request: workflow_dispatch: @@ -24,7 +24,7 @@ env: jobs: Linux_Build: # Only run push event on master branch of main repo, but run all PRs - if: github.event_name != 'push' || (github.repository == 'RPCS3/rpcs3' && github.ref_name == 'master') + #if: github.event_name != 'push' || (github.repository == 'RPCS3/rpcs3' && github.ref_name == 'master') strategy: fail-fast: false matrix: @@ -117,13 +117,13 @@ jobs: Mac_Build: # Only run push event on master branch of main repo, but run all PRs - if: github.event_name != 'push' || (github.repository == 'RPCS3/rpcs3' && github.ref_name == 'master') + #if: github.event_name != 'push' || (github.repository == 'RPCS3/rpcs3' && github.ref_name == 'master') strategy: fail-fast: false matrix: include: - name: Intel - build_sh: "arch -X86_64 .ci/build-mac.sh" + build_sh: .ci/build-mac.sh UPLOAD_COMMIT_HASH: 51ae32f468089a8169aaf1567de355ff4a3e0842 UPLOAD_REPO_FULL_NAME: rpcs3/rpcs3-binaries-mac - name: Apple Silicon @@ -191,14 +191,14 @@ jobs: run: .ci/github-upload.sh - name: Save Build Ccache - if: github.ref == 'refs/heads/master' + #if: github.ref == 'refs/heads/master' uses: actions/cache/save@main with: path: ${{ env.CCACHE_DIR }} key: ${{ steps.restore-build-ccache.outputs.cache-primary-key }} - name: Save Qt Cache - if: github.ref == 'refs/heads/master' + #if: github.ref == 'refs/heads/master' uses: actions/cache/save@main with: path: /tmp/Qt @@ -206,15 +206,15 @@ jobs: Windows_Build: # Only run push event on master branch of main repo, but run all PRs - if: github.event_name != 'push' || (github.repository == 'RPCS3/rpcs3' && github.ref_name == 'master') + #if: github.event_name != 'push' || (github.repository == 'RPCS3/rpcs3' && github.ref_name == 'master') name: RPCS3 Windows runs-on: windows-2025 env: COMPILER: msvc QT_VER_MAIN: '6' - QT_VER: '6.9.1' + QT_VER: '6.9.3' QT_VER_MSVC: 'msvc2022' - QT_DATE: '202505291653' + QT_DATE: '202509261208' LLVM_VER: '19.1.7' VULKAN_VER: '1.3.268.0' VULKAN_SDK_SHA: '8459ef49bd06b697115ddd3d97c9aec729e849cd775f5be70897718a9b3b9db5' @@ -312,14 +312,14 @@ jobs: run: .ci/github-upload.sh - name: Save Build Ccache - if: github.ref == 'refs/heads/master' + #if: github.ref == 'refs/heads/master' uses: actions/cache/save@main with: path: ${{ env.CCACHE_DIR }} key: ${{ steps.restore-build-ccache.outputs.cache-primary-key }} - name: Save Dependencies Cache - if: github.ref == 'refs/heads/master' + #if: github.ref == 'refs/heads/master' uses: actions/cache/save@main with: path: ${{ env.DEPS_CACHE_DIR }} @@ -327,25 +327,33 @@ jobs: Windows_Build_Clang: # Only run push event on master branch of main repo, but run all PRs - if: github.event_name != 'push' || (github.repository == 'RPCS3/rpcs3' && github.ref_name == 'master') - name: RPCS3 Windows Clang + #if: github.event_name != 'push' || (github.repository == 'RPCS3/rpcs3' && github.ref_name == 'master') runs-on: windows-2025 strategy: + fail-fast: false matrix: include: - msys2: clang64 compiler: clang arch: win64 + - compiler: clang-cl + llvmver: 20.1.8 + arch: win64 + env: CCACHE_DIR: 'C:\ccache' + VCPKG_TRIPLET: x64-windows + VCPKG_BUILD_TYPE: release + name: RPCS3 Windows ${{ matrix.compiler }} steps: - name: Checkout repository uses: actions/checkout@main with: fetch-depth: 0 - + - name: Setup msys2 uses: msys2/setup-msys2@v2 + if: ${{ matrix.compiler == 'clang' }} with: msystem: ${{ matrix.msys2 }} update: true @@ -373,6 +381,89 @@ jobs: git p7zip + - name: Clone and bootstrap vcpkg + if: ${{ matrix.compiler == 'clang-cl' }} + shell: pwsh + run: | + git clone https://github.com/microsoft/vcpkg.git + .\vcpkg\bootstrap-vcpkg.bat + + - name: Restore vcpkg cache + if: ${{ matrix.compiler == 'clang-cl' }} + uses: actions/cache/restore@main + id: restore-vcpkg-cache + with: + path: | + vcpkg/vcpkg.exe + vcpkg/installed + vcpkg/buildtrees + key: vcpkg-${{ runner.os }}-${{ matrix.compiler }}-${{ runner.arch }}-${{ hashFiles('**/vcpkg') }} + restore-keys: vcpkg-${{ runner.os }}-${{ matrix.compiler }}-${{ runner.arch }}- + + - name: Install dependencies with vcpkg + if: ${{ matrix.compiler == 'clang-cl' }} + shell: pwsh + run: >- + .\vcpkg\vcpkg.exe install + ffmpeg[avcodec,avformat,swscale,swresample] + libpng + opencv + qtbase + qtmultimedia + qtsvg + qttools + vulkan + zlib + --triplet $env:VCPKG_TRIPLET + --clean-after-build + + - name: Save vcpkg cache + if: ${{ matrix.compiler == 'clang-cl' }} + #if: ${{ !steps.restore-vcpkg-cache.outputs.cache-hit && matrix.compiler == 'clang-cl' }} + #if: github.ref == 'refs/heads/master' + uses: actions/cache/save@main + with: + path: | + vcpkg/vcpkg.exe + vcpkg/installed + vcpkg/buildtrees + key: ${{ steps.restore-vcpkg-cache.outputs.cache-primary-key }} + + - name: Restore LLVM Cache + if: ${{ matrix.compiler == 'clang-cl' }} + uses: actions/cache/restore@main + id: llvm-cache + with: + path: ./llvm-${{ matrix.llvmver }} + key: ${{ runner.os }}-llvm-dl-cache-${{ hashFiles('**/llvm-${{ matrix.llvmver }}') }} + restore-keys: ${{ runner.os }}-clang-dl-cache- + + - name: Add LLVM + if: ${{ matrix.compiler == 'clang-cl' }} + shell: pwsh + run: | + if (!(Test-Path -Path D:\a\rpcs3\rpcs3\llvm-${{ matrix.llvmver }}\)) { + rm -r llvm-* + curl -fsSLO https://github.com/vovkos/llvm-package-windows/releases/download/llvm-20.1.8/llvm-20.1.8-windows-amd64-msvc17-msvcrt.7z + curl -fsSLO https://github.com/vovkos/llvm-package-windows/releases/download/clang-20.1.8/clang-20.1.8-windows-amd64-msvc17-msvcrt.7z + 7z x llvm-*.7z + mv llvm* llvm-${{ matrix.llvmver }} + rm llvm-*.7z + 7z x clang-*.7z + Copy-Item -Path "D:\a\rpcs3\rpcs3\clang*\*" -Destination "D:\a\rpcs3\rpcs3\llvm-${{ matrix.llvmver }}" -Recurse -Force + rm -r clang* + } + Add-Content -Path $env:GITHUB_PATH -Value "D:\a\rpcs3\rpcs3\llvm-${{ matrix.llvmver }}\bin" + C:\PROGRA~1\LLVM\bin\clang-cl.exe --version + + - name: Save LLVM Cache + if: ${{ matrix.compiler == 'clang-cl' && steps.llvm-cache.outputs.cache-hit != 'true' }} + #if: github.ref == 'refs/heads/master' + uses: actions/cache/save@main + with: + path: ./llvm-${{ matrix.llvmver }} + key: ${{ steps.llvm-cache.outputs.cache-primary-key }} + - name: Restore build Ccache uses: actions/cache/restore@main id: restore-build-ccache @@ -382,20 +473,39 @@ jobs: restore-keys: ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ runner.arch }}- - name: Build RPCS3 + if: ${{ matrix.compiler == 'clang' }} shell: msys2 {0} run: | export CCACHE_DIR=$(cygpath -u "$CCACHE_DIR") echo "CCACHE_DIR=$CCACHE_DIR" - .ci/setup-windows-ci-vars.sh ${{ matrix.arch }} ${{ matrix.compiler }} .ci/build-windows-clang.sh + + - name: install DIA SDK + if: ${{ matrix.compiler == 'clang-cl' }} + run: | + mkdir -p "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional" || true + cp -r "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/DIA SDK" "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/DIA SDK" + + - name: Build RPCS3 + if: ${{ matrix.compiler == 'clang-cl' }} + shell: cmd + run: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 + powershell -ExecutionPolicy Bypass -File .ci/build-windows-clang-cl.ps1 - name: Save build Ccache - if: github.ref == 'refs/heads/master' + #if: github.ref == 'refs/heads/master' uses: actions/cache/save@main with: path: ${{ env.CCACHE_DIR }} key: ${{ steps.restore-build-ccache.outputs.cache-primary-key }} + - name: Prepare Artifacts + shell: bash + run: | + .ci/setup-windows-ci-vars.sh ${{ matrix.arch }} ${{ matrix.compiler }} + .ci/deploy-windows-${{ matrix.compiler }}.sh + - name: Upload artifacts uses: actions/upload-artifact@main with: @@ -406,7 +516,7 @@ jobs: FreeBSD_Build: # Only run push event on master branch of main repo, but run all PRs - if: github.event_name != 'push' || (github.repository == 'RPCS3/rpcs3' && github.ref_name == 'master') + #if: github.event_name != 'push' || (github.repository == 'RPCS3/rpcs3' && github.ref_name == 'master') name: RPCS3 FreeBSD runs-on: ubuntu-latest timeout-minutes: 60 @@ -437,7 +547,7 @@ jobs: run: .ci/install-freebsd.sh && .ci/build-freebsd.sh - name: Save Build Ccache - if: github.ref == 'refs/heads/master' + #if: github.ref == 'refs/heads/master' uses: actions/cache/save@main with: path: ${{ env.CCACHE_DIR }} diff --git a/3rdparty/OpenAL/CMakeLists.txt b/3rdparty/OpenAL/CMakeLists.txt index b9fee23ce5..ce3d05bf7e 100644 --- a/3rdparty/OpenAL/CMakeLists.txt +++ b/3rdparty/OpenAL/CMakeLists.txt @@ -11,6 +11,7 @@ if(USE_SYSTEM_OPENAL) else() option(ALSOFT_UTILS "Build utility programs" OFF) option(ALSOFT_EXAMPLES "Build example programs" OFF) + option(ALSOFT_ENABLE_MODULES "Enable use of C++20 modules when supported" OFF) set(LIBTYPE "STATIC") add_subdirectory(openal-soft EXCLUDE_FROM_ALL) add_library(3rdparty_openal INTERFACE) diff --git a/3rdparty/OpenAL/openal-soft.vcxproj b/3rdparty/OpenAL/openal-soft.vcxproj index d309093527..b0614f89e3 100644 --- a/3rdparty/OpenAL/openal-soft.vcxproj +++ b/3rdparty/OpenAL/openal-soft.vcxproj @@ -49,11 +49,11 @@ call vsdevcmd.bat -arch=amd64 cd "$(SolutionDir)build\tmp\$(ProjectName)-$(Configuration)-$(Platform)" - cmake -G Ninja -DCMAKE_CXX_COMPILER="cl.exe" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="./Release" -DCMAKE_SYSTEM_VERSION=10.0 -DLIBTYPE=STATIC -DFORCE_STATIC_VCRT=true -DALSOFT_UTILS=false -DALSOFT_EXAMPLES=false -DALSOFT_INSTALL=false -DALSOFT_INSTALL_CONFIG=false -DALSOFT_INSTALL_HRTF_DATA=false -DALSOFT_INSTALL_AMBDEC_PRESETS=false -DALSOFT_INSTALL_EXAMPLES=false -DALSOFT_INSTALL_UTILS=false "$(SolutionDir)3rdparty\OpenAL\openal-soft" + cmake -G Ninja -DCMAKE_CXX_COMPILER="cl.exe" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_INSTALL_PREFIX="./Release" -DCMAKE_SYSTEM_VERSION=10.0 -DLIBTYPE=STATIC -DFORCE_STATIC_VCRT=true -DALSOFT_UTILS=false -DALSOFT_EXAMPLES=false -DALSOFT_INSTALL=false -DALSOFT_INSTALL_CONFIG=false -DALSOFT_INSTALL_HRTF_DATA=false -DALSOFT_INSTALL_AMBDEC_PRESETS=false -DALSOFT_INSTALL_EXAMPLES=false -DALSOFT_INSTALL_UTILS=false "$(SolutionDir)3rdparty\OpenAL\openal-soft" call vsdevcmd.bat -arch=amd64 cd "$(SolutionDir)build\tmp\$(ProjectName)-$(Configuration)-$(Platform)" - cmake -G Ninja -DCMAKE_CXX_COMPILER="cl.exe" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_INSTALL_PREFIX="./Debug" -DCMAKE_SYSTEM_VERSION=10.0 -DLIBTYPE=STATIC -DALSOFT_UTILS=false -DALSOFT_EXAMPLES=false -DALSOFT_INSTALL=false -DALSOFT_INSTALL_CONFIG=false -DALSOFT_INSTALL_HRTF_DATA=false -DALSOFT_INSTALL_AMBDEC_PRESETS=false -DALSOFT_INSTALL_EXAMPLES=false -DALSOFT_INSTALL_UTILS=false "$(SolutionDir)3rdparty\OpenAL\openal-soft" + cmake -G Ninja -DCMAKE_CXX_COMPILER="cl.exe" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug -DCMAKE_INSTALL_PREFIX="./Debug" -DCMAKE_SYSTEM_VERSION=10.0 -DLIBTYPE=STATIC -DALSOFT_UTILS=false -DALSOFT_EXAMPLES=false -DALSOFT_INSTALL=false -DALSOFT_INSTALL_CONFIG=false -DALSOFT_INSTALL_HRTF_DATA=false -DALSOFT_INSTALL_AMBDEC_PRESETS=false -DALSOFT_INSTALL_EXAMPLES=false -DALSOFT_INSTALL_UTILS=false "$(SolutionDir)3rdparty\OpenAL\openal-soft" echo Copying.. @@ -106,4 +106,4 @@ - \ No newline at end of file + diff --git a/3rdparty/llvm/llvm_build_clang_cl.vcxproj b/3rdparty/llvm/llvm_build_clang_cl.vcxproj index c0ccb204c6..4495806eb7 100644 --- a/3rdparty/llvm/llvm_build_clang_cl.vcxproj +++ b/3rdparty/llvm/llvm_build_clang_cl.vcxproj @@ -106,4 +106,4 @@ - \ No newline at end of file + diff --git a/3rdparty/wolfssl/CMakeLists.txt b/3rdparty/wolfssl/CMakeLists.txt index cf1a66a1f5..0b3f00872c 100644 --- a/3rdparty/wolfssl/CMakeLists.txt +++ b/3rdparty/wolfssl/CMakeLists.txt @@ -22,5 +22,17 @@ else() add_subdirectory(wolfssl EXCLUDE_FROM_ALL) - target_compile_definitions(wolfssl PUBLIC WOLFSSL_DES_ECB HAVE_WRITE_DUP FP_MAX_BITS=8192 WOLFSSL_NO_OPTIONS_H) -endif() + target_compile_definitions(wolfssl PUBLIC WOLFSSL_DES_ECB HAVE_WRITE_DUP WOLFSSL_NO_OPTIONS_H) + + if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # Disable 128-bit Math + set(WOLFSSL_ASM ON CACHE BOOL "" FORCE) + set(WOLFSSL_FAST_MATH OFF CACHE BOOL "" FORCE) + target_compile_definitions(wolfssl PUBLIC WOLFSSL_SP_NO_128BIT FP_MAX_BITS=4096) + + # Disable warnings + target_compile_options(wolfssl PRIVATE /w) + else() + target_compile_definitions(wolfssl PUBLIC FP_MAX_BITS=8192) + endif() + endif() diff --git a/3rdparty/zstd/CMakeLists.txt b/3rdparty/zstd/CMakeLists.txt index 5a8b6f3d90..5bf68692c3 100644 --- a/3rdparty/zstd/CMakeLists.txt +++ b/3rdparty/zstd/CMakeLists.txt @@ -1,8 +1,17 @@ -option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" OFF) -option(ZSTD_BUILD_SHARED "BUILD SHARED LIBRARIES" OFF) -option(ZSTD_BUILD_STATIC "BUILD STATIC LIBRARIES" ON) -option(ZSTD_BUILD_TESTS "BUILD TESTS" OFF) - -add_subdirectory(zstd/build/cmake EXLUDE_FROM_ALL) -add_library(3rdparty_zstd INTERFACE) -target_link_libraries(3rdparty_zstd INTERFACE libzstd_static) +# zstd +# Select the version of zstd to use, default is builtin +if(NOT USE_SYSTEM_ZSTD) + option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" OFF) + option(ZSTD_BUILD_SHARED "BUILD SHARED LIBRARIES" OFF) + option(ZSTD_BUILD_STATIC "BUILD STATIC LIBRARIES" ON) + option(ZSTD_BUILD_TESTS "BUILD TESTS" OFF) + + add_subdirectory(zstd/build/cmake EXLUDE_FROM_ALL) + add_library(3rdparty_zstd INTERFACE) + target_link_libraries(3rdparty_zstd INTERFACE libzstd_static) +else() + message(STATUS "RPCS3: using VCPKG zstd") + find_package(zstd CONFIG REQUIRED) + add_library(3rdparty_zstd INTERFACE) + target_link_libraries(3rdparty_zstd INTERFACE zstd::libzstd) +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 81b2a84ee6..cb3ea2e435 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ option(USE_SYSTEM_PUGIXML "Prefer system pugixml instead of the builtin one" OFF option(USE_SYSTEM_SDL "Prefer system SDL instead of the builtin one" ON) option(USE_SYSTEM_WOLFSSL "Prefer system MoltenVK instead of the builtin one" OFF) option(USE_SYSTEM_ZLIB "Prefer system ZLIB instead of the builtin one" ON) +option(USE_SYSTEM_ZSTD "Prefer system zstd instead of the prebuild one" OFF) option(HAS_MEMORY_BREAKPOINTS "Add support for memory breakpoints to the interpreter" OFF) option(USE_LTO "Use LTO for building" ON) option(BUILD_RPCS3_TESTS "Build RPCS3 unit tests." OFF) @@ -116,7 +117,9 @@ if(MSVC) message(AUTHOR_WARNING "Debug build currently can not work with static CRT.") endif() endif() - add_compile_options(/MP) + if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options(/MP) + endif() endif() if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8) diff --git a/Utilities/JITLLVM.cpp b/Utilities/JITLLVM.cpp index 2b82d57d54..8f08e5c2d7 100644 --- a/Utilities/JITLLVM.cpp +++ b/Utilities/JITLLVM.cpp @@ -658,7 +658,11 @@ jit_compiler::jit_compiler(const std::unordered_map& _link, co std::string result; auto null_mod = std::make_unique ("null_", *m_context); +#if LLVM_VERSION_MAJOR > 20 + null_mod->setTargetTriple(llvm::Triple(jit_compiler::triple1())); +#else null_mod->setTargetTriple(jit_compiler::triple1()); +#endif std::unique_ptr mem; @@ -672,7 +676,11 @@ jit_compiler::jit_compiler(const std::unordered_map& _link, co else { mem = std::make_unique(std::move(symbols_cement)); +#if LLVM_VERSION_MAJOR > 20 + null_mod->setTargetTriple(llvm::Triple(jit_compiler::triple2())); +#else null_mod->setTargetTriple(jit_compiler::triple2()); +#endif } } else diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index c628a90a8a..189773731e 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -525,7 +525,7 @@ void fmt_class_string::format(std::string& out, u64 arg) return; } -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) fmt::append(out, "0x%016llx%016llx", num.hi, num.lo); #else fmt::append(out, "0x%016llx%016llx", static_cast(num >> 64), static_cast(num)); diff --git a/buildfiles/cmake/ConfigureCompiler.cmake b/buildfiles/cmake/ConfigureCompiler.cmake index d59d987b9c..5fa1c589a1 100644 --- a/buildfiles/cmake/ConfigureCompiler.cmake +++ b/buildfiles/cmake/ConfigureCompiler.cmake @@ -1,11 +1,24 @@ # Check and configure compiler options for RPCS3 if(MSVC) - add_compile_options(/Zc:throwingNew- /constexpr:steps16777216) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + check_cxx_compiler_flag("-msse -msse2 -mcx16" COMPILER_X86) + check_cxx_compiler_flag("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE) + if (COMPILER_X86) + #add_compile_options(-msse -msse2 -mcx16 -mavx512f -mavx512vbmi -mavx512vl -mavx512dq -mavx512vpopcntdq -mavx -mavx2 -maes -mrtm -mpclmul -mmwaitx -mwaitpkg) + add_compile_options(-maes -mrtm -mpclmul -mmwaitx -mwaitpkg) + endif() + if(COMPILER_SUPPORTS_MARCH_NATIVE) + add_compile_options(-march=native) + endif() + add_link_options(/dynamicbase) + else() + add_compile_options(/Zc:throwingNew- /constexpr:steps16777216) + add_link_options(/DYNAMICBASE) + endif() add_compile_definitions( _CRT_SECURE_NO_DEPRECATE=1 _CRT_NON_CONFORMING_SWPRINTFS=1 _SCL_SECURE_NO_WARNINGS=1 NOMINMAX _ENABLE_EXTENDED_ALIGNED_STORAGE=1 _HAS_EXCEPTIONS=0) - add_link_options(/DYNAMICBASE) #TODO: Some of these could be cleaned up add_compile_options(/wd4805) # Comparing boolean and int diff --git a/buildfiles/cmake/TCDarwinX86_64.cmake b/buildfiles/cmake/TCDarwinX86_64.cmake new file mode 100644 index 0000000000..0aa93407fb --- /dev/null +++ b/buildfiles/cmake/TCDarwinX86_64.cmake @@ -0,0 +1,2 @@ +set(CMAKE_SYSTEM_NAME Darwin) +set(CMAKE_SYSTEM_PROCESSOR x86_64) diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index b1d10d38eb..d3d23a3184 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -157,10 +157,15 @@ if (NOT ANDROID) COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/bin/Icons $/Icons COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/bin/GuiConfigs $/GuiConfigs COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/bin/test $/test - COMMAND "${WINDEPLOYQT_EXECUTABLE}" --no-compiler-runtime --no-opengl-sw --no-patchqt + ) + get_target_property(WINDEPLOYQT_EXECUTABLE Qt6::windeployqt IMPORTED_LOCATION) + add_custom_command(TARGET rpcs3 POST_BUILD + COMMAND ${WINDEPLOYQT_EXECUTABLE} --no-compiler-runtime --no-opengl-sw --no-patchqt --no-translations --no-system-d3d-compiler --no-system-dxc-compiler --no-quick-import - --plugindir "$,$/plugins,$/share/qt6/plugins>" - --verbose 0 "$") + --plugindir $/qt6/plugins + --verbose 0 + $ + ) endif() # Unix installation diff --git a/rpcs3/Crypto/aesni.cpp b/rpcs3/Crypto/aesni.cpp index 05bb65fe7f..cb09b22378 100644 --- a/rpcs3/Crypto/aesni.cpp +++ b/rpcs3/Crypto/aesni.cpp @@ -197,6 +197,21 @@ void aesni_gcm_mult( unsigned char c[16], const unsigned char b[16] ) { #if defined(POLARSSL_HAVE_MSVC_X64_INTRINSICS) + #ifdef __clang__ + __m128i xa, xb, m0, m1, x10, x32, r; + + xa[1] = _byteswap_uint64( *((unsigned __int64*)a + 0) ); + xa[0] = _byteswap_uint64( *((unsigned __int64*)a + 1) ); + xb[1] = _byteswap_uint64( *((unsigned __int64*)b + 0) ); + xb[0] = _byteswap_uint64( *((unsigned __int64*)b + 1) ); + + clmul256( xa, xb, &m0, &m1 ); + sll256( m0, m1, &x10, &x32 ); + r = reducemod128( x10, x32 ); + + *((unsigned __int64*)c + 0) = _byteswap_uint64( r[1] ); + *((unsigned __int64*)c + 1) = _byteswap_uint64( r[0] ); +#else __m128i xa, xb, m0, m1, x10, x32, r; xa.m128i_u64[1] = _byteswap_uint64( *((unsigned __int64*)a + 0) ); @@ -210,6 +225,7 @@ void aesni_gcm_mult( unsigned char c[16], *((unsigned __int64*)c + 0) = _byteswap_uint64( r.m128i_u64[1] ); *((unsigned __int64*)c + 1) = _byteswap_uint64( r.m128i_u64[0] ); +#endif #else unsigned char aa[16], bb[16], cc[16]; size_t i; diff --git a/rpcs3/Emu/CMakeLists.txt b/rpcs3/Emu/CMakeLists.txt index 3793c94ea1..1a9e95a44d 100644 --- a/rpcs3/Emu/CMakeLists.txt +++ b/rpcs3/Emu/CMakeLists.txt @@ -81,6 +81,7 @@ target_sources(rpcs3_emu PRIVATE ../../Utilities/Thread.cpp ../../Utilities/version.cpp ) + if(APPLE) target_sources(rpcs3_emu PRIVATE ../../darwin/util/sysinfo_darwin.mm @@ -90,12 +91,12 @@ endif() target_include_directories(rpcs3_emu PUBLIC "${CMAKE_SOURCE_DIR}") set_source_files_properties("../../Utilities/JITLLVM.cpp" "../../Utilities/JITASM.cpp" PROPERTIES - COMPILE_FLAGS "$,/GR-,-fno-rtti>" + COMPILE_FLAGS "$,$>/GR-,-fno-rtti>" SKIP_PRECOMPILE_HEADERS ON ) set_source_files_properties("../util/yaml.cpp" PROPERTIES - COMPILE_FLAGS "$,/EHsc,-fexceptions>" + COMPILE_FLAGS "$,$>/EHsc,-fexceptions>" SKIP_PRECOMPILE_HEADERS ON ) diff --git a/rpcs3/Emu/Cell/Modules/cellAtracXdec.cpp b/rpcs3/Emu/Cell/Modules/cellAtracXdec.cpp index 36228d8a5e..8b4285cc15 100644 --- a/rpcs3/Emu/Cell/Modules/cellAtracXdec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAtracXdec.cpp @@ -111,28 +111,7 @@ void AtracXdecDecoder::alloc_avcodec() fmt::throw_exception("avcodec_find_decoder() failed"); } - ensure(!(codec->capabilities & AV_CODEC_CAP_SUBFRAMES)); - - ctx = avcodec_alloc_context3(codec); - if (!ctx) - { - fmt::throw_exception("avcodec_alloc_context3() failed"); - } - - // Allows FFmpeg to output directly into guest memory - ctx->opaque = this; - ctx->thread_type = FF_THREAD_SLICE; // Silences a warning by FFmpeg about requesting frame threading with a custom get_buffer2(). Default is FF_THREAD_FRAME & FF_THREAD_SLICE - ctx->get_buffer2 = [](AVCodecContext* s, AVFrame* frame, int /*flags*/) -> int - { - for (s32 i = 0; i < frame->ch_layout.nb_channels; i++) - { - frame->data[i] = static_cast(s->opaque)->work_mem.get_ptr() + ATXDEC_MAX_FRAME_LENGTH + ATXDEC_SAMPLES_PER_FRAME * sizeof(f32) * i; - frame->linesize[i] = ATXDEC_SAMPLES_PER_FRAME * sizeof(f32); - } - - frame->buf[0] = av_buffer_create(frame->data[0], ATXDEC_SAMPLES_PER_FRAME * sizeof(f32) * frame->ch_layout.nb_channels, [](void*, uint8_t*){}, nullptr, 0); - return 0; - }; + //ensure(!(codec->capabilities & AV_CODEC_CAP_SUBFRAMES)); packet = av_packet_alloc(); if (!packet) @@ -149,18 +128,47 @@ void AtracXdecDecoder::alloc_avcodec() void AtracXdecDecoder::free_avcodec() { - av_packet_free(&packet); - av_frame_free(&frame); - avcodec_free_context(&ctx); + if (packet) + { + av_packet_free(&packet); + } + if (frame) + { + av_frame_free(&frame); + } + if (ctx) + { + avcodec_free_context(&ctx); + } } void AtracXdecDecoder::init_avcodec() { - if (int err = avcodec_close(ctx); err) + if (ctx) { - fmt::throw_exception("avcodec_close() failed (err=0x%x='%s')", err, utils::av_error_to_string(err)); + avcodec_free_context(&ctx); } + ctx = avcodec_alloc_context3(codec); + if (!ctx) + { + fmt::throw_exception("avcodec_alloc_context3() failed"); + } + + // Allows FFmpeg to output directly into guest memory + ctx->opaque = this; + ctx->thread_type = FF_THREAD_SLICE; // Silences a warning by FFmpeg about requesting frame threading with a custom get_buffer2(). Default is FF_THREAD_FRAME & FF_THREAD_SLICE + ctx->get_buffer2 = [](AVCodecContext* s, AVFrame* frame, int /*flags*/) -> int + { + for (s32 i = 0; i < frame->ch_layout.nb_channels; i++) + { + frame->data[i] = static_cast(s->opaque)->work_mem.get_ptr() + ATXDEC_MAX_FRAME_LENGTH + ATXDEC_SAMPLES_PER_FRAME * sizeof(f32) * i; + frame->linesize[i] = ATXDEC_SAMPLES_PER_FRAME * sizeof(f32); + } + + frame->buf[0] = av_buffer_create(frame->data[0], ATXDEC_SAMPLES_PER_FRAME * sizeof(f32) * frame->ch_layout.nb_channels, [](void*, uint8_t*){}, nullptr, 0); + return 0; + }; ctx->block_align = nbytes; ctx->ch_layout.nb_channels = nch_in; ctx->sample_rate = sampling_freq; diff --git a/rpcs3/Emu/Cell/Modules/cellAtracXdec.h b/rpcs3/Emu/Cell/Modules/cellAtracXdec.h index a670a242c2..7fc5e49956 100644 --- a/rpcs3/Emu/Cell/Modules/cellAtracXdec.h +++ b/rpcs3/Emu/Cell/Modules/cellAtracXdec.h @@ -192,10 +192,10 @@ struct AtracXdecDecoder // HLE exclusive b8 config_is_set = false; // For savestates - const AVCodec* codec; - AVCodecContext* ctx; - AVPacket* packet; - AVFrame* frame; + const AVCodec* codec = nullptr; + AVCodecContext* ctx = nullptr; + AVPacket* packet = nullptr; + AVFrame* frame = nullptr; u8 spurs_stuff[84]; // 120 bytes on LLE, pointers to CellSpurs, CellSpursTaskset, etc. diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 784cf27829..312cfad783 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -5751,7 +5751,11 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module std::unique_ptr _module = std::make_unique(obj_name, jit.get_context()); // Initialize target +#if LLVM_VERSION_MAJOR > 20 + _module->setTargetTriple(Triple(jit_compiler::triple1())); +#else _module->setTargetTriple(jit_compiler::triple1()); +#endif _module->setDataLayout(jit.get_engine().getTargetMachine()->createDataLayout()); // Initialize translator diff --git a/rpcs3/Emu/Cell/SPULLVMRecompiler.cpp b/rpcs3/Emu/Cell/SPULLVMRecompiler.cpp index c226e678ad..9bc50f7ea2 100644 --- a/rpcs3/Emu/Cell/SPULLVMRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPULLVMRecompiler.cpp @@ -1601,7 +1601,11 @@ public: // Create LLVM module std::unique_ptr _module = std::make_unique(m_hash + ".obj", m_context); +#if LLVM_VERSION_MAJOR > 20 + _module->setTargetTriple(Triple(jit_compiler::triple2())); +#else _module->setTargetTriple(jit_compiler::triple2()); +#endif _module->setDataLayout(m_jit.get_engine().getTargetMachine()->createDataLayout()); m_module = _module.get(); @@ -2876,7 +2880,11 @@ public: // Create LLVM module std::unique_ptr _module = std::make_unique("spu_interpreter.obj", m_context); +#if LLVM_VERSION_MAJOR > 20 + _module->setTargetTriple(Triple(jit_compiler::triple2())); +#else _module->setTargetTriple(jit_compiler::triple2()); +#endif _module->setDataLayout(m_jit.get_engine().getTargetMachine()->createDataLayout()); m_module = _module.get(); diff --git a/rpcs3/Emu/RSX/Program/ProgramStateCache.cpp b/rpcs3/Emu/RSX/Program/ProgramStateCache.cpp index 67cd710a2c..dfd9fbad5f 100644 --- a/rpcs3/Emu/RSX/Program/ProgramStateCache.cpp +++ b/rpcs3/Emu/RSX/Program/ProgramStateCache.cpp @@ -23,7 +23,8 @@ #endif #endif -#ifdef _MSC_VER +//#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #define AVX512_ICL_FUNC #else #define AVX512_ICL_FUNC __attribute__((__target__("avx512f,avx512bw,avx512dq,avx512cd,avx512vl,avx512bitalg,avx512ifma,avx512vbmi,avx512vbmi2,avx512vnni,avx512vpopcntdq"))) @@ -32,7 +33,8 @@ using namespace program_hash_util; -#ifdef ARCH_X64 +//#ifdef ARCH_X64 +#if defined(ARCH_X64) && !(defined(__clang__) && defined(_MSC_VER)) AVX512_ICL_FUNC usz get_vertex_program_ucode_hash_512(const RSXVertexProgram &program) { // Load all elements of the instruction_mask bitset @@ -424,7 +426,8 @@ vertex_program_utils::vertex_program_metadata vertex_program_utils::analyse_vert usz vertex_program_storage_hash::operator()(const RSXVertexProgram &program) const { -#ifdef ARCH_X64 +//#ifdef ARCH_X64 +#if defined(ARCH_X64) && !(defined(__clang__) && defined(_MSC_VER)) usz ucode_hash; if (utils::has_avx512_icl()) @@ -449,7 +452,8 @@ usz vertex_program_storage_hash::operator()(const RSXVertexProgram &program) con return rpcs3::hash64(ucode_hash, metadata_hash); } -#ifdef ARCH_X64 +//#ifdef ARCH_X64 +#if defined(ARCH_X64) && !(defined(__clang__) && defined(_MSC_VER)) AVX512_ICL_FUNC bool vertex_program_compare_512(const RSXVertexProgram &binary1, const RSXVertexProgram &binary2) { // Load all elements of the instruction_mask bitset @@ -540,7 +544,8 @@ bool vertex_program_compare::operator()(const RSXVertexProgram &binary1, const R return false; } -#ifdef ARCH_X64 +//#ifdef ARCH_X64 +#if defined(ARCH_X64) && !(defined(__clang__) && defined(_MSC_VER)) if (utils::has_avx512_icl()) { return vertex_program_compare_512(binary1, binary2); diff --git a/rpcs3/util/asm.hpp b/rpcs3/util/asm.hpp index 14eaa1409d..bccff669bd 100644 --- a/rpcs3/util/asm.hpp +++ b/rpcs3/util/asm.hpp @@ -9,7 +9,7 @@ extern bool g_use_rtm; extern u64 g_rtm_tx_limit1; #ifdef _M_X64 -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) extern "C" { u32 _xbegin(); @@ -242,7 +242,7 @@ namespace utils constexpr u32 popcnt128(const u128& v) { -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) return popcnt64(v.lo) + popcnt64(v.hi); #else return popcnt64(v) + popcnt64(v >> 64); @@ -274,7 +274,7 @@ namespace utils inline s64 div128(s64 high, s64 low, s64 divisor, s64* remainder = nullptr) { -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) s64 rem = 0; s64 r = _div128(high, low, divisor, &rem); @@ -296,7 +296,7 @@ namespace utils inline u64 udiv128(u64 high, u64 low, u64 divisor, u64* remainder = nullptr) { -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) u64 rem = 0; u64 r = _udiv128(high, low, divisor, &rem); @@ -316,7 +316,7 @@ namespace utils return r; } -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) inline u128 operator/(u128 lhs, u64 rhs) { u64 rem = 0; @@ -326,7 +326,7 @@ namespace utils constexpr u32 ctz128(u128 arg) { -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) if (!arg.lo) return std::countr_zero(arg.hi) + 64u; else @@ -341,7 +341,7 @@ namespace utils constexpr u32 clz128(u128 arg) { -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) if (arg.hi) return std::countl_zero(arg.hi); else @@ -470,6 +470,6 @@ namespace utils using utils::busy_wait; -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) using utils::operator/; #endif diff --git a/rpcs3/util/types.hpp b/rpcs3/util/types.hpp index 690f51c0e7..2ef140e941 100644 --- a/rpcs3/util/types.hpp +++ b/rpcs3/util/types.hpp @@ -249,13 +249,13 @@ public: } }; -#if defined(ARCH_X64) && !defined(_MSC_VER) +#if defined(ARCH_X64) && !defined(_MSC_VER) && !defined(__m128) using __m128i = long long __attribute__((vector_size(16))); using __m128d = double __attribute__((vector_size(16))); using __m128 = float __attribute__((vector_size(16))); #endif -#ifndef _MSC_VER +#if !defined(_MSC_VER) || defined(__clang__) using u128 = __uint128_t; using s128 = __int128_t; #else @@ -266,8 +266,8 @@ extern "C" union __m128i; struct __m128d; - uchar _addcarry_u64(uchar, u64, u64, u64*); - uchar _subborrow_u64(uchar, u64, u64, u64*); + constexpr uchar _addcarry_u64(uchar, u64, u64, u64*); + constexpr uchar _subborrow_u64(uchar, u64, u64, u64*); u64 __shiftleft128(u64, u64, uchar); u64 __shiftright128(u64, u64, uchar); u64 _umul128(u64, u64, u64*); @@ -579,7 +579,7 @@ struct s128 : u128 // Optimization for u64*u64=u128 constexpr u128 u128_from_mul(u64 a, u64 b) { -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) if (!std::is_constant_evaluated()) { u64 hi;