Skip to content

Commit

Permalink
Switch to non-strict C++ builds so QT_SUPPORTS_INT128 is true
Browse files Browse the repository at this point in the history
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
Pick-to: 6.8
Change-Id: I974f95ca0f26085dd0fe5ceb8bbef4f62467979a
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
marcmutz committed Aug 16, 2024
1 parent 9bb2ab5 commit 30e0434
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion cmake/Qt3rdPartyLibraryHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
1 change: 0 additions & 1 deletion cmake/QtModuleHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion cmake/QtPluginHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,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}"
Expand Down
7 changes: 7 additions & 0 deletions src/corelib/global/qtypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 30e0434

Please sign in to comment.