Repository: spack/spack

Issue:
Recent versions of QT5 do not build with the intel compiler
While working with the qt variant on a package I discovered that QT5 does not compile with the Intel compiler. It seems to be a problem with defining overflow builtins, which may be related to the underlying GCC used with the Intel compiler. Note that PR #14387 sets a `conflicts` directive to help prevent wasted build time.


---

### Steps to reproduce the issue

```console
$ spack install qt %intel ^freetype@2.7.1 ^harfbuzz@2.1.3 ^icu4c@58.2
...
3 errors found in build log:
     76    c++ -c -o qlist.o   -std=c++11 -ffunction-sections -fdata-sections -O2 -g  -I/dev/shm/gpjohnsn/spack-stage-q
           t-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1-s
           zivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/library -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1-szi
           vpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1-sz
           ivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/unix -I/dev/shm/gpjohnsn/spack-stage-qt-5.1
           3.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/win32 -I/dev/shm/gpjohnsn/spack-stage
           -qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/mac -I/dev/shm/gpjohnsn/spack-
           stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include -I/dev/shm/gpjohnsn/spack-stage-qt
           -5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore -I/dev/shm/gpjohnsn/spack-stage-qt-
           5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore/5.13.1 -I/dev/shm/gpjohnsn/spack-sta
           ge-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore/5.13.1/QtCore -I../src/corelib
           /global -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/mkspecs/
           linux-g++ -DQT_VERSION_STR=\"5.13.1\" -DQT_VERSION_MAJOR=5 -DQT_VERSION_MINOR=13 -DQT_VERSION_PATCH=1 -DQT_B
           UILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL -DQT_NO_FOREACH /dev/shm/gpjohnsn/spack-stage-qt-5.13.1-szi
           vpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/src/corelib/tools/qlist.cpp
     77    c++ -c -o qlocale.o   -std=c++11 -ffunction-sections -fdata-sections -O2 -g  -I/dev/shm/gpjohnsn/spack-stage
           -qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1
           -szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/library -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1-s
           zivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1-
           szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/unix -I/dev/shm/gpjohnsn/spack-stage-qt-5
           .13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/win32 -I/dev/shm/gpjohnsn/spack-sta
           ge-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/mac -I/dev/shm/gpjohnsn/spac
           k-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include -I/dev/shm/gpjohnsn/spack-stage-
           qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore -I/dev/shm/gpjohnsn/spack-stage-q
           t-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore/5.13.1 -I/dev/shm/gpjohnsn/spack-s
           tage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore/5.13.1/QtCore -I../src/corel
           ib/global -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/mkspec
           s/linux-g++ -DQT_VERSION_STR=\"5.13.1\" -DQT_VERSION_MAJOR=5 -DQT_VERSION_MINOR=13 -DQT_VERSION_PATCH=1 -DQT
           _BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL -DQT_NO_FOREACH /dev/shm/gpjohnsn/spack-stage-qt-5.13.1-s
           zivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/src/corelib/tools/qlocale.cpp
     78    c++ -c -o qlocale_tools.o   -std=c++11 -ffunction-sections -fdata-sections -O2 -g  -I/dev/shm/gpjohnsn/spack
           -stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake -I/dev/shm/gpjohnsn/spack-stage-qt-
           5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/library -I/dev/shm/gpjohnsn/spack-stage-qt-5.
           13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators -I/dev/shm/gpjohnsn/spack-stage-qt-5
           .13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/unix -I/dev/shm/gpjohnsn/spack-stag
           e-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/win32 -I/dev/shm/gpjohnsn/spa
           ck-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/mac -I/dev/shm/gpjohns
           n/spack-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include -I/dev/shm/gpjohnsn/spack-
           stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore -I/dev/shm/gpjohnsn/spack-s
           tage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore/5.13.1 -I/dev/shm/gpjohnsn/s
           pack-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore/5.13.1/QtCore -I../src
           /corelib/global -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/
           mkspecs/linux-g++ -DQT_VERSION_STR=\"5.13.1\" -DQT_VERSION_MAJOR=5 -DQT_VERSION_MINOR=13 -DQT_VERSION_PATCH=
           1 -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL -DQT_NO_FOREACH /dev/shm/gpjohnsn/spack-stage-qt-5.
           13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/src/corelib/tools/qlocale_tools.cpp
     79    c++ -c -o qmap.o   -std=c++11 -ffunction-sections -fdata-sections -O2 -g  -I/dev/shm/gpjohnsn/spack-stage-qt
           -5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1-sz
           ivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/library -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1-sziv
           polegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1-szi
           vpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/unix -I/dev/shm/gpjohnsn/spack-stage-qt-5.13
           .1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/win32 -I/dev/shm/gpjohnsn/spack-stage-
           qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/mac -I/dev/shm/gpjohnsn/spack-s
           tage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include -I/dev/shm/gpjohnsn/spack-stage-qt-
           5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore -I/dev/shm/gpjohnsn/spack-stage-qt-5
           .13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore/5.13.1 -I/dev/shm/gpjohnsn/spack-stag
           e-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore/5.13.1/QtCore -I../src/corelib/
           global -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/mkspecs/l
           inux-g++ -DQT_VERSION_STR=\"5.13.1\" -DQT_VERSION_MAJOR=5 -DQT_VERSION_MINOR=13 -DQT_VERSION_PATCH=1 -DQT_BU
           ILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL -DQT_NO_FOREACH /dev/shm/gpjohnsn/spack-stage-qt-5.13.1-sziv
           polegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/src/corelib/tools/qmap.cpp
     80    c++ -c -o qregexp.o   -std=c++11 -ffunction-sections -fdata-sections -O2 -g  -I/dev/shm/gpjohnsn/spack-stage
           -qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1
           -szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/library -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1-s
           s/linux-g++ -DQT_VERSION_STR=\"5.13.1\" -DQT_VERSION_MAJOR=5 -DQT_VERSION_MINOR=13 -DQT_VERSION_PATCH=1 -DQT
           _BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL -DQT_NO_FOREACH /dev/shm/gpjohnsn/spack-stage-qt-5.13.1-s
           zivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/src/corelib/tools/qregexp.cpp
     81    c++ -c -o qringbuffer.o   -std=c++11 -ffunction-sections -fdata-sections -O2 -g  -I/dev/shm/gpjohnsn/spack-s
           tage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake -I/dev/shm/gpjohnsn/spack-stage-qt-5.
           13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/library -I/dev/shm/gpjohnsn/spack-stage-qt-5.13
           .1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators -I/dev/shm/gpjohnsn/spack-stage-qt-5.1
           3.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/unix -I/dev/shm/gpjohnsn/spack-stage-
           qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/win32 -I/dev/shm/gpjohnsn/spack
           -stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/qmake/generators/mac -I/dev/shm/gpjohnsn/
           spack-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include -I/dev/shm/gpjohnsn/spack-st
           age-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore -I/dev/shm/gpjohnsn/spack-sta
           ge-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore/5.13.1 -I/dev/shm/gpjohnsn/spa
           ck-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore/5.13.1/QtCore -I../src/c
           orelib/global -I/dev/shm/gpjohnsn/spack-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/mk
           specs/linux-g++ -DQT_VERSION_STR=\"5.13.1\" -DQT_VERSION_MAJOR=5 -DQT_VERSION_MINOR=13 -DQT_VERSION_PATCH=1 
           -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL -DQT_NO_FOREACH /dev/shm/gpjohnsn/spack-stage-qt-5.13
           .1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/src/corelib/tools/qringbuffer.cpp
  >> 82    /dev/shm/gpjohnsn/spack-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore/5.1
           3.1/QtCore/private/../../../../../src/corelib/global/qnumeric_p.h(250): error: argument is incompatible with
            formal parameter
     83      { return __builtin_mul_overflow(v1, v2, r); }
     84               ^
     85    
  >> 86    /dev/shm/gpjohnsn/spack-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/qtbase/include/QtCore/5.1
           3.1/QtCore/private/../../../../../src/corelib/global/qnumeric_p.h(240): error: argument is incompatible with
            formal parameter
     87      { return __builtin_add_overflow(v1, v2, r); }
     88               ^
     89    
     90    compilation aborted for /dev/shm/gpjohnsn/spack-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/q
           tbase/src/corelib/tools/qbytearray.cpp (code 2)
  >> 91    gmake: *** [qbytearray.o] Error 2
     92    gmake: *** Waiting for unfinished jobs....
```
The problem is with the following code in qnumeric_p.h:
```
// Overflow math.                                                                                                       
// This provides efficient implementations for int, unsigned, qsizetype and                                             
// size_t. Implementations for 8- and 16-bit types will work but may not be as                                          
// efficient. Implementations for 64-bit may be missing on 32-bit platforms.                                            
                                                                                                                        
#if (defined(Q_CC_GNU) && (Q_CC_GNU >= 500) || (defined(Q_CC_INTEL) && !defined(Q_OS_WIN))) || QT_HAS_BUILTIN(__builtin_add_overflow)                                                                                                           
// GCC 5, ICC 18, and Clang 3.8 have builtins to detect overflows                                                       
                                                                                                                        
template <typename T> inline                                                                                            
typename std::enable_if<std::is_unsigned<T>::value || std::is_signed<T>::value, bool>::type                             
add_overflow(T v1, T v2, T *r)                                                                                          
{ return __builtin_add_overflow(v1, v2, r); }                                                                           
                                                                                                                        
template <typename T> inline                                                                                            
typename std::enable_if<std::is_unsigned<T>::value || std::is_signed<T>::value, bool>::type                             
sub_overflow(T v1, T v2, T *r)                                                                                          
{ return __builtin_sub_overflow(v1, v2, r); }                                                                           
                                                                                                                        
template <typename T> inline                                                                                            
typename std::enable_if<std::is_unsigned<T>::value || std::is_signed<T>::value, bool>::type                             
mul_overflow(T v1, T v2, T *r)                                                                                          
{ return __builtin_mul_overflow(v1, v2, r); }                                                                           
                                                                                                                        
#else                                                                                                                   
// Generic implementations  
...
```
That looks like the interfaces might be getting mixed up. There is more to it than that though as adding a module to specify a newer version of GCC, yields the following:

```console
...
Info: creating stash file /dev/shm/gpjohnsn/spack-stage-qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw/spack-src/.qmake.stash
Project ERROR: failed to parse default search paths from compiler output
==> Error: ProcessError: Command exited with status 3:
    './configure' '-no-eglfs' '-no-directfb' '-no-gtk' '-prefix' '/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/qt-5.13.1-szivpolegsx2j6hslwuyqkudeufbfhaw' '-v' '-opensource' '-no-opengl' '-release' '-confirm-license' '-openssl-linked' '-L/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/openssl-1.1.1d-vomzrhq3vyt2tkk5bx5nj6avhhei4qx6/lib' '-I/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/openssl-1.1.1d-vomzrhq3vyt2tkk5bx5nj6avhhei4qx6/include' '-optimized-qmake' '-no-pch' '-system-freetype' '-I/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/freetype-2.7.1-glh2o2djvw4vcaffhizchjtjofqf4sfw/include/freetype2' '-fontconfig' '-openssl-linked' '-system-sqlite' '-shared' '-system-harfbuzz' '-L/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/harfbuzz-2.1.3-ggxas5icupgdslvf4kvfyt6rrlsdxmqk/lib' '-I/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/harfbuzz-2.1.3-ggxas5icupgdslvf4kvfyt6rrlsdxmqk/include' '-system-pcre' '-L/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/pcre2-10.31-cbcfe5ynsf5ky7ccezwwc6ngmtnwbxot/lib' '-I/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/pcre2-10.31-cbcfe5ynsf5ky7ccezwwc6ngmtnwbxot/include' '-system-doubleconversion' '-L/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/double-conversion-2.0.1-73vy7slnoduzb5m6rejai6degd5k27oi/lib' '-I/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/double-conversion-2.0.1-73vy7slnoduzb5m6rejai6degd5k27oi/include' '-system-libpng' '-L/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/libpng-1.6.37-iu6mik7x7gbsb2sevn5bffomgkfwu643/lib' '-I/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/libpng-1.6.37-iu6mik7x7gbsb2sevn5bffomgkfwu643/include' '-system-libjpeg' '-L/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/libjpeg-turbo-2.0.3-boohheheifgexzgwwideuon5buoqfxzc/lib64' '-I/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/libjpeg-turbo-2.0.3-boohheheifgexzgwwideuon5buoqfxzc/include' '-system-zlib' '-L/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/zlib-1.2.11-csbova4up62su6pxxlvzqf2tjef233ew/lib' '-I/opt/packages/gpjohnsn/apps/linux-centos7-broadwell/intel-19.0.5.281/zlib-1.2.11-csbova4up62su6pxxlvzqf2tjef233ew/include' '-nomake' 'examples' '-no-dbus' '-system-xcb' '-skip' 'webengine' '-skip' 'webglplugin' '-skip' 'wayland'
```
The qmake.stash file looks correct in this scenario.

```
QMAKE_CXX.QT_COMPILER_STDCXX = 201402L
QMAKE_CXX.QMAKE_ICC_VER = 1900
QMAKE_CXX.QMAKE_ICC_UPDATE_VER = 5
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 6
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 1
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0
QMAKE_CXX.COMPILER_MACROS = \
    QT_COMPILER_STDCXX \
    QMAKE_ICC_VER \
    QMAKE_ICC_UPDATE_VER \
    QMAKE_GCC_MAJOR_VERSION \
    QMAKE_GCC_MINOR_VERSION \
    QMAKE_GCC_PATCH_VERSION
```
Interestingly, I see the same thing when I patch the source to remove the overflow builtins from qnumeric_p.h so that the generic interface is used. 

I see the same behavior with intel-17 and intel-18. So far I have only looked at qt-5.13.1.


### Platform and user environment

```commandline
$ uname -a 
Linux argon-build.hpc 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64 x86_64 x86_64 GNU/Linuxx86_64 x86_64 GNU/Linux
$ lsb_release -d
Description:    CentOS Linux release 7.5.1804 (Core) 
``` 



Discussion:

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
@@ -117,6 +117,10 @@ class Qt(Package):
     patch('qt4-gcc8.3-asm-volatile-fix.patch', when='@4')
     patch('qt5-gcc8.3-asm-volatile-fix.patch', when='@5.0.0:5.12.1')
 
+    # patch overflow builtins
+    patch('qt5_11-intel-overflow.patch', when='@5.11')
+    patch('qt5_12-intel-overflow.patch', when='@5.12:')
+
     # Build-only dependencies
     depends_on("pkgconfig", type='build')
     depends_on("flex", when='+webkit', type='build')
@@ -135,6 +139,7 @@ class Qt(Package):
     depends_on("gtkplus", when='+gtk')
     depends_on("openssl", when='+ssl')
     depends_on("sqlite", when='+sql', type=('build', 'run'))
+    depends_on("sqlite+column_metadata", when='+sql%intel', type=('build', 'run'))
 
     depends_on("libpng@1.2.57", when='@3')
     depends_on("pcre+multibyte", when='@5.0:5.8')
@@ -160,7 +165,8 @@ class Qt(Package):
         depends_on("xcb-util-keysyms")
         depends_on("xcb-util-renderutil")
         depends_on("xcb-util-wm")
-        depends_on("libxext", when='@3:4.99')
+        depends_on("libxext")
+        depends_on("libxrender")
         conflicts('+framework',
                   msg="QT cannot be built as a framework except on macOS.")
     else:
@@ -342,7 +348,11 @@ def common_config_args(self):
             config_args.append('-no-openssl')
 
         if '+sql' in self.spec:
-            config_args.append('-system-sqlite')
+            sqlite = self.spec['sqlite']
+            config_args.extend([
+                '-system-sqlite',
+                '-R', '{0}'.format(sqlite.prefix.lib),
+            ])
         else:
             comps = ['db2', 'ibase', 'oci', 'tds', 'mysql', 'odbc', 'psql',
                      'sqlite', 'sqlite2']
@@ -504,7 +514,7 @@ def configure(self, spec, prefix):
             '-no-directfb',
             '-{0}gtk{1}'.format(
                 '' if '+gtk' in spec else 'no-',
-                '' if version >= Version('5.8') else 'style')
+                '' if version >= Version('5.7') else 'style')
         ])
 
         if MACOS_VERSION:


Test patch: