Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .ci/build-windows-clang-cl.sh
Original file line number Diff line number Diff line change
@@ -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)"
2 changes: 1 addition & 1 deletion .ci/build-windows-clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,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
42 changes: 42 additions & 0 deletions .ci/deploy-windows-clang-cl.sh
Original file line number Diff line number Diff line change
@@ -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"
107 changes: 103 additions & 4 deletions .github/workflows/rpcs3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -328,24 +328,31 @@ 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
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
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
Expand Down Expand Up @@ -373,6 +380,81 @@ 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/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: ${{ 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 }}

- 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 }}\)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comment for this section

rm -r llvm-*
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
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: ${{ 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
Expand All @@ -382,12 +464,29 @@ 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
.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 }}
.ci/deploy-windows-${{ matrix.compiler }}.sh

- name: Save build Ccache
if: github.ref == 'refs/heads/master'
Expand All @@ -405,7 +504,7 @@ jobs:
if-no-files-found: error

FreeBSD_Build:
# Only run push event on master branch of main repo, but run all PRs
# 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 FreeBSD
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions 3rdparty/OpenAL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/OpenAL/openal-soft
Submodule openal-soft updated 382 files
6 changes: 3 additions & 3 deletions 3rdparty/OpenAL/openal-soft.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
<PropertyGroup Label="UserMacros">
<CmakeReleaseCLI>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"
</CmakeReleaseCLI>
<CmakeDebugCLI>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"
</CmakeDebugCLI>
<CmakeCopyCLI>
echo Copying..
Expand Down Expand Up @@ -106,4 +106,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion 3rdparty/llvm/llvm_build_clang_cl.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
16 changes: 14 additions & 2 deletions 3rdparty/wolfssl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 0 additions & 1 deletion 3rdparty/zstd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ else()
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)
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,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)
Expand Down
2 changes: 1 addition & 1 deletion Utilities/StrFmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ void fmt_class_string<u128>::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<u64>(num >> 64), static_cast<u64>(num));
Expand Down
Loading