Skip to content

Windows clang -- proof-of-concept#17579

Open
qurious-pixel wants to merge 45 commits intoRPCS3:masterfrom
qurious-pixel:windows-clang
Open

Windows clang -- proof-of-concept#17579
qurious-pixel wants to merge 45 commits intoRPCS3:masterfrom
qurious-pixel:windows-clang

Conversation

@qurious-pixel
Copy link
Copy Markdown
Contributor

@qurious-pixel qurious-pixel commented Oct 13, 2025

Built with PRs from:

#17552
#17401
#17017

#17372

Todo:
silence warning for:

  • asmjit [ -Wdeprecated-anon-enum-enum-conversion ]

  • yaml-cpp [ -Wignored-attributes ]

  • libusb [ -Wunused-value ]

  • cubeb [ -Wdeprecated-declarations ]

  • Remove workaround for AVX512 with Windows Clang-Cl

  • Fix breakage from Enable ASLR #16878

EDIT: With VCPKG cache, clang-cl build completes in ~14mins. Without cache, ~3 hours.

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$<$<CONFIG:Release>: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 $<TARGET_FILE:rpcs3>

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
@AniLeo AniLeo requested a review from hcorion October 13, 2025 23:08
Comment thread .ci/build-windows-clang.sh Outdated
Comment thread .ci/build-windows-clang-cl.ps1 Outdated
Comment thread .github/workflows/rpcs3.yml Outdated
Comment thread .github/workflows/rpcs3.yml Outdated
Comment thread .github/workflows/rpcs3.yml Outdated
Comment thread .github/workflows/rpcs3.yml Outdated
Comment thread 3rdparty/zstd/CMakeLists.txt Outdated
Comment thread rpcs3/Emu/CMakeLists.txt Outdated
Comment thread rpcs3/Emu/RSX/Program/ProgramStateCache.cpp
Comment thread buildfiles/cmake/ConfigureCompiler.cmake Outdated
@hcorion
Copy link
Copy Markdown
Member

hcorion commented Oct 14, 2025

Please write the script in shell script instead of Powershell.

@Megamouse
Copy link
Copy Markdown
Contributor

Please write the script in shell script instead of Powershell.

There was a GitHub runner issue with the env if you use a shell script.
That's why I wrote it in Powershell.
I believe it was something with shell running in a separate instance

@hcorion
Copy link
Copy Markdown
Member

hcorion commented Oct 14, 2025

All our other Windows builds use shell script, what makes this one not work? It makes it significantly more annoying to maintain if it's in a different language

Comment thread .github/workflows/rpcs3.yml Outdated
Comment thread .github/workflows/rpcs3.yml Outdated
if: ${{ matrix.compiler == 'clang-cl' }}
shell: pwsh
run: |
if (!(Test-Path -Path D:\a\rpcs3\rpcs3\llvm-${{ matrix.llvmver }}\)) {
Copy link
Copy Markdown
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

@Megamouse
Copy link
Copy Markdown
Contributor

All our other Windows builds use shell script, what makes this one not work? It makes it significantly more annoying to maintain if it's in a different language

I believe it's related to the bat file, which doesn't work with a shell script

@qurious-pixel
Copy link
Copy Markdown
Contributor Author

I don't think this is ready to merge as-is, since I am not the author of the respective PR's, but wanted to get feedback/reviews to move the work forward.

@Megamouse Megamouse marked this pull request as draft October 15, 2025 17:21
Comment thread 3rdparty/zstd/CMakeLists.txt Outdated
@Megamouse Megamouse added OS: Windows Build and CI Anything related to the build process and continuous integration labels Oct 17, 2025
Comment thread rpcs3/rpcs3qt/CMakeLists.txt
Comment thread .github/workflows/rpcs3.yml Outdated
curl -fsSL 'https://rpcs3.net/compatibility?api=v1&export' | iconv -t UTF-8 1> ./bin/GuiConfigs/compat_database.dat

# Set Qt plugin & translation path
cp D:/a/rpcs3/rpcs3/rpcs3/qt/etc/qt.conf ./bin/qt.conf
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The vcpkg setup differs wildly from clang setup. so copying in the qt.conf maintains the path <folder_root>/qt6/translations, or else, need to embed a separate qt.conf that requests the actual path <folder_root>/translations/Qt6/. This is set by winqtdeploy and the layout from Qt relative to qmake.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But we already embed the qt.conf in cmake.
I know it didn't actually work, but maybe it's just missing something else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

windeployqt is overriding. Not needed if translations are found in this folder: <folder_root>/translations/Qt6/
I will see if I can manipulate the vcpkg path to match MSVC and Clang.

Comment thread .github/workflows/rpcs3.yml
@kd-11
Copy link
Copy Markdown
Contributor

kd-11 commented Jan 12, 2026

Is this ready for testing? I can run it in an azure VM to check if it can load anything.

@qurious-pixel
Copy link
Copy Markdown
Contributor Author

Is this ready for testing? I can run it in an azure VM to check if it can load anything.

Yes, this runs. ironing out the translations.
Uncached vcpkg on dual-core is very slow.

@SomeoneIsWorking
Copy link
Copy Markdown

diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h
index 6d9ea05c9..af5f7d7bd 100644
--- a/Utilities/StrFmt.h
+++ b/Utilities/StrFmt.h
@@ -383,23 +383,10 @@ namespace fmt
 
 	// Throw exception with formatting
 	template <typename CharT, usz N, typename... Args>
-	struct throw_exception
+	[[noreturn]] FORCE_INLINE SAFE_BUFFERS(void) throw_exception(const CharT(&fmt)[N], const Args&... args)
 	{
-		struct args_break_t {};
-
-		[[noreturn]] FORCE_INLINE SAFE_BUFFERS() throw_exception(const CharT(&fmt)[N], const Args&... args,
-			args_break_t = args_break_t{}, std::source_location src_loc = std::source_location::current())
-		{
-			raw_throw_exception(src_loc, reinterpret_cast<const char*>(fmt), type_info_v<Args...>, fmt_args_t<Args...>{fmt_unveil<Args>::get(args)...});
-		}
-
-#if !defined(_MSC_VER) || defined(__clang__)
-		[[noreturn]] ~throw_exception() = default;
-#endif
-	};
-
-	template <typename CharT, usz N, typename... Args>
-	throw_exception(const CharT(&)[N], const Args&...) -> throw_exception<CharT, N, Args...>;
+		raw_throw_exception(std::source_location::current(), reinterpret_cast<const char*>(fmt), type_info_v<Args...>, fmt_args_t<Args...>{fmt_unveil<Args>::get(args)...});
+	}
 
 	// Helper template: pack format variables
 	template <typename Arg = void, typename... Args>

I need to do this to compile with macOS clang from CommandLineTools. No idea why it is doing that.

@SomeoneIsWorking
Copy link
Copy Markdown

It looks like CI build failed due to protobuf, which happens to me a lot.

diff --git a/cmake/protobuf-configure-target.cmake b/cmake/protobuf-configure-target.cmake
index c67c570..425a5af 100644
--- a/cmake/protobuf-configure-target.cmake
+++ b/cmake/protobuf-configure-target.cmake
@@ -8,7 +8,7 @@
 # Refactors configuration options set on all Protobuf targets
 function(protobuf_configure_target target)
     if(protobuf_LINK_LIBATOMIC)
-        target_link_libraries(libprotobuf PRIVATE atomic)
+        target_link_libraries("${target}" PRIVATE atomic)
     endif()
 
     target_compile_features("${target}" PUBLIC cxx_std_17)

I do this when it happens. I don't know what it is about.

@Megamouse Megamouse marked this pull request as ready for review February 28, 2026 10:36
@Megamouse
Copy link
Copy Markdown
Contributor

@qurious-pixel please rebase. We have conflicts yet again.
I'll try to merge this. I don't see a point of keeping this in limbo just because there are some quirks with translations.

@Megamouse
Copy link
Copy Markdown
Contributor

@qurious-pixel please rebase properly xD

@qurious-pixel
Copy link
Copy Markdown
Contributor Author

@qurious-pixel please rebase properly xD

The openAL submodule was causing some issues. Will go again at the rebase.

@digant73
Copy link
Copy Markdown
Contributor

digant73 commented Apr 9, 2026

@qurious-pixel I see the presence of 2 .lib on rpcs3 main folder:

  • libprotobuf.lib
  • libutf8_validity.lib

There are also the .dll. I suppose the .lib are not necessary, right? Although I would always prefer to link static lib instead of providing .dll

However, when clicking on rpcs3.exe the emulator is not started at all

@qurious-pixel
Copy link
Copy Markdown
Contributor Author

... when clicking on rpcs3.exe the emulator is not started at all

@digant73, I am getting the same failure to start on this build. On my personal build which I tested the Wolfssl changes, starts normally. Will have to continue to bisect

41b224d should also start normally.

@qurious-pixel
Copy link
Copy Markdown
Contributor Author

@qurious-pixel I see the presence of 2 .lib on rpcs3 main folder:

  • libprotobuf.lib
  • libutf8_validity.lib

There are also the .dll. I suppose the .lib are not necessary, right? Although I would always prefer to link static lib instead of providing .dll

However, when clicking on rpcs3.exe the emulator is not started at all

@digant73 can you check the latest build. Seems to run, even when removing the static libs you mentioned.

@digant73
Copy link
Copy Markdown
Contributor

rpcs3 starts but no game boots

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build and CI Anything related to the build process and continuous integration OS: Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants