From 442a07a707bcb2864ecf23a766971923ee227c74 Mon Sep 17 00:00:00 2001 From: oltolm Date: Sat, 9 May 2026 07:36:55 +0200 Subject: [PATCH] Fix compilation with mingw-w64 (#4365) * cmake: apply sirit unused-command-line-argument flag only with Clang * shader_recompiler: move Opcode magic_enum range customization to opcodes.h Define the magic_enum range for Shader::Gcn::Opcode as a proper enum_range specialization in opcodes.h instead of relying on translation-unit macros in translate.cpp. This makes the customization visible where the enum is used and avoids the GCC linkage/build issue. * thread: use Windows thread naming path for MinGW-w64 Switch the thread naming guard from _MSC_VER to _WIN32 so MinGW-w64 builds use the Windows SetThreadDescription implementation instead of falling through the POSIX branch. This matches the platform rather than the compiler and avoids the MinGW-w64 build issue. --- externals/CMakeLists.txt | 2 +- src/common/thread.cpp | 4 ++-- src/shader_recompiler/frontend/opcodes.h | 8 ++++++++ src/shader_recompiler/frontend/translate/translate.cpp | 2 -- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index ea2772dd7..ed5e903fa 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -149,7 +149,7 @@ endif() # sirit add_subdirectory(sirit) if (WIN32) - target_compile_options(sirit PRIVATE "-Wno-error=unused-command-line-argument") + target_compile_options(sirit PRIVATE $<$:-Wno-error=unused-command-line-argument>) endif() # half diff --git a/src/common/thread.cpp b/src/common/thread.cpp index e56953fb6..7cc54821f 100644 --- a/src/common/thread.cpp +++ b/src/common/thread.cpp @@ -170,7 +170,7 @@ bool AccurateSleep(const std::chrono::nanoseconds duration, std::chrono::nanosec #endif -#ifdef _MSC_VER +#ifdef _WIN32 // Sets the debugger-visible name of the current thread. void SetCurrentThreadName(const char* name) { @@ -184,7 +184,7 @@ void SetThreadName(void* thread, const char* name) { SetThreadDescription(thread, UTF8ToUTF16W(name).data()); } -#else // !MSVC_VER, so must be POSIX threads +#else // !_WIN32, so must be POSIX threads // MinGW with the POSIX threading model does not support pthread_setname_np #if !defined(_WIN32) || defined(_MSC_VER) diff --git a/src/shader_recompiler/frontend/opcodes.h b/src/shader_recompiler/frontend/opcodes.h index 4e538f247..afe0a500d 100644 --- a/src/shader_recompiler/frontend/opcodes.h +++ b/src/shader_recompiler/frontend/opcodes.h @@ -3,6 +3,8 @@ #pragma once +#include + #include "common/enum.h" #include "common/types.h" @@ -2696,3 +2698,9 @@ struct SendMsgSimm { }; } // namespace Shader::Gcn + +template <> +struct magic_enum::customize::enum_range { + static constexpr int min = static_cast(Shader::Gcn::Opcode::S_ADD_U32); + static constexpr int max = static_cast(Shader::Gcn::Opcode::V_MAD_MIXHI_F16); +}; diff --git a/src/shader_recompiler/frontend/translate/translate.cpp b/src/shader_recompiler/frontend/translate/translate.cpp index 346553263..49ec9638d 100644 --- a/src/shader_recompiler/frontend/translate/translate.cpp +++ b/src/shader_recompiler/frontend/translate/translate.cpp @@ -17,8 +17,6 @@ #include "video_core/amdgpu/resource.h" #include -#define MAGIC_ENUM_RANGE_MIN 0 -#define MAGIC_ENUM_RANGE_MAX 2143 #include namespace Shader::Gcn {