Allow Yuzu to be built using Clang-CL for better compiler optimizations for Windows

Also updates Boost to 1.88.0
This commit is contained in:
spectranator
2025-04-12 18:44:18 +02:00
parent 709f70a3b2
commit a640bbee41
49 changed files with 349 additions and 199 deletions

View File

@@ -110,11 +110,17 @@ else()
add_compile_options(
-fwrapv
-Werror=all
-Werror=extra
-Werror=missing-declarations
-Werror=shadow
-Werror=unused
# These cause issues with Boost, let's just set them to regular warnings instead (for now)
#-Werror=all
#-Werror=extra
#-Werror=missing-declarations
#-Werror=shadow
#-Werror=unused
-Wall
-Wextra
-Wmissing-declarations
-Wshadow
-Wunused
-Wno-attributes
-Wno-invalid-offsetof

View File

@@ -53,7 +53,7 @@ add_library(audio_core STATIC
out/audio_out.h
out/audio_out_system.cpp
out/audio_out_system.h
precompiled_headers.h
precompiled_headers.hpp
renderer/audio_device.cpp
renderer/audio_device.h
renderer/audio_renderer.h
@@ -261,7 +261,7 @@ if (ANDROID)
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(audio_core PRIVATE precompiled_headers.h)
target_precompile_headers(audio_core PRIVATE precompiled_headers.hpp)
endif()
create_target_directory_groups(audio_core)

View File

@@ -3,4 +3,4 @@
#pragma once
#include "common/common_precompiled_headers.h"
#include "common/common_precompiled_headers.hpp"

View File

@@ -34,7 +34,7 @@ add_library(common STATIC
cityhash.cpp
cityhash.h
common_funcs.h
common_precompiled_headers.h
common_precompiled_headers.hpp
common_types.h
concepts.h
container_hash.h
@@ -103,7 +103,7 @@ add_library(common STATIC
param_package.h
parent_of_member.h
point.h
precompiled_headers.h
precompiled_headers.hpp
quaternion.h
range_map.h
range_mutex.h
@@ -260,6 +260,9 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
endif()
target_link_libraries(common PUBLIC Boost::context Boost::headers fmt::fmt microprofile stb::headers Threads::Threads)
if (YUZU_USE_CPM)
target_link_libraries(common PUBLIC Boost::icl)
endif()
target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd LLVM::Demangle)
if (ANDROID)
@@ -268,7 +271,7 @@ if (ANDROID)
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(common PRIVATE precompiled_headers.h)
target_precompile_headers(common PRIVATE precompiled_headers.hpp)
endif()
create_target_directory_groups(common)

View File

@@ -3,4 +3,4 @@
#pragma once
#include "common/common_precompiled_headers.h"
#include "common/common_precompiled_headers.hpp"

View File

@@ -5,7 +5,11 @@
#include <utility>
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(__clang__)
#define MSV_BUT_NOT_CLANG
#endif
#ifdef MSV_BUT_NOT_CLANG
#include <intrin.h>
#pragma intrinsic(__umulh)
#pragma intrinsic(_umul128)
@@ -20,7 +24,7 @@ namespace Common {
// This function multiplies 2 u64 values and divides it by a u64 value.
[[nodiscard]] static inline u64 MultiplyAndDivide64(u64 a, u64 b, u64 d) {
#ifdef _MSC_VER
#ifdef MSV_BUT_NOT_CLANG
u128 r{};
r[0] = _umul128(a, b, &r[1]);
u64 remainder;
@@ -41,7 +45,7 @@ namespace Common {
// This function multiplies 2 u64 values and produces a u128 value;
[[nodiscard]] static inline u128 Multiply64Into128(u64 a, u64 b) {
u128 result;
#ifdef _MSC_VER
#ifdef MSV_BUT_NOT_CLANG
result[0] = _umul128(a, b, &result[1]);
#else
unsigned __int128 tmp = a;

View File

@@ -24,7 +24,7 @@ constexpr auto PauseCycles = 100'000U;
} // Anonymous namespace
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(__clang__)
__forceinline static void TPAUSE() {
static constexpr auto RequestC02State = 0U;
_tpause(RequestC02State, FencedRDTSC() + PauseCycles);

View File

@@ -1133,7 +1133,7 @@ add_library(core STATIC
memory/dmnt_cheat_vm.h
perf_stats.cpp
perf_stats.h
precompiled_headers.h
precompiled_headers.hpp
reporter.cpp
reporter.h
tools/freezer.cpp
@@ -1150,7 +1150,9 @@ if (MSVC)
)
else()
target_compile_options(core PRIVATE
-Werror=conversion
# Currently causes issues with Boost, degrading it to just a warning for now...
#-Werror=conversion
-Wconversion
-Wno-sign-conversion
-Wno-cast-function-type
@@ -1161,6 +1163,9 @@ endif()
target_link_libraries(core PUBLIC common PRIVATE audio_core hid_core network video_core nx_tzdb tz)
target_link_libraries(core PUBLIC Boost::headers PRIVATE fmt::fmt nlohmann_json::nlohmann_json mbedtls RenderDoc::API)
if (YUZU_USE_CPM)
target_link_libraries(core PUBLIC Boost::heap Boost::asio Boost::process Boost::crc)
endif()
if (MINGW)
target_link_libraries(core PRIVATE ${MSWSOCK_LIBRARY})
endif()
@@ -1230,7 +1235,7 @@ else()
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(core PRIVATE precompiled_headers.h)
target_precompile_headers(core PRIVATE precompiled_headers.hpp)
endif()
if (YUZU_ENABLE_LTO)

View File

@@ -6,7 +6,7 @@
#include <thread>
#include <boost/asio.hpp>
#include <boost/process/async_pipe.hpp>
#include <boost/process/v1/async_pipe.hpp>
#include "common/logging/log.h"
#include "common/polyfill_thread.h"
@@ -326,7 +326,7 @@ private:
struct ConnectionState {
boost::asio::ip::tcp::socket client_socket;
boost::process::async_pipe signal_pipe;
boost::process::v1::async_pipe signal_pipe;
SignalInfo info;
Kernel::KScopedAutoObject<Kernel::KThread> active_thread;

View File

@@ -191,12 +191,12 @@ private:
struct VM {
static constexpr u32 YUZU_PAGESIZE{0x1000};
static constexpr u32 PAGE_SIZE_BITS{std::countr_zero(YUZU_PAGESIZE)};
static constexpr u32 PAGE_SIZE_BITS{static_cast<u32>(std::countr_zero(YUZU_PAGESIZE))};
static constexpr u32 SUPPORTED_BIG_PAGE_SIZES{0x30000};
static constexpr u32 DEFAULT_BIG_PAGE_SIZE{0x20000};
u32 big_page_size{DEFAULT_BIG_PAGE_SIZE};
u32 big_page_size_bits{std::countr_zero(DEFAULT_BIG_PAGE_SIZE)};
u32 big_page_size_bits{static_cast<u32>(std::countr_zero(DEFAULT_BIG_PAGE_SIZE))};
static constexpr u32 VA_START_SHIFT{10};
static constexpr u64 DEFAULT_VA_SPLIT{1ULL << 34};

View File

@@ -6,6 +6,6 @@
#include <boost/container/flat_map.hpp> // used by service.h which is heavily included
#include <boost/intrusive/rbtree.hpp> // used by k_auto_object.h which is heavily included
#include "common/common_precompiled_headers.h"
#include "common/common_precompiled_headers.hpp"
#include "core/hle/kernel/k_process.h"

View File

@@ -2,7 +2,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later
add_executable(yuzu-room
precompiled_headers.h
precompiled_headers.hpp
yuzu_room.cpp
yuzu_room.rc
)
@@ -24,7 +24,7 @@ if(UNIX AND NOT APPLE)
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(yuzu-room PRIVATE precompiled_headers.h)
target_precompile_headers(yuzu-room PRIVATE precompiled_headers.hpp)
endif()
create_target_directory_groups(yuzu-room)

View File

@@ -3,4 +3,4 @@
#pragma once
#include "common/common_precompiled_headers.h"
#include "common/common_precompiled_headers.hpp"

View File

@@ -134,7 +134,7 @@ add_library(hid_core STATIC
hid_result.h
hid_types.h
hid_util.h
precompiled_headers.h
precompiled_headers.hpp
resource_manager.cpp
resource_manager.h
)
@@ -160,5 +160,5 @@ create_target_directory_groups(hid_core)
target_link_libraries(hid_core PUBLIC core)
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(hid_core PRIVATE precompiled_headers.h)
target_precompile_headers(hid_core PRIVATE precompiled_headers.hpp)
endif()

View File

@@ -3,4 +3,4 @@
#pragma once
#include "common/common_precompiled_headers.h"
#include "common/common_precompiled_headers.hpp"

View File

@@ -32,7 +32,7 @@ add_library(input_common STATIC
input_poller.h
main.cpp
main.h
precompiled_headers.h
precompiled_headers.hpp
)
if (MSVC)
@@ -42,7 +42,9 @@ if (MSVC)
)
else()
target_compile_options(input_common PRIVATE
-Werror=conversion
# Causes Boost to fail to compile, let's just let it be a warning for now.
#-Werror=conversion
-Wconversion
)
endif()
@@ -89,7 +91,7 @@ create_target_directory_groups(input_common)
target_link_libraries(input_common PUBLIC hid_core PRIVATE common Boost::headers)
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(input_common PRIVATE precompiled_headers.h)
target_precompile_headers(input_common PRIVATE precompiled_headers.hpp)
endif()
if (ANDROID)

View File

@@ -26,8 +26,8 @@ public:
using clock = std::chrono::system_clock;
explicit Socket(const std::string& host, u16 port, SocketCallback callback_)
: callback(std::move(callback_)), timer(io_service),
socket(io_service, udp::endpoint(udp::v4(), 0)), client_id(GenerateRandomClientId()) {
: callback(std::move(callback_)), timer(io_context),
socket(io_context, udp::endpoint(udp::v4(), 0)), client_id(GenerateRandomClientId()) {
boost::system::error_code ec{};
auto ipv4 = boost::asio::ip::make_address_v4(host, ec);
if (ec.value() != boost::system::errc::success) {
@@ -39,11 +39,11 @@ public:
}
void Stop() {
io_service.stop();
io_context.stop();
}
void Loop() {
io_service.run();
io_context.run();
}
void StartSend(const clock::time_point& from) {
@@ -113,7 +113,7 @@ private:
}
SocketCallback callback;
boost::asio::io_service io_service;
boost::asio::io_context io_context;
boost::asio::basic_waitable_timer<clock> timer;
udp::socket socket;

View File

@@ -1,6 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"

View File

@@ -0,0 +1,6 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.hpp"

View File

@@ -8,7 +8,7 @@ add_library(network STATIC
network.h
packet.cpp
packet.h
precompiled_headers.h
precompiled_headers.hpp
room.cpp
room.h
room_member.cpp
@@ -26,5 +26,5 @@ if (ENABLE_WEB_SERVICE)
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(network PRIVATE precompiled_headers.h)
target_precompile_headers(network PRIVATE precompiled_headers.hpp)
endif()

View File

@@ -1,6 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"

View File

@@ -0,0 +1,6 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.hpp"

View File

@@ -234,7 +234,7 @@ add_library(shader_recompiler STATIC
ir_opt/vendor_workaround_pass.cpp
ir_opt/verification_pass.cpp
object_pool.h
precompiled_headers.h
precompiled_headers.hpp
profile.h
program_header.h
runtime_info.h
@@ -269,5 +269,5 @@ endif()
create_target_directory_groups(shader_recompiler)
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(shader_recompiler PRIVATE precompiled_headers.h)
target_precompile_headers(shader_recompiler PRIVATE precompiled_headers.hpp)
endif()

View File

@@ -3,5 +3,5 @@
#pragma once
#include "common/common_precompiled_headers.h"
#include "common/common_precompiled_headers.hpp"
#include "frontend/maxwell/translate/impl/impl.h"

View File

@@ -14,7 +14,7 @@ add_executable(tests
common/unique_function.cpp
core/core_timing.cpp
core/internal_network/network.cpp
precompiled_headers.h
precompiled_headers.hpp
video_core/memory_tracker.cpp
input_common/calibration_configuration_job.cpp
)
@@ -27,5 +27,5 @@ target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} Catch2::Catch2WithMain
add_test(NAME tests COMMAND tests)
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(tests PRIVATE precompiled_headers.h)
target_precompile_headers(tests PRIVATE precompiled_headers.hpp)
endif()

View File

@@ -14,7 +14,7 @@
class FakeCemuhookServer {
public:
FakeCemuhookServer()
: socket(io_service, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), 0)) {}
: socket(io_context, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), 0)) {}
~FakeCemuhookServer() {
is_running = false;
@@ -82,7 +82,7 @@ public:
}
private:
boost::asio::io_service io_service;
boost::asio::io_context io_context;
boost::asio::ip::udp::socket socket;
std::array<u8, InputCommon::CemuhookUDP::MAX_PACKET_SIZE> send_buffer;
std::array<u8, InputCommon::CemuhookUDP::MAX_PACKET_SIZE> receive_buffer;

View File

@@ -1,6 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"

View File

@@ -0,0 +1,6 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.hpp"

View File

@@ -99,7 +99,7 @@ add_library(video_core STATIC
invalidation_accumulator.h
memory_manager.cpp
memory_manager.h
precompiled_headers.h
precompiled_headers.hpp
present.h
pte_kind.h
query_cache/bank_base.h
@@ -372,10 +372,6 @@ if (ARCHITECTURE_x86_64)
macro/macro_jit_x64.h
)
target_link_libraries(video_core PUBLIC xbyak::xbyak)
if (NOT MSVC)
target_compile_options(video_core PRIVATE -msse4.1)
endif()
endif()
if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64)
@@ -383,7 +379,7 @@ if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64)
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(video_core PRIVATE precompiled_headers.h)
target_precompile_headers(video_core PRIVATE precompiled_headers.hpp)
endif()
if (YUZU_ENABLE_LTO)

View File

@@ -1,6 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"

View File

@@ -0,0 +1,6 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.hpp"

View File

@@ -4,7 +4,7 @@
add_library(web_service STATIC
announce_room_json.cpp
announce_room_json.h
precompiled_headers.h
precompiled_headers.hpp
verify_login.cpp
verify_login.h
verify_user_jwt.cpp
@@ -18,5 +18,5 @@ create_target_directory_groups(web_service)
target_link_libraries(web_service PRIVATE common network nlohmann_json::nlohmann_json httplib::httplib cpp-jwt::cpp-jwt)
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(web_service PRIVATE precompiled_headers.h)
target_precompile_headers(web_service PRIVATE precompiled_headers.hpp)
endif()

View File

@@ -1,6 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"

View File

@@ -0,0 +1,6 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.hpp"

View File

@@ -203,7 +203,7 @@ add_executable(yuzu
multiplayer/validation.h
play_time_manager.cpp
play_time_manager.h
precompiled_headers.h
precompiled_headers.hpp
qt_common.cpp
qt_common.h
startup_checks.cpp
@@ -382,8 +382,11 @@ elseif(WIN32)
endif()
target_link_libraries(yuzu PRIVATE common core input_common frontend_common network video_core)
target_link_libraries(yuzu PRIVATE Boost::headers glad Qt${QT_MAJOR_VERSION}::Widgets)
target_link_libraries(yuzu PRIVATE Boost::headers httplib::httplib glad Qt${QT_MAJOR_VERSION}::Widgets)
target_link_libraries(yuzu PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads)
if (TARGET nlohmann::json)
target_link_libraries(yuzu PRIVATE nlohmann::json)
endif()
if (ENABLE_WEB_SERVICE)
target_link_libraries(yuzu PRIVATE httplib::httplib)
endif()
@@ -477,7 +480,7 @@ if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64)
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(yuzu PRIVATE precompiled_headers.h)
target_precompile_headers(yuzu PRIVATE precompiled_headers.hpp)
endif()
create_target_directory_groups(yuzu)

View File

@@ -1,6 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"

View File

@@ -0,0 +1,6 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.hpp"

View File

@@ -22,7 +22,7 @@ if (YUZU_CMD)
emu_window/emu_window_sdl2_null.h
emu_window/emu_window_sdl2_vk.cpp
emu_window/emu_window_sdl2_vk.h
precompiled_headers.h
precompiled_headers.hpp
sdl_config.cpp
sdl_config.h
yuzu.cpp
@@ -60,7 +60,7 @@ if (YUZU_CMD)
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(yuzu-cmd PRIVATE precompiled_headers.h)
target_precompile_headers(yuzu-cmd PRIVATE precompiled_headers.hpp)
endif()
create_target_directory_groups(yuzu-cmd)

View File

@@ -1,6 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"

View File

@@ -0,0 +1,6 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.hpp"