Repository: spack/spack

Issue:
Installation issue: qt
Can't build QT, was originally trying to build it as a dependency of VTK but when it failed I tried to build it on it's own. Fails at configure stage. Error is `Project ERROR: failed to parse default search paths from compiler output.`

### Steps to reproduce the issue

```console
$ spack install qt@5.13.1%clang
...
==> Installing qt
==> Searching for binary cache of qt
==> Finding buildcaches in /spack/var/spack/cache/build_cache
==> No binary for qt found: installing from source
==> Warning: microarchitecture specific optimizations are not supported yet on mixed compiler toolchains [check clang@8.0.0 for further details]
==> Using cached archive: /spack/var/spack/cache/_source-cache/archive/ad/adf00266dc38352a166a9739f1a24a1e36f1be9c04bf72e16e142a256436974e.tar.xz
==> Staging archive: /tmp/username/spack-stage/spack-stage-qt-5.13.1-xdnaqy3o2zag2pzghikfuxipprel7kfs/qt-everywhere-src-5.13.1.tar.xz
==> Created stage in /tmp/username/spack-stage/spack-stage-qt-5.13.1-xdnaqy3o2zag2pzghikfuxipprel7kfs
==> Applied patch /spack/var/spack/repos/builtin/packages/qt/btn_trigger_happy.patch
==> Applied patch /spack/var/spack/repos/builtin/packages/qt/qt5-pcre.patch
==> Ran patch() for qt
==> Building qt [Package]
==> Executing phase: 'configure'
==> Error: ProcessError: Command exited with status 3:
    './configure' '-no-eglfs' '-no-directfb' '-no-gtk' '-prefix' '/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/qt-5.13.1-xdnaqy3o2zag2pzghikfuxipprel7kfs' '-v' '-opensource' '-no-opengl' '-release' '-confirm-license' '-openssl-linked' '-L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/openssl-1.1.1d-tacmwdgknf5swmnsb6qsholturwwuiev/lib' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/openssl-1.1.1d-tacmwdgknf5swmnsb6qsholturwwuiev/include' '-optimized-qmake' '-no-pch' '-system-freetype' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/freetype-2.10.1-hjzon523uu2w3sisys733h7qi356rg3y/include/freetype2' '-fontconfig' '-openssl-linked' '-system-sqlite' '-shared' '-system-harfbuzz' '-L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/harfbuzz-2.3.1-qlk4hz6nsv327oue2ak2xdtzsaan4e7p/lib' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/harfbuzz-2.3.1-qlk4hz6nsv327oue2ak2xdtzsaan4e7p/include' '-system-pcre' '-L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/pcre2-10.31-3iody5eliq2hnamatvr7vz6zvjzqhqx4/lib' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/pcre2-10.31-3iody5eliq2hnamatvr7vz6zvjzqhqx4/include' '-system-doubleconversion' '-L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/double-conversion-2.0.1-mnmy7qk6ari3fgieie6frrsyxeuyaipb/lib' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/double-conversion-2.0.1-mnmy7qk6ari3fgieie6frrsyxeuyaipb/include' '-system-libpng' '-L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libpng-1.6.37-mqs5wdlxe5ho5gqlgbzxpqbjtessi7ao/lib' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libpng-1.6.37-mqs5wdlxe5ho5gqlgbzxpqbjtessi7ao/include' '-system-libjpeg' '-L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libjpeg-turbo-2.0.3-hcjnapf3miwxnvoi26uh7hxkzb7fbwjm/lib' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libjpeg-turbo-2.0.3-hcjnapf3miwxnvoi26uh7hxkzb7fbwjm/include' '-system-zlib' '-L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/zlib-1.2.11-53b2a2gu5dcn52jeq7p4qhz6jm5j4r6r/lib' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/zlib-1.2.11-53b2a2gu5dcn52jeq7p4qhz6jm5j4r6r/include' '-nomake' 'examples' '-no-dbus' '-system-xcb' '-skip' 'webengine' '-skip' 'webglplugin' '-skip' 'wayland'
See build log for details:
  /tmp/username/spack-stage/spack-stage-qt-5.13.1-xdnaqy3o2zag2pzghikfuxipprel7kfs/spack-build-out.txt

```

### Platform and user environment

```commandline
$ uname -a 
Linux pcname 4.15.0-66-generic #75~16.04.1-Ubuntu SMP Tue Oct 1 14:01:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -d
Description:	Ubuntu 16.04.6 LTS
``` 

### Additional information

The contents of the build log: 

```console
==> Executing phase: 'configure'
==> [2019-11-08-16:41:01.305860] './configure' '-no-eglfs' '-no-directfb' '-no-gtk' '-prefix' '/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/qt-5.13.1-xdnaqy3o2zag2pzghikfuxipprel7kfs' '-v' '-opensource' '-no-opengl' '-release' '-confirm-license' '-openssl-linked' '-L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/openssl-1.1.1d-tacmwdgknf5swmnsb6qsholturwwuiev/lib' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/openssl-1.1.1d-tacmwdgknf5swmnsb6qsholturwwuiev/include' '-optimized-qmake' '-no-pch' '-system-freetype' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/freetype-2.10.1-hjzon523uu2w3sisys733h7qi356rg3y/include/freetype2' '-fontconfig' '-openssl-linked' '-system-sqlite' '-shared' '-system-harfbuzz' '-L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/harfbuzz-2.3.1-qlk4hz6nsv327oue2ak2xdtzsaan4e7p/lib' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/harfbuzz-2.3.1-qlk4hz6nsv327oue2ak2xdtzsaan4e7p/include' '-system-pcre' '-L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/pcre2-10.31-3iody5eliq2hnamatvr7vz6zvjzqhqx4/lib' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/pcre2-10.31-3iody5eliq2hnamatvr7vz6zvjzqhqx4/include' '-system-doubleconversion' '-L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/double-conversion-2.0.1-mnmy7qk6ari3fgieie6frrsyxeuyaipb/lib' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/double-conversion-2.0.1-mnmy7qk6ari3fgieie6frrsyxeuyaipb/include' '-system-libpng' '-L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libpng-1.6.37-mqs5wdlxe5ho5gqlgbzxpqbjtessi7ao/lib' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libpng-1.6.37-mqs5wdlxe5ho5gqlgbzxpqbjtessi7ao/include' '-system-libjpeg' '-L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libjpeg-turbo-2.0.3-hcjnapf3miwxnvoi26uh7hxkzb7fbwjm/lib' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libjpeg-turbo-2.0.3-hcjnapf3miwxnvoi26uh7hxkzb7fbwjm/include' '-system-zlib' '-L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/zlib-1.2.11-53b2a2gu5dcn52jeq7p4qhz6jm5j4r6r/lib' '-I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/zlib-1.2.11-53b2a2gu5dcn52jeq7p4qhz6jm5j4r6r/include' '-nomake' 'examples' '-no-dbus' '-system-xcb' '-skip' 'webengine' '-skip' 'webglplugin' '-skip' 'wayland'
+ cd qtbase
+ /tmp/username/spack-stage/spack-stage-qt-5.13.1-xdnaqy3o2zag2pzghikfuxipprel7kfs/spack-src/qtbase/configure -top-level -no-eglfs -no-directfb -no-gtk -prefix /spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/qt-5.13.1-xdnaqy3o2zag2pzghikfuxipprel7kfs -v -opensource -no-opengl -release -confirm-license -openssl-linked -L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/openssl-1.1.1d-tacmwdgknf5swmnsb6qsholturwwuiev/lib -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/openssl-1.1.1d-tacmwdgknf5swmnsb6qsholturwwuiev/include -optimized-qmake -no-pch -system-freetype -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/freetype-2.10.1-hjzon523uu2w3sisys733h7qi356rg3y/include/freetype2 -fontconfig -openssl-linked -system-sqlite -shared -system-harfbuzz -L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/harfbuzz-2.3.1-qlk4hz6nsv327oue2ak2xdtzsaan4e7p/lib -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/harfbuzz-2.3.1-qlk4hz6nsv327oue2ak2xdtzsaan4e7p/include -system-pcre -L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/pcre2-10.31-3iody5eliq2hnamatvr7vz6zvjzqhqx4/lib -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/pcre2-10.31-3iody5eliq2hnamatvr7vz6zvjzqhqx4/include -system-doubleconversion -L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/double-conversion-2.0.1-mnmy7qk6ari3fgieie6frrsyxeuyaipb/lib -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/double-conversion-2.0.1-mnmy7qk6ari3fgieie6frrsyxeuyaipb/include -system-libpng -L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libpng-1.6.37-mqs5wdlxe5ho5gqlgbzxpqbjtessi7ao/lib -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libpng-1.6.37-mqs5wdlxe5ho5gqlgbzxpqbjtessi7ao/include -system-libjpeg -L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libjpeg-turbo-2.0.3-hcjnapf3miwxnvoi26uh7hxkzb7fbwjm/lib -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libjpeg-turbo-2.0.3-hcjnapf3miwxnvoi26uh7hxkzb7fbwjm/include -system-zlib -L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/zlib-1.2.11-53b2a2gu5dcn52jeq7p4qhz6jm5j4r6r/lib -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/zlib-1.2.11-53b2a2gu5dcn52jeq7p4qhz6jm5j4r6r/include -nomake examples -no-dbus -system-xcb -skip webengine -skip webglplugin -skip wayland
Creating qmake...
c++ -c -o main.o   -std=c++11 -ffunction-sections -fdata-sections -O2 -g  -I/tmp/hdiags/spack-
... 

Info: creating super cache file /tmp/username/spack-stage/spack-stage-qt-5.13.1-xdnaqy3o2zag2pzghikfuxipprel7kfs/spack-src/.qmake.super
Info: creating cache file /tmp/username/spack-stage/spack-stage-qt-5.13.1-xdnaqy3o2zag2pzghikfuxipprel7kfs/spack-src/.qmake.cache
Command line: -no-eglfs -no-directfb -no-gtk -prefix /spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/qt-5.13.1-xdnaqy3o2zag2pzghikfuxipprel7kfs -v -opensource -no-opengl -release -confirm-license -openssl-linked -L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/openssl-1.1.1d-tacmwdgknf5swmnsb6qsholturwwuiev/lib -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/openssl-1.1.1d-tacmwdgknf5swmnsb6qsholturwwuiev/include -optimized-qmake -no-pch -system-freetype -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/freetype-2.10.1-hjzon523uu2w3sisys733h7qi356rg3y/include/freetype2 -fontconfig -openssl-linked -system-sqlite -shared -system-harfbuzz -L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/harfbuzz-2.3.1-qlk4hz6nsv327oue2ak2xdtzsaan4e7p/lib -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/harfbuzz-2.3.1-qlk4hz6nsv327oue2ak2xdtzsaan4e7p/include -system-pcre -L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/pcre2-10.31-3iody5eliq2hnamatvr7vz6zvjzqhqx4/lib -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/pcre2-10.31-3iody5eliq2hnamatvr7vz6zvjzqhqx4/include -system-doubleconversion -L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/double-conversion-2.0.1-mnmy7qk6ari3fgieie6frrsyxeuyaipb/lib -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/double-conversion-2.0.1-mnmy7qk6ari3fgieie6frrsyxeuyaipb/include -system-libpng -L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libpng-1.6.37-mqs5wdlxe5ho5gqlgbzxpqbjtessi7ao/lib -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libpng-1.6.37-mqs5wdlxe5ho5gqlgbzxpqbjtessi7ao/include -system-libjpeg -L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libjpeg-turbo-2.0.3-hcjnapf3miwxnvoi26uh7hxkzb7fbwjm/lib -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/libjpeg-turbo-2.0.3-hcjnapf3miwxnvoi26uh7hxkzb7fbwjm/include -system-zlib -L/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/zlib-1.2.11-53b2a2gu5dcn52jeq7p4qhz6jm5j4r6r/lib -I/spack/opt/spack/linux-ubuntu16.04-skylake/clang-8.0.0/zlib-1.2.11-53b2a2gu5dcn52jeq7p4qhz6jm5j4r6r/include -nomake examples -no-dbus -system-xcb -skip webengine -skip webglplugin -skip wayland
Info: creating stash file /tmp/username/spack-stage/spack-stage-qt-5.13.1-xdnaqy3o2zag2pzghikfuxipprel7kfs/spack-src/.qmake.stash
Project ERROR: failed to parse default search paths from compiler output
```



Discussion:
@michaelkuhn @davydden @sethrj @Sinan81 any ideas?
My guess is that even though you're building with Clang, the QT build system is using the default GCC setting. Perhaps it needs to be configured with `-platform linux-clang-libc++` in the configure line?
Thanks @sethrj ! Edited my local package.py for QT, added `config_args.extend(['-platform', 'linux-clang-libc++'])` under ` @when('@5.7:')` (not ideal but it meant the flag would definitely be appended) and tried to install again. No failure at the configure stage! Just waiting now to see if the build stage succeeds (which may take awhile), will get back to you then.
Build was successful, so as Seth said adding  `-platform linux-clang-libc++` to the configure line fixes the issue. So if this occurs to anyone else then the QT package file just needs to be changed so that this is added (only) when clang is specified on Linux arch. Thanks for your help!
@sethrj @madmissmolly Care to submit a PR to fix this issue?

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
@@ -169,6 +169,9 @@ class Qt(Package):
 
     use_xcode = True
 
+    # Mapping for compilers in the QT 'mkspecs'
+    compiler_mapping = {'intel': 'icc', 'clang': 'clang-libc++', 'gcc': 'g++'}
+
     def url_for_version(self, version):
         # URL keeps getting more complicated with every release
         url = self.list_url
@@ -415,16 +418,31 @@ def common_config_args(self):
         if MACOS_VERSION:
             config_args.append('-{0}framework'.format(
                 '' if '+framework' in self.spec else 'no-'))
