Repository: spack/spack

Issue:
qt+webkit does not build
<!-- Explain, in a clear and concise way, the command you ran and the result you were trying to achieve.
Example: "I ran `spack find` to list all the installed packages and ..." -->

I wanted to build qt+webkit but ran into multiple problems. I need version 5.12.10 as a dependency for a package I want to build.

I tried to build 
```
$ spack install qt+webkit@5.12.10 %gcc@10.3.0
```
the first problem is that the python2 requirement is not set. This can easily be fixed by

```diff
-    depends_on("python@2.7.5:2.999", when='@5.14: +webkit', type='build')
+    depends_on("python@2.7.5:2.999", when='+webkit', type='build')
```

Then qt builds but webengine does not due to a missing mesa dependency
```
khronos development headers appear to be missing (mesa/libegl1-mesa-dev)
QtWebEngine will not be built.
```

When building `qt+webkit+opengl@5.12.10 %gcc10.3.0` (since gl has a mesa dependency), now nss is missing
```
A suitable version of nss could not be found.
QtWebEngine will not be built.
```
but nss is not in spack

Also the following combinations build qt (with the fix above) but do not build webengine
- `qt+webkit@5.14.2 %gcc@9.3.0` -> missing mesa
- `qt+webkit@5.15.2 %gcc@9.3.0` -> missing nss

I tried these combinations because I found them in #17270

Then I tried the most current combination `qt+webkit@5.15.2 %gcc@11.1.0` but here qt does not build.

@sethrj maybe you can help

### Information on your system

<!-- Please include the output of `spack debug report` -->

* **Spack:** 0.13.4-8281-849943c63d
* **Python:** 3.5.3
* **Platform:** linux-debian9-piledriver
* **Concretizer:** clingo

<!-- If you have any relevant configuration detail (custom `packages.yaml` or `modules.yaml`, etc.) you can add that here as well. -->

### Additional information

<!-- These boxes can be checked by replacing [ ] with [x] or by clicking them after submitting the issue. -->
- [x] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [x] I have searched the issues of this repo and believe this is not a duplicate
- [ ] I have run the failing commands in debug mode and reported the output

<!-- We encourage you to try, as much as possible, to reduce your problem to the minimal example that still reproduces the issue. That would help us a lot in fixing it quickly and effectively!

If you want to ask a question about the tool (how to use it, what it can currently do, etc.), try the `#general` channel on our Slack first. We have a welcoming community and chances are you'll get your reply faster and without opening an issue.

Other than that, thanks for taking the time to contribute to Spack! -->



Discussion:
OK, thanks for the  bump to the  'conflicts' version: when I add conflicts I try to only add them for "known" versions not "suspected". We should also add a conflict for `+webkit ~opengl`.  Could you submit a PR and mention me on it?

As to the next step, can you upload the log files please? Then we can try to track down the next issue.
I was not sure which combination you wanted, so I added all I had. I also rerun the combinations with the patch to get a updated picture.  For my use case I would only need 5.12.10 preferable with gcc 11.

