Repository: spack/spack

Issue:
Installation issue: Qt-5.13.1 fails to compile with gcc@9.2.0
**Summary**: I'm having trouble building new versions of qt on RHEL7 with gcc.

### Steps to reproduce the issue

```console
$ spack install gcc@9.2.0 # system gcc is 4.8.5
$ spack load gcc@9.2.0
$ spack compiler add
$ spack install qt+phonon+dbus % gcc@9.2.0

c++ -c -pipe -O3 -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC -DQT_NO_USING_NAMESPACE -DQT_NO_FOREACH -DELF_INTERPRETER=\"/lib64/ld-linux-x86-64.so.2\" -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_BUILD_CORE_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -I. -Iglobal -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I../3rdparty/sha3 -I../3rdparty/forkfd -I../3rdparty/tinycbor/src -I../../include -I../../include/QtCore -I../../include/QtCore/5.13.1 -I../../include/QtCore/5.13.1/QtCore -I.moc -I.tracegen -I/scratch/kellyt/spack.20191014/opt/spack/linux-rhel7-sandybridge/gcc-9.2.0/pcre2-10.31-pbuwezgctqeaunjz2mrf3fgn3m6zluax/include -I/scratch/kellyt/spack.20191014/opt/spack/linux-rhel7-sandybridge/gcc-9.2.0/pcre-8.42-is6tuvst2le4ffdebo3p23xveehybedz/include -I/scratch/kellyt/spack.20191014/opt/spack/linux-rhel7-sandybridge/gcc-9.2.0/glib-2.56.3-77japfj2uel7kr47a5x6qohsb4tazrgq/include/glib-2.0 -I/scratch/kellyt/spack.20191014/opt/spack/linux-rhel7-sandybridge/gcc-9.2.0/glib-2.56.3-77japfj2uel7kr47a5x6qohsb4tazrgq/lib/glib-2.0/include -I/scratch/kellyt/spack.20191014/opt/spack/linux-rhel7-sandybridge/gcc-9.2.0/openssl-1.1.1d-uuzeqmzia5ivvdsj5s4s4vm6vnlae75v/include -I/scratch/kellyt/spack.20191014/opt/spack/linux-rhel7-sandybridge/gcc-9.2.0/freetype-2.10.1-t4kofzc5375dozscay3xzgkf6ekrmxqp/include/freetype2 -I/scratch/kellyt/spack.20191014/opt/spack/linux-rhel7-sandybridge/gcc-9.2.0/harfbuzz-2.3.1-4lu57m5su3aialmfdik6rt3i2t32trnf/include -I/scratch/kellyt/spack.20191014/opt/spack/linux-rhel7-sandybridge/gcc-9.2.0/pcre2-10.31-pbuwezgctqeaunjz2mrf3fgn3m6zluax/include -I/scratch/kellyt/spack.20191014/opt/spack/linux-rhel7-sandybridge/gcc-9.2.0/double-conversion-2.0.1-v4yhhqbnqfaitwqg6qw7nhv6gkdztg7r/include -I/scratch/kellyt/spack.20191014/opt/spack/linux-rhel7-sandybridge/gcc-9.2.0/libpng-1.6.37-zld7juxatidfsvqcu3vkzagnxbz7sc7i/include -I/scratch/kellyt/spack.20191014/opt/spack/linux-rhel7-sandybridge/gcc-9.2.0/libjpeg-turbo-2.0.3-ewjs45p5vlkamqra74j4qe2gl4j2mafb/include -I/scratch/kellyt/spack.20191014/opt/spack/linux-rhel7-sandybridge/gcc-9.2.0/zlib-1.2.11-ekcbncuah46gxhmanj2eyniybfrm6ipc/include -I/scratch/kellyt/spack.20191014/opt/spack/linux-rhel7-sandybridge/gcc-9.2.0/dbus-1.12.8-upwxr4uv7uu3j2hkrq3f3rb3wodqdnql/lib/dbus-1.0/include -I/scratch/kellyt/spack.20191014/opt/spack/linux-rhel7-sandybridge/gcc-9.2.0/dbus-1.12.8-upwxr4uv7uu3j2hkrq3f3rb3wodqdnql/include/dbus-1.0 -I../../mkspecs/linux-g++ -o .obj/qmutex.o thread/qmutex.cpp
thread/qatomic.cpp:1624:4: error: #error "Q_ATOMIC_INT64_IS_SUPPORTED must be defined on a 64-bit platform"
 1624 | #  error "Q_ATOMIC_INT64_IS_SUPPORTED must be defined on a 64-bit platform"
      |    ^~~~~
```

### Platform and user environment

Please report your OS here:
```commandline
$ uname -a 
Linux xxx 3.10.0-1062.1.2.el7.x86_64 #1 SMP Mon Sep 16 14:19:51 EDT 2019 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -d
Description:	Red Hat Enterprise Linux Workstation release 7.7 (Maipo)
``` 
### Additional information

* I had the same error for `qt@5.12.5 % gcc@9.2.0` and  `qt@5.13.1 % gcc@8.3.0` .
* I was able to build `qt@5.11.3 % gcc@8.1.0`, but I need version `5.12:`
* Google doesn't show any relevant hits for this failure mode.



Discussion:
I had the same problem before #12765 was merged. Does your checkout include that PR already?
@michaelkuhn I just double checked the code base that I am using.  Indeed, I already have #12765 merged into my _spack_ sandbox and I am still getting this error.  Also, after that initial error, I see a bunch of these related errors:

```console
In file included from ../../include/QtCore/qglobal.h:1,
                 from thread/qatomic.h:41,
                 from thread/qatomic.cpp:41:
../../include/QtCore/../../src/corelib/thread/qbasicatomic.h: In instantiation of 'class QBasicAtomicInteger<long int>':
../../include/QtCore/../../src/corelib/thread/qatomic.h:55:7:   required from 'class QAtomicInteger<long int>'
thread/qatomic.cpp:1631:1:   required from here
../../include/QtCore/../../src/corelib/global/qglobal.h:121:63: error: static assertion failed: template parameter is an integral of a size not supported on this platform
  121 | #  define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
      |                                                               ^~~~~~~~~~~~~~~
../../include/QtCore/../../src/corelib/thread/qbasicatomic.h:97:5: note: in expansion of macro 'Q_STATIC_ASSERT_X'
   97 |     Q_STATIC_ASSERT_X(QAtomicOpsSupport<sizeof(T)>::IsSupported, "template parameter is an integral of a size not supported on this platform");
      |     ^~~~~~~~~~~~~~~~~
```
> @michaelkuhn I just double checked the code base that I am using. Indeed, I already have #12765 merged into my _spack_ sandbox and I am still getting this error. Also, after that initial error, I see a bunch of these related errors:

Strange. These errors apparently stem from the fact that configure cannot find libatomic (which is provided by GCC). I hacked around this locally but then configure cannot find some other system libraries (I think it was libdl). Since #12765 fixed it for me, I gave up creating a workaround.
* [Possibly related information](https://bugreports.qt.io/browse/QTBUG-46949?jql=text%20~%20%22Q_ATOMIC_INT64_IS_SUPPORTED%22) - but for older Qt versions.  

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/qt/package.py b/var/spack/repos/builtin/packages/qt/package.py
--- a/var/spack/repos/builtin/packages/qt/package.py
+++ b/var/spack/repos/builtin/packages/qt/package.py
@@ -294,8 +294,6 @@ def patch(self):
     @when('@5')
     def patch(self):
         # Fix qmake compilers in the default mkspec
-        filter_file('^QMAKE_COMPILER .*', 'QMAKE_COMPILER = cc',
-                    'qtbase/mkspecs/common/g++-base.conf')
         filter_file('^QMAKE_CC .*', 'QMAKE_CC = cc',
                     'qtbase/mkspecs/common/g++-base.conf')
         filter_file('^QMAKE_CXX .*', 'QMAKE_CXX = c++',


Test patch: