[oe] [meta-qt4][PATCH 2/2] qt4: updates for gcc 9.2

Jeroen Hofstee jhofstee at victronenergy.com
Sun Nov 17 21:44:43 UTC 2019


This adds two patches, the first one is a backport from qt5 to make
Q_FOREACH work again. The patch itself contains the details.

The other one makes the build logs readable again by suppressing many
harmless warnings issued by newer compilers.

Signed-off-by: Jeroen Hofstee <jhofstee at victronenergy.com>
---
 recipes-qt4/qt4/nativesdk-qt4-tools.inc       |  2 +
 recipes-qt4/qt4/qt4-4.8.7.inc                 |  2 +
 ...event-gcc-9.2-miscompiling-Q_FOREACH.patch | 78 ++++++++++++++++
 ...ence-some-loud-but-innocent-warnings.patch | 91 +++++++++++++++++++
 recipes-qt4/qt4/qt4-native.inc                |  2 +
 5 files changed, 175 insertions(+)
 create mode 100644 recipes-qt4/qt4/qt4-4.8.7/0038-prevent-gcc-9.2-miscompiling-Q_FOREACH.patch
 create mode 100644 recipes-qt4/qt4/qt4-4.8.7/0039-silence-some-loud-but-innocent-warnings.patch

diff --git a/recipes-qt4/qt4/nativesdk-qt4-tools.inc b/recipes-qt4/qt4/nativesdk-qt4-tools.inc
index e9c45da..f071b22 100644
--- a/recipes-qt4/qt4/nativesdk-qt4-tools.inc
+++ b/recipes-qt4/qt4/nativesdk-qt4-tools.inc
@@ -19,6 +19,8 @@ SRC_URI = "http://download.qt-project.org/official_releases/qt/4.8/${PV}/qt-ever
            file://0006-configure-Use-OE_QMAKE_-values-to-specify-Qt-utility.patch \
            file://0007-dbus-Remove-const-usage-that-causes-compile-failure-.patch \
            file://0008-qmake.pro-Allow-building-a-separate-qmake-for-the-ta.patch \
+           file://0038-prevent-gcc-9.2-miscompiling-Q_FOREACH.patch \
+           file://0039-silence-some-loud-but-innocent-warnings.patch \
            file://g++.conf \
            file://linux.conf"
 
diff --git a/recipes-qt4/qt4/qt4-4.8.7.inc b/recipes-qt4/qt4/qt4-4.8.7.inc
index 7d9b9b9..1b52d6d 100644
--- a/recipes-qt4/qt4/qt4-4.8.7.inc
+++ b/recipes-qt4/qt4/qt4-4.8.7.inc
@@ -28,6 +28,8 @@ SRC_URI = "http://download.qt-project.org/official_releases/qt/4.8/${PV}/qt-ever
            file://0035-Add-nios2-support.patch \
            file://0036-qt-everywhere-opensource-src-4.8.7-gcc6.patch \
            file://0037-fix-configure-with-icu60.patch \
+           file://0038-prevent-gcc-9.2-miscompiling-Q_FOREACH.patch \
+           file://0039-silence-some-loud-but-innocent-warnings.patch \
            file://gcc-version.patch \
            file://Fix-QWSLock-invalid-argument-logs.patch \
            file://add_check_for_aarch64_32.patch \
diff --git a/recipes-qt4/qt4/qt4-4.8.7/0038-prevent-gcc-9.2-miscompiling-Q_FOREACH.patch b/recipes-qt4/qt4/qt4-4.8.7/0038-prevent-gcc-9.2-miscompiling-Q_FOREACH.patch
new file mode 100644
index 0000000..e02c9be
--- /dev/null
+++ b/recipes-qt4/qt4/qt4-4.8.7/0038-prevent-gcc-9.2-miscompiling-Q_FOREACH.patch
@@ -0,0 +1,78 @@
+From f27717257dc7fcfe1d48b02b10668da1af678ad4 Mon Sep 17 00:00:00 2001
+From: Jeroen Hofstee <jhofstee at victronenergy.com>
+Date: Sat, 16 Nov 2019 16:48:58 +0100
+Subject: [PATCH 1/2] prevent gcc 9.2 miscompiling Q_FOREACH
+
+With gcc 9.2, Q_FOREACH only loops over the first element [1]. Fix
+this by backporting [2]. That commit is for other reasons, but also
+fixes this.
+
+Original commit by Thiago Macieira <thiago.macieira at intel.com>:
+
+It's possible to do without them, which probably makes the number of
+supported compilers a lot bigger: they just need to support decltype()
+or __typeof__.
+
+That includes the Intel compiler. The old code was also apparently
+working, but no one had realized the old workaround for some old version
+was still in place.
+
+The loop overhead is more or less the same. I have not done benchmarks,
+but inspection of the generated assembly shows more or less the same
+number of instructions.
+
+Change-Id: I32d499c84a6ddd19d994b49f17a469acb5c3a3f1
+Reviewed-by: Olivier Goffart <ogoffart at woboq.com>
+Reviewed-by: Marc Mutz <marc.mutz at kdab.com>
+
+[1] https://github.com/qt/qtbase/commit/c35a3f519007af44c3b364b9af86f6a336f6411b
+[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90617
+---
+ src/corelib/global/qglobal.h | 21 +++++++++++++++------
+ 1 file changed, 15 insertions(+), 6 deletions(-)
+
+diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
+index 96fbeee0ae..a2f9ea097a 100644
+--- a/src/corelib/global/qglobal.h
++++ b/src/corelib/global/qglobal.h
+@@ -2367,22 +2367,31 @@ typedef uint Flags;
+ 
+ #endif /* Q_NO_TYPESAFE_FLAGS */
+ 
+-#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT)
++#if defined(Q_CC_GNU) && !defined(Q_CC_RVCT)
+ /* make use of typeof-extension */
+ template <typename T>
+ class QForeachContainer {
+ public:
+-    inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { }
++    inline QForeachContainer(const T& t) : c(t), i(c.begin()), e(c.end()), control(1) { }
+     const T c;
+-    int brk;
+     typename T::const_iterator i, e;
++    int control;
+ };
+ 
++// Explanation of the control word:
++//  - it's initialized to 1
++//  - that means both the inner and outer loops start
++//  - if there were no breaks, at the end of the inner loop, it's set to 0, which
++//    causes it to exit (the inner loop is run exactly once)
++//  - at the end of the outer loop, it's inverted, so it becomes 1 again, allowing
++//    the outer loop to continue executing
++//  - if there was a break inside the inner loop, it will exit with control still
++//    set to 1; in that case, the outer loop will invert it to 0 and will exit too
+ #define Q_FOREACH(variable, container)                                \
+ for (QForeachContainer<__typeof__(container)> _container_(container); \
+-     !_container_.brk && _container_.i != _container_.e;              \
+-     __extension__  ({ ++_container_.brk; ++_container_.i; }))                       \
+-    for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))
++    _container_.control && _container_.i != _container_.e;            \
++    ++_container_.i, _container_.control ^= 1)                        \
++    for (variable = *_container_.i; _container_.control; _container_.control = 0)
+ 
+ #else
+ 
+-- 
+2.17.1
+
diff --git a/recipes-qt4/qt4/qt4-4.8.7/0039-silence-some-loud-but-innocent-warnings.patch b/recipes-qt4/qt4/qt4-4.8.7/0039-silence-some-loud-but-innocent-warnings.patch
new file mode 100644
index 0000000..0647261
--- /dev/null
+++ b/recipes-qt4/qt4/qt4-4.8.7/0039-silence-some-loud-but-innocent-warnings.patch
@@ -0,0 +1,91 @@
+From e03ee6b5bca6ab457a16faa8399ba20cd5cc1fbc Mon Sep 17 00:00:00 2001
+From: Jeroen Hofstee <jhofstee at victronenergy.com>
+Date: Sat, 16 Nov 2019 16:50:00 +0100
+Subject: [PATCH] silence some loud but innocent warnings
+
+These warnings are harmless for old code, so suppress them so real
+issue are visible in the logs.
+---
+ configure | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 66 insertions(+)
+
+diff --git a/configure b/configure
+index a9ba7c8ccb..6ebf71ab21 100755
+--- a/configure
++++ b/configure
+@@ -3435,6 +3435,72 @@ if [ -n "$CFG_SYSROOT" ]; then
+ fi
+ export SYSROOT_FLAG    # used by config.tests/unix/compile.test
+ 
++# Since qt4 is no longer officialy maintained, silence the harmless warnings
++# since nobody is going to fix them anyway...
++
++if compilerSupportsFlag $TEST_COMPILER -Wunused-but-set-variable -Werror; then
++	QMakeVar add QMAKE_CFLAGS -Wno-unused-but-set-variable
++	QMakeVar add QMAKE_CXXFLAGS -Wno-unused-but-set-variable
++fi
++
++if compilerSupportsFlag $TEST_COMPILER -Wunused-function -Werror; then
++	QMakeVar add QMAKE_CFLAGS -Wno-unused-function
++	QMakeVar add QMAKE_CXXFLAGS -Wno-unused-function
++fi
++
++if compilerSupportsFlag $TEST_COMPILER -Wunused-variable -Werror; then
++	QMakeVar add QMAKE_CFLAGS -Wno-unused-variable
++	QMakeVar add QMAKE_CXXFLAGS -Wno-unused-variable
++fi
++
++if compilerSupportsFlag $TEST_COMPILER -Wunused-local-typedefs; then
++	QMakeVar add QMAKE_CFLAGS -Wno-unused-local-typedefs
++	QMakeVar add QMAKE_CXXFLAGS -Wno-unused-local-typedefs
++fi
++
++if compilerSupportsFlag $TEST_COMPILER -Wimplicit-fallthrough -Werror; then
++	QMakeVar add QMAKE_CFLAGS -Wno-implicit-fallthrough
++	QMakeVar add QMAKE_CXXFLAGS -Wno-implicit-fallthrough
++fi
++
++if compilerSupportsFlag $TEST_COMPILER -Wunused-parameter -Werror; then
++	QMakeVar add QMAKE_CFLAGS -Wno-unused-parameter
++	QMakeVar add QMAKE_CXXFLAGS -Wno-unused-parameter
++fi
++
++# when a compiler starts guessing it is often wrong..
++if compilerSupportsFlag $TEST_COMPILER -Wmaybe-uninitialized -Werror; then
++	QMakeVar add QMAKE_CFLAGS -Wno-maybe-uninitialized
++	QMakeVar add QMAKE_CXXFLAGS -Wno-maybe-uninitialized
++fi
++
++if compilerSupportsFlag $TEST_COMPILER -Wswitch -Werror; then
++	QMakeVar add QMAKE_CFLAGS -Wno-switch
++	QMakeVar add QMAKE_CXXFLAGS -Wno-switch
++fi
++
++if compilerSupportsFlag $TEST_COMPILER -Wdeprecated-copy -Werror; then
++	QMakeVar add QMAKE_CXXFLAGS -Wno-deprecated-copy
++fi
++
++if compilerSupportsFlag $TEST_COMPILER -Wdeprecated-declarations -Werror; then
++	QMakeVar add QMAKE_CXXFLAGS -Wno-deprecated-declarations
++fi
++
++if compilerSupportsFlag $TEST_COMPILER -Wparentheses -Werror; then
++	QMakeVar add QMAKE_CXXFLAGS -Wno-parentheses
++fi
++
++if compilerSupportsFlag $TEST_COMPILER -Wclass-memaccess -Werror; then
++	QMakeVar add QMAKE_CXXFLAGS -Wno-class-memaccess
++fi
++
++# note: parameter passing for argument of type 'QMap<QSettingsKey, QVariant>::iterator' changed in GCC 7.1
++# Assuming that OE is used to rebuild all sources, there is no need to worry about abi changes..
++if compilerSupportsFlag $TEST_COMPILER -Wpsabi -Werror; then
++	QMakeVar add QMAKE_CXXFLAGS -Wno-psabi
++fi
++
+ # auto-detect precompiled header support
+ if [ "$CFG_PRECOMPILE" = "auto" ]; then
+     if [ `echo "$CFG_MAC_ARCHS" | wc -w` -gt 1 ]; then
+-- 
+2.17.1
+
diff --git a/recipes-qt4/qt4/qt4-native.inc b/recipes-qt4/qt4/qt4-native.inc
index b813f9e..8a964c6 100644
--- a/recipes-qt4/qt4/qt4-native.inc
+++ b/recipes-qt4/qt4/qt4-native.inc
@@ -18,6 +18,8 @@ SRC_URI = "http://download.qt-project.org/official_releases/qt/4.8/${PV}/qt-ever
            file://0015-configure-add-nostrip-for-debug-packages.patch  \
            file://0021-configure-make-qt4-native-work-with-long-building-pa.patch \
            file://0036-qt-everywhere-opensource-src-4.8.7-gcc6.patch \
+           file://0038-prevent-gcc-9.2-miscompiling-Q_FOREACH.patch \
+           file://0039-silence-some-loud-but-innocent-warnings.patch \
            file://gcc-version.patch \
            file://g++.conf \
            file://linux.conf \
-- 
2.17.1



More information about the Openembedded-devel mailing list