From 1938385bf058caf030292b48a468368f0264b806 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 7 Jun 2025 16:29:45 -0400 Subject: [PATCH] build(windows): fix gcc15 compatibility (#3946) --- .github/workflows/CI.yml | 71 +++++++++++++++---------- cmake/compile_definitions/windows.cmake | 4 ++ tools/CMakeLists.txt | 1 + tools/audio.cpp | 12 +++-- 4 files changed, 55 insertions(+), 33 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9df09f6d..418e3133 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -864,48 +864,61 @@ jobs: - name: Update Windows dependencies env: - gcc_version: "14.2.0-3" + MSYSTEM: "ucrt64" + TOOLCHAIN: "ucrt-x86_64" shell: msys2 {0} run: | - broken_deps=( - "mingw-w64-ucrt-x86_64-gcc" - "mingw-w64-ucrt-x86_64-gcc-libs" + # variables + declare -A pinned_deps + + # dependencies + dependencies=( + "git" + "mingw-w64-${TOOLCHAIN}-cmake" + "mingw-w64-${TOOLCHAIN}-cppwinrt" + "mingw-w64-${TOOLCHAIN}-curl-winssl" + "mingw-w64-${TOOLCHAIN}-gcc" + "mingw-w64-${TOOLCHAIN}-graphviz" + "mingw-w64-${TOOLCHAIN}-MinHook" + "mingw-w64-${TOOLCHAIN}-miniupnpc" + "mingw-w64-${TOOLCHAIN}-nlohmann-json" + "mingw-w64-${TOOLCHAIN}-nodejs" + "mingw-w64-${TOOLCHAIN}-nsis" + "mingw-w64-${TOOLCHAIN}-onevpl" + "mingw-w64-${TOOLCHAIN}-openssl" + "mingw-w64-${TOOLCHAIN}-opus" + "mingw-w64-${TOOLCHAIN}-toolchain" ) - tarballs="" - for dep in "${broken_deps[@]}"; do - tarball="${dep}-${gcc_version}-any.pkg.tar.zst" + # do not modify below this line - # download and install working version - wget https://repo.msys2.org/mingw/ucrt64/${tarball} + ignore_packages=() + tarballs="" + for pkg in "${!pinned_deps[@]}"; do + ignore_packages+=("${pkg}") + version="${pinned_deps[$pkg]}" + tarball="${pkg}-${version}-any.pkg.tar.zst" + + # download working version + wget "https://repo.msys2.org/mingw/${MSYSTEM}/${tarball}" tarballs="${tarballs} ${tarball}" done - # install broken dependencies + # Create the ignore string for pacman + ignore_list=$(IFS=,; echo "${ignore_packages[*]}") + + # install pinned dependencies if [ -n "$tarballs" ]; then pacman -U --noconfirm ${tarballs} fi - # install dependencies - dependencies=( - "git" - "mingw-w64-ucrt-x86_64-cmake" - "mingw-w64-ucrt-x86_64-cppwinrt" - "mingw-w64-ucrt-x86_64-curl-winssl" - "mingw-w64-ucrt-x86_64-graphviz" - "mingw-w64-ucrt-x86_64-MinHook" - "mingw-w64-ucrt-x86_64-miniupnpc" - "mingw-w64-ucrt-x86_64-nlohmann-json" - "mingw-w64-ucrt-x86_64-nodejs" - "mingw-w64-ucrt-x86_64-nsis" - "mingw-w64-ucrt-x86_64-onevpl" - "mingw-w64-ucrt-x86_64-openssl" - "mingw-w64-ucrt-x86_64-opus" - "mingw-w64-ucrt-x86_64-toolchain" - ) - - pacman -Syu --noconfirm --ignore="$(IFS=,; echo "${broken_deps[*]}")" "${dependencies[@]}" + # Only add --ignore if we have packages to ignore + if [ -n "$ignore_list" ]; then + pacman -Syu --noconfirm --ignore="${ignore_list}" "${dependencies[@]}" + else + pacman -Syu --noconfirm "${dependencies[@]}" + fi - name: Install Doxygen # GCC compiled doxygen has issues when running graphviz diff --git a/cmake/compile_definitions/windows.cmake b/cmake/compile_definitions/windows.cmake index a3009be0..d40fb0fa 100644 --- a/cmake/compile_definitions/windows.cmake +++ b/cmake/compile_definitions/windows.cmake @@ -9,6 +9,10 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") # gcc complains about misleading indentation in some mingw includes list(APPEND SUNSHINE_COMPILE_OPTIONS -Wno-misleading-indentation) +# gcc15 complains about non-template type 'coroutine_handle' used as a template in Windows.Foundation.h +# can remove after https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120495 is available in mingw-w64 +list(APPEND SUNSHINE_COMPILE_OPTIONS -Wno-template-body) + # see gcc bug 98723 add_definitions(-DUSE_BOOST_REGEX) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 8d4c08e3..59651565 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -15,6 +15,7 @@ target_compile_options(dxgi-info PRIVATE ${SUNSHINE_COMPILE_OPTIONS}) add_executable(audio-info audio.cpp) set_target_properties(audio-info PROPERTIES CXX_STANDARD 20) target_link_libraries(audio-info + ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ksuser ${PLATFORM_LIBRARIES}) diff --git a/tools/audio.cpp b/tools/audio.cpp index 2fe4a7eb..c5ca506f 100644 --- a/tools/audio.cpp +++ b/tools/audio.cpp @@ -3,8 +3,8 @@ * @brief Handles collecting audio device information from Windows. */ #define INITGUID -#include "src/utility.h" +// platform includes #include #include #include @@ -13,6 +13,12 @@ #include #include +// lib includes +#include + +// local includes +#include "src/utility.h" + DEFINE_PROPERTYKEY(PKEY_Device_DeviceDesc, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 2); // DEVPROP_TYPE_STRING DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14); // DEVPROP_TYPE_STRING DEFINE_PROPERTYKEY(PKEY_DeviceInterface_FriendlyName, 0x026e516e, 0xb814, 0x414b, 0x83, 0xcd, 0x85, 0x6d, 0x6f, 0xef, 0x48, 0x22, 2); @@ -44,8 +50,6 @@ namespace audio { using handle_t = util::safe_ptr_v2; - static std::wstring_convert, wchar_t> converter; - class prop_var_t { public: prop_var_t() { @@ -204,7 +208,7 @@ namespace audio { // so we can take the first match as the current format to display. auto audio_client = make_audio_client(device, format); if (audio_client) { - current_format = converter.from_bytes(format.name.data()); + current_format = boost::locale::conv::utf_to_utf(format.name.data()); break; } }