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 <type_traits> and <limits> 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 <thiago.macieira@intel.com>
(cherry picked from commit 30e04340dac26ebd09f9bc8ceb598e873ab63ba7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-08-05 20:20:12 +02:00 committed by Qt Cherry-pick Bot
parent 7805b3c32f
commit feb43b779a
4 changed files with 7 additions and 3 deletions

View File

@ -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}")

View File

@ -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)

View File

@ -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}"

View File

@ -503,6 +503,13 @@ static_assert(sizeof(size_t) == sizeof(qsizetype)); // implied by the definition
static_assert((std::is_same<qsizetype, qptrdiff>::value));
static_assert(std::is_same_v<std::size_t, size_t>);
#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");