- `qt+webkit+opengl@5.12.10 %gcc@9.3.0`
   with full patch applied

  -> webengine does not build

  [spack-build-out.txt](https://cloud.ovgu.de/s/EtPPtMD9MRgwASE)

- `qt+webkit+opengl@5.12.10 %gcc@10.3.0`
  with full patch applied

  -> webengine does not build

   [spack-build-out.txt](https://cloud.ovgu.de/s/KMBqSdAEn5H37KZ)

- `qt+webkit+opengl@5.12.10 %gcc@11.1.0`
  with full patch applied

   -> llvm dependency does not build, see #24270

- `qt+webkit@5.15.2 %gcc@11.1.0`
  (only python patch, not conflict)

  -> qt does not build

  [spack-build-out.txt](https://cloud.ovgu.de/s/jbE8N5x4NqQsL3D)

- `qt+webkit+opengl@5.15.2 %gcc@11.1.0`
  with full patch applied

  -> llvm dependency does not build, see #24270
I downloaded the first build output (spack-build-out-qt-5-12-10-gcc-9-3-0) but can't find any actual build errors in it. It looks like it correctly built qtwebengine (which superseded webkit from Qt 5.7+) and successfully finished the qt bulid.

It's not surprising that llvm 10 failed on gcc11... it's the price of compilers geting more strict. Wonder why it didn't use a newer llvm.
Yes that is part of the problem. In the first and second case (gcc 9 and gcc 10) there are no build error for qt itself but it just skips webengine and does not build it
see line 32858 of the gcc 9 (line 33131 of gcc 10):
```
A suitable version of nss could not be found.
QtWebEngine will not be built.
```
Oh there it is... wow that's easy to miss.

From a little googling it looks like you're not the only one with this problem. I don't know why qt errors out so late in the game rather than during configure. And I don't know what nss is...

I'm not sure why the concretizer is picking up an older version of llvm.  Try using `^llvm@11:` and I'll add a PR with the gcc/llvm conflict so the new clingo concretizer will try to find a workaround.  If llvm is coming in through mesa, you can disable that.

But I don't think either of those is going to solve the missing nss  issue. If you can create  a spack package for nss, you can then add `depends_on('nss',  when='@5.7: +webkit')`  to the qt recipe and hope that solves it. I unfortunately lack the time to do that on my own... qt is a beast.

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
@@ -3,13 +3,14 @@
 #
 # SPDX-License-Identifier: (Apache-2.0 OR MIT)
 
-from spack import *
-from spack.operating_systems.mac_os import macos_version
-import llnl.util.tty as tty
 import itertools
 import os
 import sys
 
+import llnl.util.tty as tty
+from spack import *
+from spack.operating_systems.mac_os import macos_version
+
 MACOS_VERSION = macos_version() if sys.platform == 'darwin' else None
 
 
@@ -141,6 +142,10 @@ class Qt(Package):
           sha256='84b099109d08adf177adf9d3542b6215ec3e42138041d523860dbfdcb59fdaae',
           working_dir='qtwebsockets',
           when='@5.14: %gcc@11:')
+    patch('https://src.fedoraproject.org/rpms/qt5-qtwebengine/raw/32062243e895612823b47c2ae9eeb873a98a3542/f/qtwebengine-gcc11.patch',
+          sha256='14e2d6baff0d09a528ee3e2b5a14de160859880360100af75ea17f3e0f672787',
+          working_dir='qtwebengine',
+          when='@5.15.2:+webkit %gcc@11:')
     conflicts('%gcc@10:', when='@5.9:5.12.6 +opengl')
 
     # Build-only dependencies
@@ -179,8 +184,19 @@ class Qt(Package):
     depends_on("pcre2+multibyte", when='@5.9:')
     depends_on("llvm", when='@5.11: +doc')
 
-    # the gl headers are needed to build webkit
+    depends_on("nss", when='@5.7: +webkit')
+    depends_on("libdrm", when='@5.7: +webkit')
+    depends_on("libxcomposite", when='@5.7: +webkit')
+    depends_on("libxcursor", when='@5.7: +webkit')
+    depends_on("libxi", when='@5.7: +webkit')
+    depends_on("libxtst", when='@5.7: +webkit')
+    depends_on("libxrandr", when='@5.7: +webkit')
+    depends_on("libxdamage", when='@5.7: +webkit')
+    depends_on("gettext", when='@5.7: +webkit')
+
+    # the gl headers and dbus are needed to build webkit
     conflicts('~opengl', when='+webkit')
+    conflicts('~dbus', when='+webkit')
 
     # gcc@4 is not supported as of Qt@5.14
     # https://doc.qt.io/qt-5.14/supported-platforms.html
@@ -313,6 +329,14 @@ def get_mkspec(self):
 
         return (mkspec_dir, qtplat)
 
+    # webkit requires libintl (gettext), but does not test for it
+    # correctly, so add it here.
+    def flag_handler(self, name, flags):
+        if '+webkit' in self.spec and name == 'ldlibs':
+            flags.append('-lintl')
+
+        return (flags, None, None)
+
     @when('@4 platform=darwin')
     def patch(self):
         ogl = self.spec['opengl'] if '+opengl' in self.spec else None


Test patch: