From 42c7f13ce5865ce51b382ece1822d9ba70f94d81 Mon Sep 17 00:00:00 2001 From: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com> Date: Sat, 19 Jul 2025 21:02:56 -0700 Subject: [PATCH 01/12] clang-cl ffmpeg Update rpcs3.yml Update rpcs3.yml Update rpcs3.yml folded scalar with neg newline x64-windows-release x64-windows-rel if: "!cancelled()" vcpkg_build_type Update rpcs3.yml no ccache ${{github.run_id}} zlib vcpkg qt vulkan ffmpeg llvm build with clang-cl Create build-windows-clang-cl.ps1 llvm --keep-going llvm[clang,core,tools,lld,target-x86]:x64-windows-release llvm:x64-windows-release@17.0.2 llvm with debug on Create vcpkg.json Update rpcs3.yml ffmpeg features vcpkg nuget minimal vcpkg.json Update rpcs3.yml fetch nuget more packages vcpkg.json libpng vcpkg classic cmake 3.29.0 Rename vcpkg.json to x_vcpkg.json Update rpcs3.yml Update rpcs3.yml llvm Update rpcs3.yml git llvm LLVM with cache Update rpcs3.yml Update rpcs3.yml build llvm LLVM_TARGETS_TO_BUILD="X86" llvm binary set path build rpcs3 DIA SDK Update rpcs3.yml Update rpcs3.yml Update rpcs3.yml fix conditionals fix conditionals set shell VCPKG env vars DIA SDK Update asm.hpp Update types.hpp Update aesni.cpp Update CMakeLists.txt Update ConfigureCompiler.cmake Update StrFmt.cpp Update CMakeLists.txt Update CMakeLists.txt Build with changes Update CMakeLists.txt D:\a\rpcs3\rpcs3\llvm D:\a\rpcs3\rpcs3\llvm llvm-* llvm-${{ matrix.llvmver }} clangpath llvm-* $llvmver $clangPath $clangPath include bin rm duplicate "add_compile_options" USE_SYSTEM_ZSTD USE_SYSTEM_ZSTD USE_SYSTEM_ZSTD USE_SYSTEM_ZSTD zstd Update CMakeLists.txt PkgConfig zstd zstd::zstd ALIAS PkgConfig::libzstd clang-cl only cache hit Update CMakeLists.txt cache-hit cache vcpkg/vcpkg.exe NOT USE_SYSTEM_ZSTD vcpkg_root revert zstd Update CMakeLists.txt Update CMakeLists.txt Update CMakeLists.txt /defaultlib:zstd_static.lib Remove else /defaultlib:zstd.lib Zstd ahared Nodefaultlib Create Findzstd.cmake zstd CMakeLists.txt not use zstd system CMakeLists.txt dont add 3rdparty::libzstd add_library(PkgConfig::libzstd ALIAS 3rdparty::zstd) add_library(PkgConfig::libzstd ALIAS 3rdparty::zstd) add_library(3rdparty::libzstd ALIAS PkgConfig::zstd) add_library(3rdparty::zstd ALIAS PkgConfig::zstd) Update Findzstd.cmake zstd::zstd Update CMakeLists.txt zstd::zstd zstd::zstd CMakeLists.txt PkgConfig::libzstd CMakeLists.txt zstd::libzstd Update CMakeLists.txt Update CMakeLists.txt vcpkg zstd CMakeLists.txt MODULES CMakeLists.txt zstd::libzstd add_library(3rdparty::7zip ALIAS 3rdparty_7zip) LLVM Static-link on set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Release>") set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") Update CMakeLists.txt message(STATUS "MSVC Runtime Library: ${CMAKE_MSVC_RUNTIME_LIBRARY}") revert CMakeLists.txt DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" rpcs3_emu SHARED STATIC CMakeLists.txt cmake_policy(SET CMP0091 NEW) LLVM_AVAILABLE=ON add_compile_definitions(LLVM_AVAILABLE=true) add_compile_options(/MT) LLVM_AVAILABLE=1 add_compile_definitions(_DISABLE_STRING_ANNOTATION=1 _DISABLE_VECTOR_ANNOTATION=1) Update build-windows-clang-cl.ps1 clang msvc17-msvcrt rm compressed archve cachee name cache name again builtin clang-rt build all set $llvmPath extract into llvm copy with -verbose mv destination path build llvm cache $clangPath full build LLVM static LLVM -> LLVMCore STATIC_LINK_LLVM=OFF no lookup llvm bin dir revert revert revert LLVMCore -> LLVM LLVM -> LLVM-C llvm_map_components_to_libnames Update CMakeLists.txt LLVM CMakeLists.txt LLVM_DIR=$llvmPath MultiThreadedDLL CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON clang-cl version cmake -v --log-level=VERBOSE built-in LLVM llvm lib folder PF short name built-in LLVM/Clang 20.1.8 mt.exe path Use llvm-mt "$clangPath/llvm-mt.exe" fix terminator Add winqtdeploy to PATH Test windeployqt6.exe with version Missing ) No winqtdeploy Build no quotes prep artifacts no winqtdeploy $VcpkgWindeployqt --version $($VcpkgWindeployqt) --version --version Invoke-Expression Update build-windows-clang-cl.ps1 rpcs3_win_clang.7z rpcs3 artifacts dir cp artifacts build/bin dir clone recent asmjit Update build-windows-clang-cl.ps1 CMAKE_CXX_SCAN_FOR_MODULES=ON default-openal USE_NATIVE_INSTRUCTIONS=ON Update ConfigureCompiler.cmake USE_NATIVE_INSTRUCTIONS=OFF / rm 512 instuctions revert set(LLVM_LIBS LLVM) COMPILER_X86 only add_compile_options(-msse -msse2 -mcx16 -mavx512f -mavx -mavx2 -maes -mrtm -mpclmul -mmwaitx -mwaitpkg) avx512 flags add_compile_options(-march=native) check_cxx_compiler_flag("-march=native" add_compile_options(-maes -mrtm -mpclmul -mmwaitx -mwaitpkg) COMMAND Qt6::windeployqt --version COMMAND Qt6::windeployqt $ add vcpkg bin to PATH check vcpkg is added to PATH update PATH cache [System.EnvironmentVariableTarget]::Machine display all paths cmd.exe /c "echo %PATH%" make windeployqt verbose verbose 2 Invoke-Expression "cmd.exe /c "set PATH=%PATH%;$VcpkgBin"" Update build-windows-clang-cl.ps1 no invoke cmd.exe /c "set PATH=$VcpkgBin;%PATH%" --ignore-library-errors -DQTPATH_EXE="$VcpkgQtpath" no --ignore-library-errors Update CMakeLists.txt Update CMakeLists.txt Update CMakeLists.txt Update CMakeLists.txt Update CMakeLists.txt Update CMakeLists.txt Update CMakeLists.txt Update CMakeLists.txt change \ to / ${WINDEPLOYQT_EXECUTABLE} Qt6::windeployqt gci vcpkg tools bin --ignore-library-errors x64-windows/tools VCPKG_TRIPLET: x64-windows Save vcpkg cache revert revert remove MSVC runtime message revert rm dupes revert Delete buildfiles/cmake/Findzstd.cmake WINDEPLOYQT_EXECUTABLE Delete x_vcpkg.json add AVX512 compile options Wno-deprecated-anon-enum-enum-conversion clean-up silence warnings terminate properly set PRIVATE CFLAGS --no-vulkan rm vulkan lib at package step override cflags remove OpenGL_GL_PREFERENCE=LEGACY rm --no-vulkan switch Update CMakeLists.txt restore LLVM dir ASMJIT_CMAKE_FLAGS revert order check_cxx_compiler_flag Wno-unused-value revert revert Update CMakeLists.txt Update llvm_build_clang_cl.vcxproj Update llvm_build_clang_cl.vcxproj Update rpcs3.yml go to deploy if successful Create deploy-windows-clang-cl.sh build then deploy Update build-windows-clang-cl.ps1 deploy step test Update ProgramStateCache.cpp remove AVX512 Update JITLLVM.cpp FFMPEG 8.0 FFMPEG 8.0 LLVM 21 LLVM 21 set CMAKE_MSVC_RUNTIME_LIBRARY update OpenAL msys2 clang git openal-soft reset update yaml reset to master reset to master "Build succeeded" ALSOFT_ENABLE_MODULES OFF Build All Jobs Run Builds when not on Main branch Win Qt 6.9.3 Update build-mac-arm64.sh Update build-mac.sh Create TCDarwinX86_64.cmake --- .ci/build-mac-arm64.sh | 19 +-- .ci/build-mac.sh | 35 ++--- .ci/build-windows-clang-cl.ps1 | 143 +++++++++++++++++++ .ci/build-windows-clang.sh | 3 +- .ci/deploy-windows-clang-cl.sh | 42 ++++++ .github/workflows/rpcs3.yml | 148 +++++++++++++++++--- 3rdparty/OpenAL/CMakeLists.txt | 1 + 3rdparty/OpenAL/openal-soft.vcxproj | 6 +- 3rdparty/llvm/llvm_build_clang_cl.vcxproj | 2 +- 3rdparty/wolfssl/CMakeLists.txt | 16 ++- 3rdparty/zstd/CMakeLists.txt | 25 ++-- CMakeLists.txt | 5 +- Utilities/JITLLVM.cpp | 8 ++ Utilities/StrFmt.cpp | 2 +- buildfiles/cmake/ConfigureCompiler.cmake | 17 ++- buildfiles/cmake/TCDarwinX86_64.cmake | 2 + rpcs3/CMakeLists.txt | 11 +- rpcs3/Crypto/aesni.cpp | 16 +++ rpcs3/Emu/CMakeLists.txt | 5 +- rpcs3/Emu/Cell/Modules/cellAtracXdec.cpp | 62 ++++---- rpcs3/Emu/Cell/Modules/cellAtracXdec.h | 8 +- rpcs3/Emu/Cell/PPUThread.cpp | 4 + rpcs3/Emu/Cell/SPULLVMRecompiler.cpp | 8 ++ rpcs3/Emu/RSX/Program/ProgramStateCache.cpp | 15 +- rpcs3/util/asm.hpp | 16 +-- rpcs3/util/types.hpp | 10 +- 26 files changed, 511 insertions(+), 118 deletions(-) create mode 100644 .ci/build-windows-clang-cl.ps1 create mode 100644 .ci/deploy-windows-clang-cl.sh create mode 100644 buildfiles/cmake/TCDarwinX86_64.cmake 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; From d24305564d33bae12933ec08419fe8442f4a43fe Mon Sep 17 00:00:00 2001 From: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com> Date: Sun, 12 Oct 2025 23:42:49 -0700 Subject: [PATCH 02/12] Update deploy-mac.sh --- .ci/deploy-mac.sh | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/.ci/deploy-mac.sh b/.ci/deploy-mac.sh index c293358748..55b8c5eb9a 100755 --- a/.ci/deploy-mac.sh +++ b/.ci/deploy-mac.sh @@ -36,9 +36,7 @@ mv rpcs3.app RPCS3_.app mv RPCS3_.app RPCS3.app # Hack -install_name_tool \ --delete_rpath /usr/local/lib \ --delete_rpath /usr/local/opt/llvm@$LLVM_COMPILER_VER/lib RPCS3.app/Contents/MacOS/rpcs3 +install_name_tool -delete_rpath /usr/local/lib RPCS3.app/Contents/MacOS/rpcs3 #-delete_rpath /usr/local/Cellar/sdl3/3.2.8/lib # NOTE: "--deep" is deprecated @@ -48,24 +46,8 @@ echo "[InternetShortcut]" > Quickstart.url echo "URL=https://rpcs3.net/quickstart" >> Quickstart.url echo "IconIndex=0" >> Quickstart.url -#DMG_FILEPATH="$BUILD_ARTIFACTSTAGINGDIRECTORY/rpcs3-v${COMM_TAG}-${COMM_COUNT}-${COMM_HASH}_macos.dmg" -#"$BREW_X64_PATH/bin/create-dmg" --volname RPCS3 \ -#--window-size 800 400 \ -#--icon-size 100 \ -#--icon rpcs3.app 200 190 \ -#--add-file Quickstart.url Quickstart.url 400 20 \ -#--hide-extension rpcs3.app \ -#--hide-extension Quickstart.url \ -#--app-drop-link 600 185 \ -#--skip-jenkins \ -#--format ULMO \ -#"$DMG_FILEPATH" \ -#RPCS3.app -#FILESIZE=$(stat -f %z "$DMG_FILEPATH") -#SHA256SUM=$(shasum -a 256 "$DMG_FILEPATH" | awk '{ print $1 }') - ARCHIVE_FILEPATH="$BUILD_ARTIFACTSTAGINGDIRECTORY/rpcs3-v${COMM_TAG}-${COMM_COUNT}-${COMM_HASH}_macos.7z" -"$BREW_X64_PATH/bin/7z" a -mx9 "$ARCHIVE_FILEPATH" RPCS3.app Quickstart.url +"/opt/homebrew/bin/7z" a -mx9 "$ARCHIVE_FILEPATH" RPCS3.app Quickstart.url FILESIZE=$(stat -f %z "$ARCHIVE_FILEPATH") SHA256SUM=$(shasum -a 256 "$ARCHIVE_FILEPATH" | awk '{ print $1 }') From fd2576fabbc7ba666fec6973cc716134786ed744 Mon Sep 17 00:00:00 2001 From: Live session user Date: Wed, 15 Oct 2025 08:01:11 -0700 Subject: [PATCH 03/12] LLVM 19.1.7 --- .ci/build-windows-clang-cl.ps1 | 2 -- .ci/build-windows-clang.sh | 1 - .github/workflows/rpcs3.yml | 14 +++++--------- 3rdparty/zstd/CMakeLists.txt | 1 - 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.ci/build-windows-clang-cl.ps1 b/.ci/build-windows-clang-cl.ps1 index 367f2feaed..19200974e5 100644 --- a/.ci/build-windows-clang-cl.ps1 +++ b/.ci/build-windows-clang-cl.ps1 @@ -30,7 +30,6 @@ $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" @@ -80,7 +79,6 @@ $submodules = Select-String -Path .gitmodules -Pattern 'path = (.+)' | ForEach-O 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" diff --git a/.ci/build-windows-clang.sh b/.ci/build-windows-clang.sh index 75054cc66b..06482dd63a 100644 --- a/.ci/build-windows-clang.sh +++ b/.ci/build-windows-clang.sh @@ -6,7 +6,6 @@ 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 diff --git a/.github/workflows/rpcs3.yml b/.github/workflows/rpcs3.yml index 2d5b29acf1..7630729902 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: @@ -337,7 +337,7 @@ jobs: compiler: clang arch: win64 - compiler: clang-cl - llvmver: 20.1.8 + llvmver: 19.1.7 arch: win64 env: @@ -350,7 +350,6 @@ jobs: uses: actions/checkout@main with: fetch-depth: 0 - - name: Setup msys2 uses: msys2/setup-msys2@v2 if: ${{ matrix.compiler == 'clang' }} @@ -387,7 +386,6 @@ jobs: 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 @@ -437,15 +435,14 @@ jobs: 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 + curl -fsSLO https://github.com/vovkos/llvm-package-windows/releases/download/llvm-${{ matrix.llvmver }}/llvm-${{ matrix.llvmver }}-windows-amd64-msvc17-msvcrt.7z + curl -fsSLO https://github.com/vovkos/llvm-package-windows/releases/download/clang-${{ matrix.llvmver }}/clang-${{ matrix.llvmver }}-windows-amd64-msvc17-msvcrt.7z 7z x llvm-*.7z mv llvm* llvm-${{ matrix.llvmver }} rm llvm-*.7z @@ -455,7 +452,6 @@ jobs: } 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' diff --git a/3rdparty/zstd/CMakeLists.txt b/3rdparty/zstd/CMakeLists.txt index 5bf68692c3..e0454c9ea9 100644 --- a/3rdparty/zstd/CMakeLists.txt +++ b/3rdparty/zstd/CMakeLists.txt @@ -5,7 +5,6 @@ if(NOT USE_SYSTEM_ZSTD) 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) From 451d6e0039453c8b128870f5568ac8fdeac27380 Mon Sep 17 00:00:00 2001 From: Live session user Date: Wed, 15 Oct 2025 08:31:58 -0700 Subject: [PATCH 04/12] Updated OpenAL to 9c50193 --- 3rdparty/OpenAL/openal-soft | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/OpenAL/openal-soft b/3rdparty/OpenAL/openal-soft index dc7d7054a5..9c50193236 160000 --- a/3rdparty/OpenAL/openal-soft +++ b/3rdparty/OpenAL/openal-soft @@ -1 +1 @@ -Subproject commit dc7d7054a5b4f3bec1dc23a42fd616a0847af948 +Subproject commit 9c50193236ad4d8c68f390a3151f8253709baabd From 8228ae6c1766fb963a7d6bb52434c0595ef2fe95 Mon Sep 17 00:00:00 2001 From: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com> Date: Thu, 16 Oct 2025 03:27:58 -0700 Subject: [PATCH 05/12] Fix compile flags for MSVC and Clang in CMakeLists --- rpcs3/Emu/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/CMakeLists.txt b/rpcs3/Emu/CMakeLists.txt index ad310ba1e0..3b3af36aa3 100644 --- a/rpcs3/Emu/CMakeLists.txt +++ b/rpcs3/Emu/CMakeLists.txt @@ -91,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 ) From c902134c5515520caf1deb2bc916d73dd9ce59b7 Mon Sep 17 00:00:00 2001 From: Live session user Date: Fri, 17 Oct 2025 06:14:03 -0700 Subject: [PATCH 06/12] Windows build shell script --- .ci/build-windows-clang-cl.ps1 | 141 --------------------------------- .ci/build-windows-clang-cl.sh | 99 +++++++++++++++++++++++ .github/workflows/rpcs3.yml | 7 +- 3rdparty/zstd/CMakeLists.txt | 15 ++-- 4 files changed, 108 insertions(+), 154 deletions(-) delete mode 100644 .ci/build-windows-clang-cl.ps1 create mode 100755 .ci/build-windows-clang-cl.sh diff --git a/.ci/build-windows-clang-cl.ps1 b/.ci/build-windows-clang-cl.ps1 deleted file mode 100644 index 19200974e5..0000000000 --- a/.ci/build-windows-clang-cl.ps1 +++ /dev/null @@ -1,141 +0,0 @@ -# .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" - -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 - -# 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-cl.sh b/.ci/build-windows-clang-cl.sh new file mode 100755 index 0000000000..a24d8f8361 --- /dev/null +++ b/.ci/build-windows-clang-cl.sh @@ -0,0 +1,99 @@ +#!/bin/sh -e + +echo "Starting RPCS3 build (Bash script)" + +# Automatically find clang_rt.builtins-x86_64.lib +echo "Searching for clang_rt.builtins-x86_64.lib ..." +clangBuiltinsLibPath=$(find "C:\Program Files\LLVM\lib\clang" -name "clang_rt.builtins-x86_64.lib" | sed 's|Program Files|PROGRA~1|g') + +if [ -z "$clangBuiltinsLibPath" ]; then + echo "ERROR: Could not find clang_rt.builtins-x86_64.lib in LLVM installation." + exit 1 +fi + +clangBuiltinsDir=$(dirname "$clangBuiltinsLibPath") +clangBuiltinsLib=$(basename "$clangBuiltinsLibPath") +# shellcheck disable=SC2028 +clangPath=$(echo "C:\Program Files\LLVM\bin" | sed 's|Program Files|PROGRA~1|g') + +echo "Found Clang builtins library: $clangBuiltinsLib in $clangBuiltinsDir" +echo "Found Clang Path: $clangPath" + +# Search for mt.exe in SDK bin directories +echo "Searching for llvm-mt.exe ..." +mtPath=$(find "$clangPath" -name "llvm-mt.exe") + +if [ -z "$mtPath" ]; then + echo "ERROR: Could not find llvm-mt.exe in SDK directories." + exit 1 +fi + +echo "Found llvm-mt.exe at: $mtPath" + +VcpkgRoot="$(pwd)/vcpkg" +VcpkgTriplet="$VCPKG_TRIPLET" +VcpkgInstall="$VcpkgRoot/installed/$VcpkgTriplet" +VcpkgInclude="$VcpkgInstall/include" +VcpkgLib="$VcpkgInstall/lib" + +# Configure git safe directory +echo "Configuring git safe directory" +git config --global --add safe.directory '*' + +# Initialize submodules except certain ones +echo "Initializing submodules" +# shellcheck disable=SC2046 +git submodule -q update --init $(awk '/path/ && !/llvm/ && !/opencv/ && !/FAudio/ && !/libpng/ && !/zlib/ && !/feralinteractive/ { print $3 }' .gitmodules) + +# Create and enter build directory +echo "Creating build directory" +mkdir -p build +cd build || exit +echo "Changed directory to: $(pwd)" + +# Run CMake with Ninja generator and required flags +echo "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:${clangBuiltinsDir} /defaultlib:${clangBuiltinsLib}" \ + -DCMAKE_MT="${mtPath}" \ + -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 + +echo "CMake configuration complete" + +# Build with ninja +echo "Starting build with Ninja..." +ninja + +echo "Build succeeded" + +# Go back to root directory +cd .. +echo "Returned to root directory: $(pwd)" diff --git a/.github/workflows/rpcs3.yml b/.github/workflows/rpcs3.yml index 7630729902..16ad0c5ffb 100644 --- a/.github/workflows/rpcs3.yml +++ b/.github/workflows/rpcs3.yml @@ -392,7 +392,6 @@ jobs: id: restore-vcpkg-cache with: path: | - vcpkg/vcpkg.exe vcpkg/installed vcpkg/buildtrees key: vcpkg-${{ runner.os }}-${{ matrix.compiler }}-${{ runner.arch }}-${{ hashFiles('**/vcpkg') }} @@ -422,7 +421,6 @@ jobs: uses: actions/cache/save@main with: path: | - vcpkg/vcpkg.exe vcpkg/installed vcpkg/buildtrees key: ${{ steps.restore-vcpkg-cache.outputs.cache-primary-key }} @@ -481,13 +479,12 @@ jobs: 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" + "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 - 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 + run: .ci/build-windows-clang-cl.sh - name: Save build Ccache #if: github.ref == 'refs/heads/master' diff --git a/3rdparty/zstd/CMakeLists.txt b/3rdparty/zstd/CMakeLists.txt index e0454c9ea9..c5c8dd66ff 100644 --- a/3rdparty/zstd/CMakeLists.txt +++ b/3rdparty/zstd/CMakeLists.txt @@ -1,6 +1,10 @@ -# zstd -# Select the version of zstd to use, default is builtin -if(NOT USE_SYSTEM_ZSTD) +if(USE_SYSTEM_ZSTD) + message(STATUS "RPCS3: using shared zstd") + pkg_check_modules(zstd REQUIRED IMPORTED_TARGET libzstd) + add_library(3rdparty_zstd INTERFACE) + target_link_libraries(3rdparty_zstd INTERFACE PkgConfig::zstd) + target_include_directories(3rdparty_zstd INTERFACE PkgConfig::RtMidi) +else() option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" OFF) option(ZSTD_BUILD_SHARED "BUILD SHARED LIBRARIES" OFF) option(ZSTD_BUILD_STATIC "BUILD STATIC LIBRARIES" ON) @@ -8,9 +12,4 @@ if(NOT USE_SYSTEM_ZSTD) 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() From 1148253b790886c6c7080ac2b9ced7233892ccdf Mon Sep 17 00:00:00 2001 From: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com> Date: Fri, 17 Oct 2025 09:56:31 -0700 Subject: [PATCH 07/12] Fix shell for Windows sh script --- .github/workflows/rpcs3.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rpcs3.yml b/.github/workflows/rpcs3.yml index 16ad0c5ffb..d9cda2c6a3 100644 --- a/.github/workflows/rpcs3.yml +++ b/.github/workflows/rpcs3.yml @@ -483,7 +483,7 @@ jobs: - name: Build RPCS3 if: ${{ matrix.compiler == 'clang-cl' }} - shell: cmd + shell: bash run: .ci/build-windows-clang-cl.sh - name: Save build Ccache From e65b63308f53a4c14d4ad18db83e477df46bed9a Mon Sep 17 00:00:00 2001 From: Live session user Date: Fri, 31 Oct 2025 07:37:56 -0700 Subject: [PATCH 08/12] Fix submodule errors --- .ci/build-windows-clang-cl.sh | 7 ++- .github/workflows/rpcs3.yml | 57 ++++++++------------- 3rdparty/OpenAL/openal-soft | 2 +- 3rdparty/asmjit/CMakeLists.txt | 1 + 3rdparty/cubeb/CMakeLists.txt | 5 ++ 3rdparty/libusb/config.cmake | 7 +++ 3rdparty/yaml-cpp/CMakeLists.txt | 1 + buildfiles/cmake/ConfigureCompiler.cmake | 3 +- rpcs3/Crypto/aesni.cpp | 3 ++ rpcs3/Emu/Memory/vm_reservation.h | 16 +++--- rpcs3/Emu/RSX/Common/BufferUtils.cpp | 2 +- rpcs3/Emu/RSX/Program/ProgramStateCache.cpp | 13 ++--- rpcs3/util/asm.hpp | 6 +-- rpcs3/util/sysinfo.cpp | 2 +- vcpkg.json | 24 +++++++++ 15 files changed, 85 insertions(+), 64 deletions(-) create mode 100644 vcpkg.json diff --git a/.ci/build-windows-clang-cl.sh b/.ci/build-windows-clang-cl.sh index a24d8f8361..f6feea350b 100755 --- a/.ci/build-windows-clang-cl.sh +++ b/.ci/build-windows-clang-cl.sh @@ -30,9 +30,10 @@ fi echo "Found llvm-mt.exe at: $mtPath" -VcpkgRoot="$(pwd)/vcpkg" +VcpkgRoot="$VCPKG_ROOT" +VcpkgBuildRoot="$GITHUB_WORKSPACE/build" VcpkgTriplet="$VCPKG_TRIPLET" -VcpkgInstall="$VcpkgRoot/installed/$VcpkgTriplet" +VcpkgInstall="$VcpkgBuildRoot/vcpkg_installed/$VcpkgTriplet" VcpkgInclude="$VcpkgInstall/include" VcpkgLib="$VcpkgInstall/lib" @@ -42,8 +43,10 @@ git config --global --add safe.directory '*' # Initialize submodules except certain ones echo "Initializing submodules" +set -x # shellcheck disable=SC2046 git submodule -q update --init $(awk '/path/ && !/llvm/ && !/opencv/ && !/FAudio/ && !/libpng/ && !/zlib/ && !/feralinteractive/ { print $3 }' .gitmodules) +set +x # Create and enter build directory echo "Creating build directory" diff --git a/.github/workflows/rpcs3.yml b/.github/workflows/rpcs3.yml index cc50e17208..04b52250f0 100644 --- a/.github/workflows/rpcs3.yml +++ b/.github/workflows/rpcs3.yml @@ -344,12 +344,15 @@ jobs: CCACHE_DIR: 'C:\ccache' VCPKG_TRIPLET: x64-windows VCPKG_BUILD_TYPE: release + VCPKG_ROOT: "${{github.workspace}}/vcpkg" + VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite' 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' }} @@ -386,42 +389,21 @@ jobs: 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/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 + - name: 'Setup NuGet Credentials for 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: ${{ github.ref == 'refs/heads/master' && matrix.compiler == 'clang-cl' }} - uses: actions/cache/save@main - with: - path: | - vcpkg/installed - vcpkg/buildtrees - key: ${{ steps.restore-vcpkg-cache.outputs.cache-primary-key }} + shell: 'bash' + run: | + `./vcpkg/vcpkg fetch nuget | tail -n 1` \ + sources add \ + -source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \ + -storepasswordincleartext \ + -name "GitHub" \ + -username "${{ github.repository_owner }}" \ + -password "${{ secrets.GITHUB_TOKEN }}" + `./vcpkg/vcpkg fetch nuget | tail -n 1` \ + setapikey "${{ secrets.GITHUB_TOKEN }}" \ + -source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" - name: Restore LLVM Cache if: ${{ matrix.compiler == 'clang-cl' }} @@ -431,6 +413,7 @@ jobs: 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 @@ -447,14 +430,14 @@ jobs: 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: ${{ github.ref == 'refs/heads/master' && matrix.compiler == 'clang-cl' }} 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 @@ -472,7 +455,7 @@ jobs: .ci/build-windows-clang.sh .ci/setup-windows-ci-vars.sh ${{ matrix.arch }} ${{ matrix.compiler }} .ci/deploy-windows-${{ matrix.compiler }}.sh - + - name: install DIA SDK if: ${{ matrix.compiler == 'clang-cl' }} run: | diff --git a/3rdparty/OpenAL/openal-soft b/3rdparty/OpenAL/openal-soft index 9c50193236..0e5e98e4ac 160000 --- a/3rdparty/OpenAL/openal-soft +++ b/3rdparty/OpenAL/openal-soft @@ -1 +1 @@ -Subproject commit 9c50193236ad4d8c68f390a3151f8253709baabd +Subproject commit 0e5e98e4ac8adae92e4f7653dd6eee17aa9c8791 diff --git a/3rdparty/asmjit/CMakeLists.txt b/3rdparty/asmjit/CMakeLists.txt index ae88ce2fe8..dbbf85f362 100644 --- a/3rdparty/asmjit/CMakeLists.txt +++ b/3rdparty/asmjit/CMakeLists.txt @@ -11,6 +11,7 @@ include("${ASMJIT_DIR}/CMakeLists.txt") add_library(asmjit ${ASMJIT_SRC}) target_include_directories(asmjit PUBLIC ${ASMJIT_DIR}/src) target_link_libraries(asmjit PRIVATE ${ASMJIT_DEPS}) +target_compile_options(asmjit PRIVATE -Wno-nontrivial-memcall -Wno-deprecated-anon-enum-enum-conversion) # ASMJIT should have a option for disabling installing and this wouldnt # be required to avoid installing ASMJIT... diff --git a/3rdparty/cubeb/CMakeLists.txt b/3rdparty/cubeb/CMakeLists.txt index 6d1f231f0b..427bb0eff5 100644 --- a/3rdparty/cubeb/CMakeLists.txt +++ b/3rdparty/cubeb/CMakeLists.txt @@ -10,6 +10,11 @@ set(USE_SANITIZERS FALSE CACHE BOOL "Dont't use sanitizers") add_subdirectory(cubeb EXCLUDE_FROM_ALL) add_library(3rdparty::cubeb ALIAS cubeb) +target_compile_options(cubeb PRIVATE + -Wno-int-to-void-pointer-cast + -Wno-deprecated-declarations + -Wno-implicit-const-int-float-conversion + ) if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm|ARM|aarch64|AArch64|Aarch64)") target_compile_definitions(speex PUBLIC diff --git a/3rdparty/libusb/config.cmake b/3rdparty/libusb/config.cmake index 1a9833eb9b..4349b86262 100644 --- a/3rdparty/libusb/config.cmake +++ b/3rdparty/libusb/config.cmake @@ -33,6 +33,13 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") ) elseif(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) + if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + append_compiler_flags( + -Wno-unused-value + -Wno-pragma-pack + ${ADDITIONAL_CC_FLAGS} + ) + endif() endif() check_include_files(sys/timerfd.h USBI_TIMERFD_AVAILABLE) diff --git a/3rdparty/yaml-cpp/CMakeLists.txt b/3rdparty/yaml-cpp/CMakeLists.txt index 0c123a37b8..41fdf4173c 100644 --- a/3rdparty/yaml-cpp/CMakeLists.txt +++ b/3rdparty/yaml-cpp/CMakeLists.txt @@ -12,5 +12,6 @@ set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "Enable testing" FORCE) set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "Enable parse tools" FORCE) set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "Enable contrib stuff in library" FORCE) add_subdirectory(yaml-cpp EXCLUDE_FROM_ALL) +target_compile_options(yaml-cpp PRIVATE -Wno-ignored-attributes -Wno-unused-value) set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX_OLD}) diff --git a/buildfiles/cmake/ConfigureCompiler.cmake b/buildfiles/cmake/ConfigureCompiler.cmake index 5fa1c589a1..1c1ba7139a 100644 --- a/buildfiles/cmake/ConfigureCompiler.cmake +++ b/buildfiles/cmake/ConfigureCompiler.cmake @@ -5,8 +5,7 @@ if(MSVC) 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) + add_compile_options(-msse -msse2 -mcx16) endif() if(COMPILER_SUPPORTS_MARCH_NATIVE) add_compile_options(-march=native) diff --git a/rpcs3/Crypto/aesni.cpp b/rpcs3/Crypto/aesni.cpp index cb09b22378..e75333c249 100644 --- a/rpcs3/Crypto/aesni.cpp +++ b/rpcs3/Crypto/aesni.cpp @@ -35,6 +35,9 @@ #if defined(_MSC_VER) && defined(_M_X64) #define POLARSSL_HAVE_MSVC_X64_INTRINSICS #include +#ifdef __clang__ +#include +#endif #endif /* diff --git a/rpcs3/Emu/Memory/vm_reservation.h b/rpcs3/Emu/Memory/vm_reservation.h index 6ff9aa2376..61c3745d72 100644 --- a/rpcs3/Emu/Memory/vm_reservation.h +++ b/rpcs3/Emu/Memory/vm_reservation.h @@ -171,7 +171,7 @@ namespace vm auto stamp0 = utils::get_tsc(), stamp1 = stamp0, stamp2 = stamp0; -#ifndef _MSC_VER +#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) __asm__ goto ("xbegin %l[stage2];" ::: "memory" : stage2); #else status = _xbegin(); @@ -180,7 +180,7 @@ namespace vm { if (res & rsrv_unique_lock) { -#ifndef _MSC_VER +#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) __asm__ volatile ("xend; mov $-1, %%eax;" ::: "memory"); #else _xend(); @@ -192,7 +192,7 @@ namespace vm { std::invoke(op, *sptr); const u64 old_time = res.fetch_add(128); -#ifndef _MSC_VER +#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) __asm__ volatile ("xend;" ::: "memory"); #else _xend(); @@ -206,7 +206,7 @@ namespace vm if (auto result = std::invoke(op, *sptr)) { const u64 old_time = res.fetch_add(128); -#ifndef _MSC_VER +#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) __asm__ volatile ("xend;" ::: "memory"); #else _xend(); @@ -247,7 +247,7 @@ namespace vm break; } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) __asm__ goto ("xbegin %l[retry];" ::: "memory" : retry); #else status = _xbegin(); @@ -260,7 +260,7 @@ namespace vm if constexpr (std::is_void_v>) { std::invoke(op, *sptr); -#ifndef _MSC_VER +#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) __asm__ volatile ("xend;" ::: "memory"); #else _xend(); @@ -274,7 +274,7 @@ namespace vm { if (auto result = std::invoke(op, *sptr)) { -#ifndef _MSC_VER +#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) __asm__ volatile ("xend;" ::: "memory"); #else _xend(); @@ -286,7 +286,7 @@ namespace vm } else { -#ifndef _MSC_VER +#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) __asm__ volatile ("xend;" ::: "memory"); #else _xend(); diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index d6ee2349d2..d0704e5ad6 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -19,7 +19,7 @@ #include "Emu/CPU/sse2neon.h" #endif -#if defined(_MSC_VER) || !defined(__SSE2__) +#if defined(_MSC_VER) && !defined(__clang__) || !defined(__SSE2__) #define SSE4_1_FUNC #define AVX2_FUNC #define AVX3_FUNC diff --git a/rpcs3/Emu/RSX/Program/ProgramStateCache.cpp b/rpcs3/Emu/RSX/Program/ProgramStateCache.cpp index 5694ebf52f..32476dc62c 100644 --- a/rpcs3/Emu/RSX/Program/ProgramStateCache.cpp +++ b/rpcs3/Emu/RSX/Program/ProgramStateCache.cpp @@ -23,7 +23,6 @@ #endif #endif -//#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(__clang__) #define AVX512_ICL_FUNC #else @@ -33,8 +32,7 @@ using namespace program_hash_util; -//#ifdef ARCH_X64 -#if defined(ARCH_X64) && !(defined(__clang__) && defined(_MSC_VER)) +#ifdef ARCH_X64 AVX512_ICL_FUNC usz get_vertex_program_ucode_hash_512(const RSXVertexProgram &program) { // Load all elements of the instruction_mask bitset @@ -426,8 +424,7 @@ vertex_program_utils::vertex_program_metadata vertex_program_utils::analyse_vert usz vertex_program_storage_hash::operator()(const RSXVertexProgram &program) const { -//#ifdef ARCH_X64 -#if defined(ARCH_X64) && !(defined(__clang__) && defined(_MSC_VER)) +#ifdef ARCH_X64 usz ucode_hash; if (utils::has_avx512_icl()) @@ -452,8 +449,7 @@ usz vertex_program_storage_hash::operator()(const RSXVertexProgram &program) con return rpcs3::hash64(ucode_hash, metadata_hash); } -//#ifdef ARCH_X64 -#if defined(ARCH_X64) && !(defined(__clang__) && defined(_MSC_VER)) +#ifdef ARCH_X64 AVX512_ICL_FUNC bool vertex_program_compare_512(const RSXVertexProgram &binary1, const RSXVertexProgram &binary2) { // Load all elements of the instruction_mask bitset @@ -544,8 +540,7 @@ bool vertex_program_compare::operator()(const RSXVertexProgram &binary1, const R return false; } -//#ifdef ARCH_X64 -#if defined(ARCH_X64) && !(defined(__clang__) && defined(_MSC_VER)) +#ifdef ARCH_X64 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 80d65cffc5..959df17e53 100644 --- a/rpcs3/util/asm.hpp +++ b/rpcs3/util/asm.hpp @@ -46,7 +46,7 @@ namespace utils for (auto stamp0 = get_tsc(), stamp1 = stamp0; g_use_rtm && stamp1 - stamp0 <= g_rtm_tx_limit1; stamp1 = get_tsc()) { -#ifndef _MSC_VER +#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) __asm__ goto ("xbegin %l[retry];" ::: "memory" : retry); #else status = _xbegin(); @@ -60,7 +60,7 @@ namespace utils if constexpr (std::is_void_v) { std::invoke(op); -#ifndef _MSC_VER +#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) __asm__ volatile ("xend;" ::: "memory"); #else _xend(); @@ -70,7 +70,7 @@ namespace utils else { auto result = std::invoke(op); -#ifndef _MSC_VER +#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) __asm__ volatile ("xend;" ::: "memory"); #else _xend(); diff --git a/rpcs3/util/sysinfo.cpp b/rpcs3/util/sysinfo.cpp index 52bb6f27b0..f7cb7b00cf 100755 --- a/rpcs3/util/sysinfo.cpp +++ b/rpcs3/util/sysinfo.cpp @@ -46,7 +46,7 @@ static inline std::array get_cpuid(u32 func, u32 subfunc) static inline u64 get_xgetbv(u32 xcr) { -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) return _xgetbv(xcr); #else u32 eax, edx; diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000000..9b5d53aaae --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,24 @@ +{ + "name": "rpcs3", + "version-string": "1.0", + "builtin-baseline": "b94ab47c998b93fe72b0f501eaac70f96328019e", + "dependencies": [ + { + "name": "ffmpeg", + "features": [ + "avcodec", + "avformat", + "swscale", + "swresample" + ] + }, + "libpng", + "opencv", + "qtbase", + "qtmultimedia", + "qtsvg", + "qttools", + "vulkan", + "zlib" + ] +} From 1e46b9e06404a54d9f6b8ee54fba86f5238da5fe Mon Sep 17 00:00:00 2001 From: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com> Date: Fri, 14 Nov 2025 15:32:46 -0800 Subject: [PATCH 09/12] remove homebrew ccache Installs fmt 12 as dep. Interferes with OpenAL-soft. --- .ci/build-mac-arm64.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.ci/build-mac-arm64.sh b/.ci/build-mac-arm64.sh index 4d46cac7ef..b69c634f48 100755 --- a/.ci/build-mac-arm64.sh +++ b/.ci/build-mac-arm64.sh @@ -6,7 +6,7 @@ export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 export HOMEBREW_NO_ENV_HINTS=1 export HOMEBREW_NO_INSTALL_CLEANUP=1 -brew install -f --overwrite --quiet ccache pipenv googletest ffmpeg@5 "llvm@$LLVM_COMPILER_VER" glew sdl3 vulkan-headers +brew install -f --overwrite --quiet 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.4.0 release @@ -27,6 +27,11 @@ export CMAKE_EXTRA_OPTS='-DLLVM_TARGETS_TO_BUILD=arm64' export WORKDIR; WORKDIR="$(pwd)" +# Setup ccache +if [ ! -d "$CCACHE_DIR" ]; then + mkdir -p "$CCACHE_DIR" +fi + # Get Qt if [ ! -d "/tmp/Qt/$QT_VER" ]; then mkdir -p "/tmp/Qt" From 390bc9a04d9084a8973a642d473fed5ff95ec31d Mon Sep 17 00:00:00 2001 From: Live session user Date: Sun, 16 Nov 2025 05:25:55 -0800 Subject: [PATCH 10/12] modify workflow --- .github/workflows/rpcs3.yml | 91 ++++++++++++++++-------- 3rdparty/libusb/config.cmake | 8 +-- buildfiles/cmake/ConfigureCompiler.cmake | 2 - rpcs3/Emu/Memory/vm_reservation.h | 2 +- rpcs3/util/asm.hpp | 2 +- 5 files changed, 66 insertions(+), 39 deletions(-) diff --git a/.github/workflows/rpcs3.yml b/.github/workflows/rpcs3.yml index a12bae0db7..fe7078939d 100644 --- a/.github/workflows/rpcs3.yml +++ b/.github/workflows/rpcs3.yml @@ -325,28 +325,20 @@ jobs: path: ${{ env.DEPS_CACHE_DIR }} key: ${{ steps.restore-dependencies-cache.outputs.cache-primary-key }} - Windows_Build_Clang: + + Windows_Build_MSYS2: # 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') runs-on: windows-2025 strategy: - fail-fast: false matrix: include: - msys2: clang64 compiler: clang arch: win64 - - compiler: clang-cl - llvmver: 19.1.7 - arch: win64 - env: CCACHE_DIR: 'C:\ccache' - VCPKG_TRIPLET: x64-windows - VCPKG_BUILD_TYPE: release - VCPKG_ROOT: "${{github.workspace}}/vcpkg" - VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite' - name: RPCS3 Windows ${{ matrix.compiler }} + name: RPCS3 Windows Clang (MSYS2) steps: - name: Checkout repository uses: actions/checkout@main @@ -355,7 +347,6 @@ jobs: - name: Setup msys2 uses: msys2/setup-msys2@v2 - if: ${{ matrix.compiler == 'clang' }} with: msystem: ${{ matrix.msys2 }} update: true @@ -383,16 +374,69 @@ jobs: git p7zip + - name: Restore build Ccache + uses: actions/cache/restore@main + id: restore-build-ccache + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ runner.arch }}-${{ github.run_id }} + restore-keys: ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ runner.arch }}- + + - name: Build RPCS3 + 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: Save build Ccache + 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: Upload artifacts + uses: actions/upload-artifact@main + with: + name: RPCS3 for Windows (${{ runner.arch }}, ${{ matrix.compiler }}) + path: ${{ env.BUILD_ARTIFACTSTAGINGDIRECTORY }} + compression-level: 0 + if-no-files-found: error + + Windows_Build_CLANG-CL: + # 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') + runs-on: windows-2025 + strategy: + fail-fast: false + matrix: + include: + - compiler: clang-cl + llvmver: 19.1.7 + arch: win64 + + env: + CCACHE_DIR: 'C:\ccache' + VCPKG_TRIPLET: x64-windows + VCPKG_BUILD_TYPE: release + VCPKG_ROOT: "${{github.workspace}}/vcpkg" + VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite' + name: RPCS3 Windows Clang (Clang-CL) + steps: + - name: Checkout repository + uses: actions/checkout@main + with: + fetch-depth: 0 + - 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: 'Setup NuGet Credentials for vcpkg' - if: ${{ matrix.compiler == 'clang-cl' }} - shell: 'bash' run: | `./vcpkg/vcpkg fetch nuget | tail -n 1` \ sources add \ @@ -406,7 +450,6 @@ jobs: -source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" - name: Restore LLVM Cache - if: ${{ matrix.compiler == 'clang-cl' }} uses: actions/cache/restore@main id: llvm-cache with: @@ -415,7 +458,6 @@ jobs: 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 }}\)) { @@ -432,7 +474,7 @@ jobs: Add-Content -Path $env:GITHUB_PATH -Value "D:\a\rpcs3\rpcs3\llvm-${{ matrix.llvmver }}\bin" - name: Save LLVM Cache - if: ${{ github.ref == 'refs/heads/master' && matrix.compiler == 'clang-cl' }} + if: ${{ github.ref == 'refs/heads/master' }} uses: actions/cache/save@main with: path: ./llvm-${{ matrix.llvmver }} @@ -446,26 +488,13 @@ jobs: key: ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ runner.arch }}-${{ github.run_id }} 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/build-windows-clang.sh - .ci/setup-windows-ci-vars.sh ${{ matrix.arch }} ${{ matrix.compiler }} - .ci/deploy-windows-${{ matrix.compiler }}.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" "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 - name: Build RPCS3 - if: ${{ matrix.compiler == 'clang-cl' }} - shell: bash run: | .ci/build-windows-clang-cl.sh .ci/setup-windows-ci-vars.sh ${{ matrix.arch }} ${{ matrix.compiler }} diff --git a/3rdparty/libusb/config.cmake b/3rdparty/libusb/config.cmake index 4349b86262..8166c1773e 100644 --- a/3rdparty/libusb/config.cmake +++ b/3rdparty/libusb/config.cmake @@ -34,10 +34,10 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") elseif(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") - append_compiler_flags( - -Wno-unused-value - -Wno-pragma-pack - ${ADDITIONAL_CC_FLAGS} + append_compiler_flags( + -Wno-unused-value + -Wno-pragma-pack + ${ADDITIONAL_CC_FLAGS} ) endif() endif() diff --git a/buildfiles/cmake/ConfigureCompiler.cmake b/buildfiles/cmake/ConfigureCompiler.cmake index 1c1ba7139a..1685e4d13e 100644 --- a/buildfiles/cmake/ConfigureCompiler.cmake +++ b/buildfiles/cmake/ConfigureCompiler.cmake @@ -10,10 +10,8 @@ if(MSVC) 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 diff --git a/rpcs3/Emu/Memory/vm_reservation.h b/rpcs3/Emu/Memory/vm_reservation.h index 53e2453292..1085307f79 100644 --- a/rpcs3/Emu/Memory/vm_reservation.h +++ b/rpcs3/Emu/Memory/vm_reservation.h @@ -171,7 +171,7 @@ namespace vm auto stamp0 = utils::get_tsc(), stamp1 = stamp0, stamp2 = stamp0; -#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) +#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) __asm__ goto ("xbegin %l[stage2];" ::: "memory" : stage2); #else status = _xbegin(); diff --git a/rpcs3/util/asm.hpp b/rpcs3/util/asm.hpp index 959df17e53..6286fcb23d 100644 --- a/rpcs3/util/asm.hpp +++ b/rpcs3/util/asm.hpp @@ -70,7 +70,7 @@ namespace utils else { auto result = std::invoke(op); -#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) +#if !defined(_MSC_VER) || (defined(__clang__) && defined(_MSC_VER)) __asm__ volatile ("xend;" ::: "memory"); #else _xend(); From 032714ccd1ca340eed7bb3fd24be47cf6530e859 Mon Sep 17 00:00:00 2001 From: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com> Date: Sat, 22 Nov 2025 09:49:36 -0800 Subject: [PATCH 11/12] package: write --- .github/workflows/rpcs3.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/rpcs3.yml b/.github/workflows/rpcs3.yml index 234f8f8104..8cf871a8f4 100644 --- a/.github/workflows/rpcs3.yml +++ b/.github/workflows/rpcs3.yml @@ -10,6 +10,9 @@ on: pull_request: workflow_dispatch: +permissions: + packages: write + concurrency: group: ${{ github.ref }}-${{ github.event_name }} cancel-in-progress: true From 79f0caf7de6d2b42ffdfbd8c51f13394b06e4c61 Mon Sep 17 00:00:00 2001 From: Live session user Date: Thu, 27 Nov 2025 06:00:51 -0800 Subject: [PATCH 12/12] popcount --- .ci/build-mac-arm64.sh | 6 +++--- Utilities/StrFmt.h | 4 ++-- rpcs3/util/asm.hpp | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.ci/build-mac-arm64.sh b/.ci/build-mac-arm64.sh index b69c634f48..4af777f758 100755 --- a/.ci/build-mac-arm64.sh +++ b/.ci/build-mac-arm64.sh @@ -6,7 +6,7 @@ export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 export HOMEBREW_NO_ENV_HINTS=1 export HOMEBREW_NO_INSTALL_CLEANUP=1 -brew install -f --overwrite --quiet pipenv googletest ffmpeg@5 "llvm@$LLVM_COMPILER_VER" glew sdl3 vulkan-headers +brew install -f --overwrite --quiet pipenv 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.4.0 release @@ -83,8 +83,8 @@ mkdir build && cd build || exit 1 export MACOSX_DEPLOYMENT_TARGET=14.0 "$BREW_PATH/bin/cmake" .. \ - -DBUILD_RPCS3_TESTS="${RUN_UNIT_TESTS}" \ - -DRUN_RPCS3_TESTS="${RUN_UNIT_TESTS}" \ + -DBUILD_RPCS3_TESTS=OFF \ + -DRUN_RPCS3_TESTS=OFF \ -DUSE_SDL=ON \ -DUSE_DISCORD_RPC=ON \ -DUSE_VULKAN=ON \ diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 6d9ea05c9e..a984ebe212 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -393,8 +393,8 @@ namespace fmt raw_throw_exception(src_loc, reinterpret_cast(fmt), type_info_v, fmt_args_t{fmt_unveil::get(args)...}); } -#if !defined(_MSC_VER) || defined(__clang__) - [[noreturn]] ~throw_exception() = default; +#if defined(__FreeBSD__) + [[noreturn]] ~throw_exception(); #endif }; diff --git a/rpcs3/util/asm.hpp b/rpcs3/util/asm.hpp index 5fa4ba58d2..da3d7dac95 100644 --- a/rpcs3/util/asm.hpp +++ b/rpcs3/util/asm.hpp @@ -69,7 +69,9 @@ namespace utils #if defined(_MSC_VER) && !defined(__clang__) return std::popcount(v.lo) + std::popcount(v.hi); #else - return std::popcount(v); + const u64 lo = static_cast(v); + const u64 hi = static_cast(v >> 64); + return static_cast(std::popcount(lo) + std::popcount(hi)); #endif } @@ -156,7 +158,11 @@ namespace utils else return std::countr_zero(arg.lo); #else - return std::countr_zero(arg); + const u64 hi = static_cast(arg >> 64); + if (hi != 0) + return static_cast(std::countr_zero(hi)); + const u64 lo = static_cast(arg); + return static_cast(std::countr_zero(lo) + 64u); #endif } @@ -168,7 +174,11 @@ namespace utils else return std::countl_zero(arg.lo) + 64; #else - return std::countl_zero(arg); + const u64 hi = static_cast(arg >> 64); + if (hi != 0) + return static_cast(std::countl_zero(hi)); + const u64 lo = static_cast(arg); + return static_cast(std::countl_zero(lo) + 64u); #endif }