summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Di Battista <rubendibattista@users.noreply.github.com>2019-09-14 21:00:46 +0200
committerAdam J. Stewart <ajstewart426@gmail.com>2019-09-14 14:00:46 -0500
commit9675db4e7f626a14007f743baccaa9e062868432 (patch)
tree7a8eb5a5cc84a3c76449f21da831ee63fcd87c82
parentc26a3ff8940d18d3029c69f424acd4894a7af4c2 (diff)
downloadspack-9675db4e7f626a14007f743baccaa9e062868432.tar.gz
spack-9675db4e7f626a14007f743baccaa9e062868432.tar.bz2
spack-9675db4e7f626a14007f743baccaa9e062868432.tar.xz
spack-9675db4e7f626a14007f743baccaa9e062868432.zip
qt: Fix build with GCC9 for version 4 (#12832)
* qt: Fix build w/ GCC9 for @4: * qt: Fix patch filename and qt version * Fix typo in patch name
-rw-r--r--var/spack/repos/builtin/packages/qt/package.py4
-rw-r--r--var/spack/repos/builtin/packages/qt/qt4-gcc9-qforeach.patch64
2 files changed, 68 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/qt/package.py b/var/spack/repos/builtin/packages/qt/package.py
index 158b9b6e3e..8b192de89f 100644
--- a/var/spack/repos/builtin/packages/qt/package.py
+++ b/var/spack/repos/builtin/packages/qt/package.py
@@ -105,6 +105,10 @@ class Qt(Package):
working_dir='qtbase',
when='@5.10:5.12.0 %gcc@9:')
+ # Fix build of QT4 with GCC 9
+ # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=925811
+ patch("qt4-gcc9-qforeach.patch", when="@4:4.999 %gcc@9")
+
# https://bugreports.qt.io/browse/QTBUG-74196
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89585
patch('qt4-gcc8.3-asm-volatile-fix.patch', when='@4')
diff --git a/var/spack/repos/builtin/packages/qt/qt4-gcc9-qforeach.patch b/var/spack/repos/builtin/packages/qt/qt4-gcc9-qforeach.patch
new file mode 100644
index 0000000000..ae54cdbc1e
--- /dev/null
+++ b/var/spack/repos/builtin/packages/qt/qt4-gcc9-qforeach.patch
@@ -0,0 +1,64 @@
+From c35a3f519007af44c3b364b9af86f6a336f6411b Mon Sep 17 00:00:00 2001
+From: Thiago Macieira <thiago.macieira@intel.com>
+Date: Tue, 11 Feb 2014 16:17:46 -0800
+Subject: [PATCH] Redo the Q_FOREACH loop control without GCC statement
+ expressions
+
+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@woboq.com>
+Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
+
+Backported to Qt 4
+
+--- a/src/corelib/global/qglobal.h
++++ b/src/corelib/global/qglobal.h
+@@ -2482,22 +2482,32 @@ 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
+