Просмотр исходного кода

common,yuzu-qt: Avoid explicit instantiation on old clang

Clang versions < 15 have compile issues with explicit instantiation.
Disable it for these versions.
lat9nq 3 лет назад
Родитель
Сommit
3f0cc544cf
6 измененных файлов с 22 добавлено и 3 удалено
  1. 8 3
      src/common/CMakeLists.txt
  2. 2 0
      src/common/settings.cpp
  3. 2 0
      src/common/settings.h
  4. 6 0
      src/yuzu/CMakeLists.txt
  5. 2 0
      src/yuzu/uisettings.cpp
  6. 2 0
      src/yuzu/uisettings.h

+ 8 - 3
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
     /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
     /we4800 # Implicit conversion from 'type' to bool. Possible information loss
   )
   )
-else()
+endif()
+
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
   target_compile_options(common PRIVATE
   target_compile_options(common PRIVATE
-    $<$<CXX_COMPILER_ID:Clang>:-fsized-deallocation>
-    $<$<CXX_COMPILER_ID:Clang>:-Werror=unreachable-code-aggressive>
+    -fsized-deallocation
+    -Werror=unreachable-code-aggressive
+  )
+  target_compile_definitions(common PRIVATE
+    $<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,15>:_CANNOT_EXPLICITLY_INSTANTIATE>
   )
   )
 endif()
 endif()
 
 

+ 2 - 0
src/common/settings.cpp

@@ -25,6 +25,7 @@
 
 
 namespace Settings {
 namespace Settings {
 
 
+#ifndef _CANNOT_EXPLICITLY_INSTANTIATE
 #define SETTING(TYPE, RANGED) template class Setting<TYPE, RANGED>
 #define SETTING(TYPE, RANGED) template class Setting<TYPE, RANGED>
 #define SWITCHABLE(TYPE, RANGED) template class SwitchableSetting<TYPE, RANGED>
 #define SWITCHABLE(TYPE, RANGED) template class SwitchableSetting<TYPE, RANGED>
 
 
@@ -61,6 +62,7 @@ SWITCHABLE(u8, true);
 
 
 #undef SETTING
 #undef SETTING
 #undef SWITCHABLE
 #undef SWITCHABLE
+#endif
 
 
 Values values;
 Values values;
 
 

+ 2 - 0
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
 // Instantiate the classes elsewhere (settings.cpp) to reduce compiler/linker work
 #define SETTING(TYPE, RANGED) extern template class Setting<TYPE, RANGED>
 #define SETTING(TYPE, RANGED) extern template class Setting<TYPE, RANGED>
 #define SWITCHABLE(TYPE, RANGED) extern template class SwitchableSetting<TYPE, RANGED>
 #define SWITCHABLE(TYPE, RANGED) extern template class SwitchableSetting<TYPE, RANGED>
@@ -84,6 +85,7 @@ SWITCHABLE(u8, true);
 
 
 #undef SETTING
 #undef SETTING
 #undef SWITCHABLE
 #undef SWITCHABLE
+#endif
 
 
 /**
 /**
  * The InputSetting class allows for getting a reference to either the global or custom members.
  * The InputSetting class allows for getting a reference to either the global or custom members.

+ 6 - 0
src/yuzu/CMakeLists.txt

@@ -235,6 +235,12 @@ if (WIN32 AND YUZU_CRASH_DUMPS)
     target_compile_definitions(yuzu PRIVATE -DYUZU_DBGHELP)
     target_compile_definitions(yuzu PRIVATE -DYUZU_DBGHELP)
 endif()
 endif()
 
 
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+    target_compile_definitions(yuzu PRIVATE
+        $<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,15>:_CANNOT_EXPLICITLY_INSTANTIATE>
+    )
+endif()
+
 file(GLOB COMPAT_LIST
 file(GLOB COMPAT_LIST
      ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.qrc
      ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.qrc
      ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.json)
      ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.json)

+ 2 - 0
src/yuzu/uisettings.cpp

@@ -3,6 +3,7 @@
 
 
 #include "yuzu/uisettings.h"
 #include "yuzu/uisettings.h"
 
 
+#ifndef _CANNOT_EXPLICITLY_INSTANTIATE
 namespace Settings {
 namespace Settings {
 template class Setting<bool>;
 template class Setting<bool>;
 template class Setting<std::string>;
 template class Setting<std::string>;
@@ -12,6 +13,7 @@ template class Setting<u8, true>;
 template class Setting<u8>;
 template class Setting<u8>;
 template class Setting<unsigned long long>;
 template class Setting<unsigned long long>;
 } // namespace Settings
 } // namespace Settings
+#endif
 
 
 namespace UISettings {
 namespace UISettings {
 
 

+ 2 - 0
src/yuzu/uisettings.h

@@ -17,6 +17,7 @@
 using Settings::Category;
 using Settings::Category;
 using Settings::Setting;
 using Settings::Setting;
 
 
+#ifndef _CANNOT_EXPLICITLY_INSTANTIATE
 namespace Settings {
 namespace Settings {
 extern template class Setting<bool>;
 extern template class Setting<bool>;
 extern template class Setting<std::string>;
 extern template class Setting<std::string>;
@@ -26,6 +27,7 @@ extern template class Setting<u8, true>;
 extern template class Setting<u8>;
 extern template class Setting<u8>;
 extern template class Setting<unsigned long long>;
 extern template class Setting<unsigned long long>;
 } // namespace Settings
 } // namespace Settings
+#endif
 
 
 namespace UISettings {
 namespace UISettings {