-        if '@5:' in self.spec and MACOS_VERSION:
-            config_args.extend([
-                '-no-xcb-xlib',
-                '-no-pulseaudio',
-                '-no-alsa',
-            ])
-            if self.spec.satisfies('@:5.11'):
-                config_args.append('-no-xinput2')
 
-        # FIXME: else: -system-xcb ?
+        # Note: QT defaults to the following compilers
+        #  QT4 mac: gcc
+        #  QT5 mac: clang
+        #  linux: gcc
+        # In QT4, unsupported compilers lived under an 'unsupported'
+        # subdirectory but are now in the main platform directory.
+        spec = self.spec
+        cname = spec.compiler.name
+        cname = self.compiler_mapping.get(cname, cname)
+        is_new_qt = spec.satisfies('@5:')
+        platform = None
+        if MACOS_VERSION:
+            if is_new_qt and cname != "clang-libc++":
+                platform = 'macx-' + cname
+            elif not is_new_qt and cname != "g++":
+                platform = 'unsupported/macx-' + cname
+        elif cname != 'g++':
+            if is_new_qt:
+                platform = 'linux-' + cname
+            else:
+                platform = 'unsupported/linux-' + cname
+
+        if platform is not None:
+            config_args.extend(['-platform', platform])
 
         return config_args
 
@@ -472,51 +490,56 @@ def configure(self, spec, prefix):
             sdkpath = which('xcrun')('--show-sdk-path', output=str).strip()
             config_args.extend([
                 '-cocoa',
-                '-platform', 'unsupported/macx-clang-libc++',
                 '-sdk', sdkpath])
 
         configure(*config_args)
 
-    @when('@5.0:5.6')
-    def configure(self, spec, prefix):
-        webkit_args = [] if '+webkit' in spec else ['-skip', 'qtwebkit']
-        configure('-no-eglfs',
-                  '-no-directfb',
-                  '-{0}gtkstyle'.format('' if '+gtk' in spec else 'no-'),
-                  *(webkit_args + self.common_config_args))
-
-    @when('@5.7:')
+    @when('@5')
     def configure(self, spec, prefix):
         config_args = self.common_config_args
+        version = self.version
+
+        config_args.extend([
+            '-no-eglfs',
+            '-no-directfb',
+            '-{0}gtk{1}'.format(
+                '' if '+gtk' in spec else 'no-',
+                '' if version >= Version('5.8') else 'style')
+        ])
 
-        if not MACOS_VERSION:
+        if MACOS_VERSION:
             config_args.extend([
-                '-system-xcb',
+                '-no-xcb-xlib',
+                '-no-pulseaudio',
+                '-no-alsa',
             ])
+            if version < Version('5.12'):
+                config_args.append('-no-xinput2')
+        else:
+            # Linux-only QT5 dependencies
+            config_args.append('-system-xcb')
 
         if '~webkit' in spec:
             config_args.extend([
-                '-skip', 'webengine',
+                '-skip',
+                'webengine' if version >= Version('5.7') else 'qtwebkit',
             ])
 
-        if '~opengl' in spec and spec.satisfies('@5.10:'):
-            config_args.extend([
-                '-skip', 'webglplugin',
-            ])
+        if spec.satisfies('@5.7'):
+            config_args.extend(['-skip', 'virtualkeyboard'])
 
-        if self.version > Version('5.8'):
+        if version >= Version('5.8'):
             # relies on a system installed wayland, i.e. no spack package yet
             # https://wayland.freedesktop.org/ubuntu16.04.html
             # https://wiki.qt.io/QtWayland
             config_args.extend(['-skip', 'wayland'])
 
-        if spec.satisfies('@5.7'):
-            config_args.extend(['-skip', 'virtualkeyboard'])
+        if version >= Version('5.10') and '~opengl' in spec:
+            config_args.extend([
+                '-skip', 'webglplugin',
+            ])
 
-        configure('-no-eglfs',
-                  '-no-directfb',
-                  '-{0}gtk'.format('' if '+gtk' in spec else 'no-'),
-                  *config_args)
+        configure(*config_args)
 
     def build(self, spec, prefix):
         make()


Test patch: