From feb43b779ac4b4d82b2c40a1993b8e8fcc93aa1e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 5 Aug 2024 20:20:12 +0200 Subject: [PATCH] Switch to non-strict C++ builds so QT_SUPPORTS_INT128 is true A previous commit disabled QT_SUPPORTS_INT128 if the Standard Library doesn't properly specialize and for the 128-bit types, like libstdc++ in strict mode. As a consequence, we now need to compile Qt in non-strict mode so QT_SUPPORTS_INT128 is true when building Qt, at least if the compiler supports 128-bit integers in principle. Statically assert that QT_SUPPORTS_INT128 is defined if the compiler in principle supports it, to catch other problematic platforms early. We have a few out-of-line implementations that should be built if the compiler supports int128 in principle, so that Qt users are free to use the types if their compiler supports them and not run into missing support in the Qt library. This patch ensures this. Compiling in non-strict mode removes the early warning we were getting from it, but a) headersclean still uses strict mode, so at least our headers are regularly checked and b) this is a cross-platform project; if we were to use platform-specific extensions unprotected, other platform's compilers will still complain. Fixes: QTBUG-119901 Change-Id: I974f95ca0f26085dd0fe5ceb8bbef4f62467979a Reviewed-by: Thiago Macieira (cherry picked from commit 30e04340dac26ebd09f9bc8ceb598e873ab63ba7) Reviewed-by: Qt Cherry-pick Bot --- cmake/Qt3rdPartyLibraryHelpers.cmake | 1 - cmake/QtModuleHelpers.cmake | 1 - cmake/QtPluginHelpers.cmake | 1 - src/corelib/global/qtypes.cpp | 7 +++++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake/Qt3rdPartyLibraryHelpers.cmake b/cmake/Qt3rdPartyLibraryHelpers.cmake index 7d40145efa1..b6efc2427df 100644 --- a/cmake/Qt3rdPartyLibraryHelpers.cmake +++ b/cmake/Qt3rdPartyLibraryHelpers.cmake @@ -197,7 +197,6 @@ function(qt_internal_add_3rdparty_library target) qt_internal_add_qt_repo_known_module(${target}) qt_internal_add_target_aliases(${target}) - _qt_internal_apply_strict_cpp(${target}) qt_skip_warnings_are_errors_when_repo_unclean("${target}") diff --git a/cmake/QtModuleHelpers.cmake b/cmake/QtModuleHelpers.cmake index d92e1524fee..7576b0b1c1b 100644 --- a/cmake/QtModuleHelpers.cmake +++ b/cmake/QtModuleHelpers.cmake @@ -312,7 +312,6 @@ function(qt_internal_add_module target) qt_internal_add_target_aliases("${target}") qt_skip_warnings_are_errors_when_repo_unclean("${target}") - _qt_internal_apply_strict_cpp("${target}") # No need to compile Q_IMPORT_PLUGIN-containing files for non-executables. if(is_static_lib) diff --git a/cmake/QtPluginHelpers.cmake b/cmake/QtPluginHelpers.cmake index e29b638ff5b..fc036cf6a54 100644 --- a/cmake/QtPluginHelpers.cmake +++ b/cmake/QtPluginHelpers.cmake @@ -160,7 +160,6 @@ function(qt_internal_add_plugin target) qt_set_common_target_properties("${target}") qt_internal_add_target_aliases("${target}") qt_skip_warnings_are_errors_when_repo_unclean("${target}") - _qt_internal_apply_strict_cpp("${target}") set_target_properties("${target}" PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${output_directory}" diff --git a/src/corelib/global/qtypes.cpp b/src/corelib/global/qtypes.cpp index 9de3960e2fc..9a4616b9d89 100644 --- a/src/corelib/global/qtypes.cpp +++ b/src/corelib/global/qtypes.cpp @@ -503,6 +503,13 @@ static_assert(sizeof(size_t) == sizeof(qsizetype)); // implied by the definition static_assert((std::is_same::value)); static_assert(std::is_same_v); +#ifdef __SIZEOF_INT128__ +# ifndef QT_SUPPORTS_INT128 +# error Qt needs to be compiled in a mode that enables INT128 \ + if the compiler supports it in principle. +# endif +#endif + // Check that our own typedefs are not broken. static_assert(sizeof(qint8) == 1, "Internal error, qint8 is misdefined"); static_assert(sizeof(qint16)== 2, "Internal error, qint16 is misdefined");