Disable -Werror=tsan on GCC < 15

QGlobalStatic has a warning suppression for -Wtsan because of its
usage of std::atomic_thread_fence, which TSAN doesn't support.
That header is included in QtCore's PCH, and that triggers a GCC bug
that causes the warning to be emitted despite the suppression [1].

In a developer build, the warning turns fatal.

We could either disable PCHs in such a build configuration
(TSAN+developer-build+GCC < 15), or: simply make the warning non-fatal
on earlier compiler versions.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64117

Pick-to: 6.8 6.5
Fixes: QTBUG-134415
Change-Id: If80a4acdb1372d00804a60361f6c3d6893b96106
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit a72077a88903fe532f6a749677eb4da4ea99f79f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Giuseppe D'Angelo 2025-03-05 14:16:37 +01:00 committed by Qt Cherry-pick Bot
parent d7127c02ff
commit 8181c4868a
2 changed files with 9 additions and 0 deletions

View File

@ -81,6 +81,14 @@ function(qt_internal_set_warnings_are_errors_flags target target_scope)
# This in turn triggers a fallthrough warning in cborparser.c, so we disable
# this warning.
-no-integrated-cpp -Wno-implicit-fallthrough
CONDITIONS VERSION_LESS 15.1
AND $<BOOL:${QT_FEATURE_sanitize_thread}>
AND $<BOOL:${BUILD_WITH_PCH}>
OPTIONS
# GCC < 15 raises a TSAN warning from Qt's own PCHs, despite the warning
# being suppressed (QTBUG-134415)
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64117
-Wno-error=tsan
COMMON_CONDITIONS
${common_conditions}
${language_args}

View File

@ -43,6 +43,7 @@ template <typename QGS> union Holder
// TSAN does not support atomic_thread_fence and GCC complains:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97868
// https://github.com/google/sanitizers/issues/1352
// QTBUG-134415
QT_WARNING_PUSH
#if defined(Q_CC_GNU_ONLY) && Q_CC_GNU >= 1100
QT_WARNING_DISABLE_GCC("-Wtsan")