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.
This commit is contained in:
oltolm 2026-05-09 07:36:55 +02:00 committed by GitHub
parent 7132795b7a
commit 442a07a707
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 5 deletions

View File

@ -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 $<$<CXX_COMPILER_ID:Clang>:-Wno-error=unused-command-line-argument>)
endif()
# half

View File

@ -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)

View File

@ -3,6 +3,8 @@
#pragma once
#include <magic_enum/magic_enum.hpp>
#include "common/enum.h"
#include "common/types.h"
@ -2696,3 +2698,9 @@ struct SendMsgSimm {
};
} // namespace Shader::Gcn
template <>
struct magic_enum::customize::enum_range<Shader::Gcn::Opcode> {
static constexpr int min = static_cast<int>(Shader::Gcn::Opcode::S_ADD_U32);
static constexpr int max = static_cast<int>(Shader::Gcn::Opcode::V_MAD_MIXHI_F16);
};

View File

@ -17,8 +17,6 @@
#include "video_core/amdgpu/resource.h"
#include <numbers>
#define MAGIC_ENUM_RANGE_MIN 0
#define MAGIC_ENUM_RANGE_MAX 2143
#include <magic_enum/magic_enum.hpp>
namespace Shader::Gcn {