From ebecdd3a7458dd5a353524dc161f4050d019b7be Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 12 Jun 2022 17:14:27 -0400 Subject: general: fix compilation on MinGW GCC 12 --- externals/CMakeLists.txt | 5 +++++ src/core/loader/nso.cpp | 9 ++++----- src/video_core/macro/macro_jit_x64.cpp | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 64361de5f..bd01f4c4d 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -40,6 +40,11 @@ target_include_directories(mbedtls PUBLIC ./mbedtls/include) add_library(microprofile INTERFACE) target_include_directories(microprofile INTERFACE ./microprofile) +# GCC bugs +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND MINGW) + target_compile_options(microprofile INTERFACE "-Wno-array-bounds") +endif() + # libusb if (NOT LIBUSB_FOUND OR YUZU_USE_BUNDLED_LIBUSB) add_subdirectory(libusb) diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 8a938aa83..8dd956fc6 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp @@ -128,11 +128,10 @@ std::optional AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core:: // Apply patches if necessary if (pm && (pm->HasNSOPatch(nso_header.build_id) || Settings::values.dump_nso)) { - std::vector pi_header; - pi_header.insert(pi_header.begin(), reinterpret_cast(&nso_header), - reinterpret_cast(&nso_header) + sizeof(NSOHeader)); - pi_header.insert(pi_header.begin() + sizeof(NSOHeader), program_image.data(), - program_image.data() + program_image.size()); + std::vector pi_header(sizeof(NSOHeader) + program_image.size()); + std::memcpy(pi_header.data(), &nso_header, sizeof(NSOHeader)); + std::memcpy(pi_header.data() + sizeof(NSOHeader), program_image.data(), + program_image.size()); pi_header = pm->PatchNSO(pi_header, nso_file.GetName()); diff --git a/src/video_core/macro/macro_jit_x64.cpp b/src/video_core/macro/macro_jit_x64.cpp index dc5376501..aca25d902 100644 --- a/src/video_core/macro/macro_jit_x64.cpp +++ b/src/video_core/macro/macro_jit_x64.cpp @@ -411,7 +411,7 @@ void MacroJITx64Impl::Compile_Branch(Macro::Opcode opcode) { Xbyak::Label end; auto value = Compile_GetRegister(opcode.src_a, eax); - test(value, value); + cmp(value, 0); // test(value, value); if (optimizer.has_delayed_pc) { switch (opcode.branch_condition) { case Macro::BranchCondition::Zero: -- cgit v1.2.3