From 3f0cc544cf7184adacec22aedd81f6d796bbea31 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 18 Jun 2023 19:57:14 -0400 Subject: [PATCH] common,yuzu-qt: Avoid explicit instantiation on old clang Clang versions < 15 have compile issues with explicit instantiation. Disable it for these versions. --- src/common/CMakeLists.txt | 11 ++++++++--- src/common/settings.cpp | 2 ++ src/common/settings.h | 2 ++ src/yuzu/CMakeLists.txt | 6 ++++++ src/yuzu/uisettings.cpp | 2 ++ src/yuzu/uisettings.h | 2 ++ 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 09e7e673e..cf05ae364 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -197,10 +197,15 @@ if (MSVC) /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data /we4800 # Implicit conversion from 'type' to bool. Possible information loss ) -else() +endif() + +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_compile_options(common PRIVATE - $<$:-fsized-deallocation> - $<$:-Werror=unreachable-code-aggressive> + -fsized-deallocation + -Werror=unreachable-code-aggressive + ) + target_compile_definitions(common PRIVATE + $<$,15>:_CANNOT_EXPLICITLY_INSTANTIATE> ) endif() diff --git a/src/common/settings.cpp b/src/common/settings.cpp index a1cc76a38..f4eb2d2fb 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -25,6 +25,7 @@ namespace Settings { +#ifndef _CANNOT_EXPLICITLY_INSTANTIATE #define SETTING(TYPE, RANGED) template class Setting #define SWITCHABLE(TYPE, RANGED) template class SwitchableSetting @@ -61,6 +62,7 @@ SWITCHABLE(u8, true); #undef SETTING #undef SWITCHABLE +#endif Values values; diff --git a/src/common/settings.h b/src/common/settings.h index e510036b4..35fa4cf3d 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -45,6 +45,7 @@ struct ResolutionScalingInfo { } }; +#ifndef _CANNOT_EXPLICITLY_INSTANTIATE // Instantiate the classes elsewhere (settings.cpp) to reduce compiler/linker work #define SETTING(TYPE, RANGED) extern template class Setting #define SWITCHABLE(TYPE, RANGED) extern template class SwitchableSetting @@ -84,6 +85,7 @@ SWITCHABLE(u8, true); #undef SETTING #undef SWITCHABLE +#endif /** * The InputSetting class allows for getting a reference to either the global or custom members. diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 899b75871..5183aabdf 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -235,6 +235,12 @@ if (WIN32 AND YUZU_CRASH_DUMPS) target_compile_definitions(yuzu PRIVATE -DYUZU_DBGHELP) endif() +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_definitions(yuzu PRIVATE + $<$,15>:_CANNOT_EXPLICITLY_INSTANTIATE> + ) +endif() + file(GLOB COMPAT_LIST ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.qrc ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.json) diff --git a/src/yuzu/uisettings.cpp b/src/yuzu/uisettings.cpp index 2a02a27bc..41e2493b3 100644 --- a/src/yuzu/uisettings.cpp +++ b/src/yuzu/uisettings.cpp @@ -3,6 +3,7 @@ #include "yuzu/uisettings.h" +#ifndef _CANNOT_EXPLICITLY_INSTANTIATE namespace Settings { template class Setting; template class Setting; @@ -12,6 +13,7 @@ template class Setting; template class Setting; template class Setting; } // namespace Settings +#endif namespace UISettings { diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index 2152b0b3b..08049f9c4 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h @@ -17,6 +17,7 @@ using Settings::Category; using Settings::Setting; +#ifndef _CANNOT_EXPLICITLY_INSTANTIATE namespace Settings { extern template class Setting; extern template class Setting; @@ -26,6 +27,7 @@ extern template class Setting; extern template class Setting; extern template class Setting; } // namespace Settings +#endif namespace UISettings {