Subject: bug#50014: closed (Re: bug#50014: [core-updates] QtWebKit build failures)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 28 Aug 2021 16:25:02 +0000

Your bug report

#50014: [core-updates] QtWebKit build failures

which was filed against the guix package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
50014: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=50014
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#50014: [core-updates] QtWebKit build failures
From: Guillaume Le Vaillant <[email-masked]>
To: Leo Famulari <[email-masked]>
Cc: [email-masked]
Date: Sat, 28 Aug 2021 16:17:38 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi Leo,

I found the cause of the "error adding symbols: Malformed archive".
It happens because the maximum number of open file descriptors is too
low. I pushed a fix (f3152cf3021892ba7e2f3d837207eb1ee64bfdb6) raising
the limit from 1024 to 4096 in the build phase on top of your 4 patches,
and the build succeeds.

Subject: [core-updates] QtWebKit build failures
From: Leo Famulari <[email-masked]>
To: [email-masked]
Date: Wed, 11 Aug 2021 17:14:40 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

I noticed that QtWebKit fails to build on core-updates due to
incompatibility with current Python, ICU, glib, and bison.

I worked around those issues by cherry-picking upstream fixes
(attached).

However, the build still fails like this:

------
[ 95%] Linking CXX shared library ../../lib/libQt5WebKit.so
cd /tmp/guix-build-qtwebkit-5.212.0-alpha4.drv-0/build/Source/WebKit && /gnu/store/scy8sv893g08nc8bzjibn5l2828xbhcv-perl-5.34.0/bin/perl /tmp/guix-build-qtwebkit-5.212.0-alpha4.drv-0/qtwebkit-5.212.0-alpha4/Tools/qt/generate-version-script.pl 5.15.2 > /tmp/guix-build-qtwebkit-5.212.0-alpha4.drv-0/build/QtWebKit.version
cd /tmp/guix-build-qtwebkit-5.212.0-alpha4.drv-0/build/Source/WebKit && /gnu/store/yb80jc3m4azrylgf7x05v7v1ngwddypc-cmake-minimal-3.20.2/bin/cmake -E cmake_link_script CMakeFiles/WebKit.dir/link.txt --verbose=1
ld: ../../lib/libWebCore.a: error adding symbols: malformed archive
collect2: error: ld returned 1 exit status
make[2]: *** [Source/WebKit/CMakeFiles/WebKit.dir/build.make:2030: lib/libQt5WebKit.so.5.212.0] Error 1
make[2]: Leaving directory '/tmp/guix-build-qtwebkit-5.212.0-alpha4.drv-0/build'
make[1]: *** [CMakeFiles/Makefile2:1612: Source/WebKit/CMakeFiles/WebKit.dir/all] Error 2
make[1]: Leaving directory '/tmp/guix-build-qtwebkit-5.212.0-alpha4.drv-0/build'
make: *** [Makefile:169: all] Error 2
error: in phase 'build': uncaught exception:
%exception #<&invoke-error program: "make" arguments: () exit-status: 2 term-signal: #f stop-signal: #f>
phase `build' failed after 17292.3 seconds
command "make" failed with status 2
builder for `/gnu/store/imqay9l31ma0vrn24gb38qggiv15qp1g-qtwebkit-5.212.0-alpha4.drv' failed with exit code 1
------

Any ideas?
>From 84c78938898c35477f36cf240829727dbe660248 Mon Sep 17 00:00:00 2001
From: Leo Famulari <[email-masked]>
Date: Tue, 10 Aug 2021 15:23:53 -0400
Subject: [PATCH 1/4] gnu: QtWebKit: Fix building with Python 3.9.

* gnu/packages/patches/qtwebkit-fix-building-with-python-3.9.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/qt.scm (qtwebkit)[source]: Use it.
---
 gnu/local.mk                                  |  1 +
 ...twebkit-fix-building-with-python-3.9.patch | 35 +++++++++++++++++++
 gnu/packages/qt.scm                           |  3 +-
 3 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/qtwebkit-fix-building-with-python-3.9.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 35769c6e15..ae0e9f73da 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1645,6 +1645,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/quassel-qt-514-compat.patch		\
   %D%/packages/patches/quickswitch-fix-dmenu-check.patch	\
   %D%/packages/patches/qtwebkit-pbutils-include.patch		\
+  %D%/packages/patches/qtwebkit-fix-building-with-python-3.9.patch	\
   %D%/packages/patches/randomjungle-disable-static-build.patch	\
   %D%/packages/patches/rapicorn-isnan.patch			\
   %D%/packages/patches/rapidjson-gcc-compat.patch		\
diff --git a/gnu/packages/patches/qtwebkit-fix-building-with-python-3.9.patch b/gnu/packages/patches/qtwebkit-fix-building-with-python-3.9.patch
new file mode 100644
index 0000000000..9f9674de33
--- /dev/null
+++ b/gnu/packages/patches/qtwebkit-fix-building-with-python-3.9.patch
@@ -0,0 +1,35 @@
+Fix building with Python 3.9:
+
+https://github.com/qtwebkit/qtwebkit/issues/993
+
+Patch copied from upstream source repository:
+
+https://github.com/qtwebkit/qtwebkit/commit/78360c01c796b6260bf828bc9c8a0ef73c5132fd
+
+From 78360c01c796b6260bf828bc9c8a0ef73c5132fd Mon Sep 17 00:00:00 2001
+From: Konstantin Tokarev <[email-masked]>
+Date: Wed, 3 Jun 2020 15:01:42 +0300
+Subject: [PATCH] Fix compilation with Python 3.9: avoid passing encoding to
+ json.load()
+
+In Python 2.7 UTF-8 is assumed by default, while in Python 3 this argument
+is not supported.
+
+Change-Id: Ic459d60a6b20bc1838d8771bc36ac41614fe61a9
+---
+ Source/JavaScriptCore/generate-bytecode-files | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Source/JavaScriptCore/generate-bytecode-files b/Source/JavaScriptCore/generate-bytecode-files
+index c5dab429c7b0f..af3431275ecf9 100644
+--- a/Source/JavaScriptCore/generate-bytecode-files
++++ b/Source/JavaScriptCore/generate-bytecode-files
+@@ -163,7 +163,7 @@ if __name__ == "__main__":
+         initBytecodesFile = openOrExit(initASMFileName, "w")
+ 
+     try:
+-        bytecodeSections = json.load(bytecodeFile, encoding = "utf-8")
++        bytecodeSections = json.load(bytecodeFile)
+     except:
+         print("Unexpected error parsing {0}: {1}".format(bytecodeJSONFile, sys.exc_info()))
+ 
diff --git a/gnu/packages/qt.scm b/gnu/packages/qt.scm
index f80ea336d8..4482d38a98 100644
--- a/gnu/packages/qt.scm
+++ b/gnu/packages/qt.scm
@@ -2624,7 +2624,8 @@ different kinds of sliders, and much more.")
         (sha256
          (base32
           "1rm9sjkabxna67dl7myx9d9vpdyfxfdhrk9w7b94srkkjbd2d8cw"))
-        (patches (search-patches "qtwebkit-pbutils-include.patch"))))
+        (patches (search-patches "qtwebkit-pbutils-include.patch"
+                                 "qtwebkit-fix-building-with-python-3.9.patch"))))
     (build-system cmake-build-system)
     (native-inputs
      `(("perl" ,perl)
-- 
2.32.0

>From 8660a85abc34ab05c3c7ff6e6813440edfca5bf3 Mon Sep 17 00:00:00 2001
From: Leo Famulari <[email-masked]>
Date: Tue, 10 Aug 2021 18:02:42 -0400
Subject: [PATCH 2/4] gnu: QtWebKit: Fix building with ICU 68.

* gnu/packages/patches/qtwebkit-fix-building-with-icu-68.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/qt.scm (qtwebkit)[source]: Use it
---
 gnu/local.mk                                  |   1 +
 .../qtwebkit-fix-building-with-icu-68.patch   | 152 ++++++++++++++++++
 gnu/packages/qt.scm                           |   1 +
 3 files changed, 154 insertions(+)
 create mode 100644 gnu/packages/patches/qtwebkit-fix-building-with-icu-68.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index ae0e9f73da..190d758516 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1646,6 +1646,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/quickswitch-fix-dmenu-check.patch	\
   %D%/packages/patches/qtwebkit-pbutils-include.patch		\
   %D%/packages/patches/qtwebkit-fix-building-with-python-3.9.patch	\
+  %D%/packages/patches/qtwebkit-fix-building-with-icu-68.patch	\
   %D%/packages/patches/randomjungle-disable-static-build.patch	\
   %D%/packages/patches/rapicorn-isnan.patch			\
   %D%/packages/patches/rapidjson-gcc-compat.patch		\
diff --git a/gnu/packages/patches/qtwebkit-fix-building-with-icu-68.patch b/gnu/packages/patches/qtwebkit-fix-building-with-icu-68.patch
new file mode 100644
index 0000000000..acbfc4c4c8
--- /dev/null
+++ b/gnu/packages/patches/qtwebkit-fix-building-with-icu-68.patch
@@ -0,0 +1,152 @@
+Fix building with ICU > 68.
+
+https://bugs.gentoo.org/753260
+
+Patch adapted from Gentoo:
+
+https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=335f29d266c5b169ff1e781f9851a3a203f3198c
+
+From 335f29d266c5b169ff1e781f9851a3a203f3198c Mon Sep 17 00:00:00 2001
+From: Andreas Sturmlechner <[email-masked]>
+Date: Fri, 6 Nov 2020 09:22:15 +0100
+Subject: dev-qt/qtwebkit: Fix build with ICU-68
+
+Thanks-to: Lars Wendler <[email-masked]>
+Closes: https://bugs.gentoo.org/753260
+Package-Manager: Portage-3.0.9, Repoman-3.0.2
+Signed-off-by: Andreas Sturmlechner <[email-masked]>
+---
+ .../qtwebkit-5.212.0_pre20200309-icu-68.patch      | 120 +++++++++++++++++++++
+ 1 file changed, 120 insertions(+)
+ create mode 100644 dev-qt/qtwebkit/files/qtwebkit-5.212.0_pre20200309-icu-68.patch
+
+(limited to 'dev-qt/qtwebkit/files/qtwebkit-5.212.0_pre20200309-icu-68.patch')
+
+diff --git a/Source/WebCore/platform/text/TextCodecICU.cpp b/Source/WebCore/platform/text/TextCodecICU.cpp
+index dd6ff06..e0f4bd7 100644
+--- a/Source/WebCore/platform/text/TextCodecICU.cpp
++++ b/Source/WebCore/platform/text/TextCodecICU.cpp
+@@ -308,7 +308,7 @@ void TextCodecICU::createICUConverter() const
+     m_converterICU = ucnv_open(m_canonicalConverterName, &err);
+     ASSERT(U_SUCCESS(err));
+     if (m_converterICU)
+-        ucnv_setFallback(m_converterICU, TRUE);
++        ucnv_setFallback(m_converterICU, true);
+ }
+ 
+ int TextCodecICU::decodeToBuffer(UChar* target, UChar* targetLimit, const char*& source, const char* sourceLimit, int32_t* offsets, bool flush, UErrorCode& err)
+diff --git a/Source/WebCore/platform/text/icu/UTextProvider.h b/Source/WebCore/platform/text/icu/UTextProvider.h
+index c254fc4..6d1e1cb 100644
+--- a/Source/WebCore/platform/text/icu/UTextProvider.h
++++ b/Source/WebCore/platform/text/icu/UTextProvider.h
+@@ -80,12 +80,12 @@ inline bool uTextAccessInChunkOrOutOfRange(UText* text, int64_t nativeIndex, int
+             // Ensure chunk offset is well formed if computed offset exceeds int32_t range.
+             ASSERT(offset < std::numeric_limits<int32_t>::max());
+             text->chunkOffset = offset < std::numeric_limits<int32_t>::max() ? static_cast<int32_t>(offset) : 0;
+-            isAccessible = TRUE;
++            isAccessible = true;
+             return true;
+         }
+         if (nativeIndex >= nativeLength && text->chunkNativeLimit == nativeLength) {
+             text->chunkOffset = text->chunkLength;
+-            isAccessible = FALSE;
++            isAccessible = false;
+             return true;
+         }
+     } else {
+@@ -94,12 +94,12 @@ inline bool uTextAccessInChunkOrOutOfRange(UText* text, int64_t nativeIndex, int
+             // Ensure chunk offset is well formed if computed offset exceeds int32_t range.
+             ASSERT(offset < std::numeric_limits<int32_t>::max());
+             text->chunkOffset = offset < std::numeric_limits<int32_t>::max() ? static_cast<int32_t>(offset) : 0;
+-            isAccessible = TRUE;
++            isAccessible = true;
+             return true;
+         }
+         if (nativeIndex <= 0 && !text->chunkNativeStart) {
+             text->chunkOffset = 0;
+-            isAccessible = FALSE;
++            isAccessible = false;
+             return true;
+         }
+     }
+diff --git a/Source/WebCore/platform/text/icu/UTextProviderLatin1.cpp b/Source/WebCore/platform/text/icu/UTextProviderLatin1.cpp
+index cd6852c..6a864b1 100644
+--- a/Source/WebCore/platform/text/icu/UTextProviderLatin1.cpp
++++ b/Source/WebCore/platform/text/icu/UTextProviderLatin1.cpp
+@@ -100,23 +100,23 @@ static UBool uTextLatin1Access(UText* uText, int64_t index, UBool forward)
+         if (index < uText->chunkNativeLimit && index >= uText->chunkNativeStart) {
+             // Already inside the buffer. Set the new offset.
+             uText->chunkOffset = static_cast<int32_t>(index - uText->chunkNativeStart);
+-            return TRUE;
++            return true;
+         }
+         if (index >= length && uText->chunkNativeLimit == length) {
+             // Off the end of the buffer, but we can't get it.
+             uText->chunkOffset = static_cast<int32_t>(index - uText->chunkNativeStart);
+-            return FALSE;
++            return false;
+         }
+     } else {
+         if (index <= uText->chunkNativeLimit && index > uText->chunkNativeStart) {
+             // Already inside the buffer. Set the new offset.
+             uText->chunkOffset = static_cast<int32_t>(index - uText->chunkNativeStart);
+-            return TRUE;
++            return true;
+         }
+         if (!index && !uText->chunkNativeStart) {
+             // Already at the beginning; can't go any farther.
+             uText->chunkOffset = 0;
+-            return FALSE;
++            return false;
+         }
+     }
+     
+@@ -144,7 +144,7 @@ static UBool uTextLatin1Access(UText* uText, int64_t index, UBool forward)
+ 
+     uText->nativeIndexingLimit = uText->chunkLength;
+ 
+-    return TRUE;
++    return true;
+ }
+ 
+ static int32_t uTextLatin1Extract(UText* uText, int64_t start, int64_t limit, UChar* dest, int32_t destCapacity, UErrorCode* status)
+@@ -336,7 +336,7 @@ static int64_t uTextLatin1ContextAwareNativeLength(UText* text)
+ static UBool uTextLatin1ContextAwareAccess(UText* text, int64_t nativeIndex, UBool forward)
+ {
+     if (!text->context)
+-        return FALSE;
++        return false;
+     int64_t nativeLength = uTextLatin1ContextAwareNativeLength(text);
+     UBool isAccessible;
+     if (uTextAccessInChunkOrOutOfRange(text, nativeIndex, nativeLength, forward, isAccessible))
+@@ -356,7 +356,7 @@ static UBool uTextLatin1ContextAwareAccess(UText* text, int64_t nativeIndex, UBo
+         ASSERT(newContext == UTextProviderContext::PriorContext);
+         textLatin1ContextAwareSwitchToPriorContext(text, nativeIndex, nativeLength, forward);
+     }
+-    return TRUE;
++    return true;
+ }
+ 
+ static int32_t uTextLatin1ContextAwareExtract(UText*, int64_t, int64_t, UChar*, int32_t, UErrorCode* errorCode)
+diff --git a/Source/WebCore/platform/text/icu/UTextProviderUTF16.cpp b/Source/WebCore/platform/text/icu/UTextProviderUTF16.cpp
+index 7aaac48..9ae0d36 100644
+--- a/Source/WebCore/platform/text/icu/UTextProviderUTF16.cpp
++++ b/Source/WebCore/platform/text/icu/UTextProviderUTF16.cpp
+@@ -125,7 +125,7 @@ static inline int64_t uTextUTF16ContextAwareNativeLength(UText* text)
+ static UBool uTextUTF16ContextAwareAccess(UText* text, int64_t nativeIndex, UBool forward)
+ {
+     if (!text->context)
+-        return FALSE;
++        return false;
+     int64_t nativeLength = uTextUTF16ContextAwareNativeLength(text);
+     UBool isAccessible;
+     if (uTextAccessInChunkOrOutOfRange(text, nativeIndex, nativeLength, forward, isAccessible))
+@@ -145,7 +145,7 @@ static UBool uTextUTF16ContextAwareAccess(UText* text, int64_t nativeIndex, UBoo
+         ASSERT(newContext == UTextProviderContext::PriorContext);
+         textUTF16ContextAwareSwitchToPriorContext(text, nativeIndex, nativeLength, forward);
+     }
+-    return TRUE;
++    return true;
+ }
+ 
+ static int32_t uTextUTF16ContextAwareExtract(UText*, int64_t, int64_t, UChar*, int32_t, UErrorCode* errorCode)
diff --git a/gnu/packages/qt.scm b/gnu/packages/qt.scm
index 4482d38a98..525fe2f80b 100644
--- a/gnu/packages/qt.scm
+++ b/gnu/packages/qt.scm
@@ -2625,6 +2625,7 @@ different kinds of sliders, and much more.")
          (base32
           "1rm9sjkabxna67dl7myx9d9vpdyfxfdhrk9w7b94srkkjbd2d8cw"))
         (patches (search-patches "qtwebkit-pbutils-include.patch"
+                                 "qtwebkit-fix-building-with-icu-68.patch"
                                  "qtwebkit-fix-building-with-python-3.9.patch"))))
     (build-system cmake-build-system)
     (native-inputs
-- 
2.32.0

>From 52af6e4caa205ee204ad668859be78db818e54c8 Mon Sep 17 00:00:00 2001
From: Leo Famulari <[email-masked]>
Date: Wed, 11 Aug 2021 00:23:02 -0400
Subject: [PATCH 3/4] gnu: QtWebKit: Fix building with glib 2.68.

* gnu/packages/patches/qtwebkit-fix-building-with-glib-2.68.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/qt.scm (qtwebkit)[source]: Use it.
---
 gnu/local.mk                                  |  1 +
 ...qtwebkit-fix-building-with-glib-2.68.patch | 21 +++++++++++++++++++
 gnu/packages/qt.scm                           |  1 +
 3 files changed, 23 insertions(+)
 create mode 100644 gnu/packages/patches/qtwebkit-fix-building-with-glib-2.68.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 190d758516..1f31b70085 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1647,6 +1647,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/qtwebkit-pbutils-include.patch		\
   %D%/packages/patches/qtwebkit-fix-building-with-python-3.9.patch	\
   %D%/packages/patches/qtwebkit-fix-building-with-icu-68.patch	\
+  %D%/packages/patches/qtwebkit-fix-building-with-glib-2.68.patch	\
   %D%/packages/patches/randomjungle-disable-static-build.patch	\
   %D%/packages/patches/rapicorn-isnan.patch			\
   %D%/packages/patches/rapidjson-gcc-compat.patch		\
diff --git a/gnu/packages/patches/qtwebkit-fix-building-with-glib-2.68.patch b/gnu/packages/patches/qtwebkit-fix-building-with-glib-2.68.patch
new file mode 100644
index 0000000000..63840f4bbc
--- /dev/null
+++ b/gnu/packages/patches/qtwebkit-fix-building-with-glib-2.68.patch
@@ -0,0 +1,21 @@
+Fix building with glib 2.68:
+
+https://github.com/qtwebkit/qtwebkit/issues/1057
+
+Patch copied from upstream pull request:
+
+https://github.com/qtwebkit/qtwebkit/pull/1058/commits/5b698ba3faffd4e198a45be9fe74f53307395e4b
+
+diff -aurN qtwebkit-5.212.0-alpha4/Source/WTF/wtf/glib/GRefPtr.h qtwebkit-5.212.0-alpha4-mod/Source/WTF/wtf/glib/GRefPtr.h
+--- qtwebkit-5.212.0-alpha4/Source/WTF/wtf/glib/GRefPtr.h	2020-03-04 18:16:37.000000000 +0100
++++ qtwebkit-5.212.0-alpha4-mod/Source/WTF/wtf/glib/GRefPtr.h	2021-04-05 06:58:44.763328636 +0200
+@@ -29,9 +29,6 @@
+ #include <wtf/RefPtr.h>
+ #include <algorithm>
+ 
+-extern "C" void g_object_unref(gpointer);
+-extern "C" gpointer g_object_ref_sink(gpointer);
+-
+ namespace WTF {
+ 
+ enum GRefPtrAdoptType { GRefPtrAdopt };
diff --git a/gnu/packages/qt.scm b/gnu/packages/qt.scm
index 525fe2f80b..a6b3f65f1f 100644
--- a/gnu/packages/qt.scm
+++ b/gnu/packages/qt.scm
@@ -2625,6 +2625,7 @@ different kinds of sliders, and much more.")
          (base32
           "1rm9sjkabxna67dl7myx9d9vpdyfxfdhrk9w7b94srkkjbd2d8cw"))
         (patches (search-patches "qtwebkit-pbutils-include.patch"
+                                 "qtwebkit-fix-building-with-glib-2.68.patch"
                                  "qtwebkit-fix-building-with-icu-68.patch"
                                  "qtwebkit-fix-building-with-python-3.9.patch"))))
     (build-system cmake-build-system)
-- 
2.32.0

>From f3432fcee181dc1ff2813edf423aff14312245f7 Mon Sep 17 00:00:00 2001
From: Leo Famulari <[email-masked]>
Date: Wed, 11 Aug 2021 11:35:04 -0400
Subject: [PATCH 4/4] gnu: QtWebKit: Fix building with Bison 3.7.

* gnu/packages/patches/qtwebkit-fix-building-with-bison-3.7.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/qt.scm (qtwebkit)[source]: Use it.
---
 gnu/local.mk                                  |  1 +
 ...qtwebkit-fix-building-with-bison-3.7.patch | 54 +++++++++++++++++++
 gnu/packages/qt.scm                           |  1 +
 3 files changed, 56 insertions(+)
 create mode 100644 gnu/packages/patches/qtwebkit-fix-building-with-bison-3.7.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 1f31b70085..239072bd54 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1645,6 +1645,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/quassel-qt-514-compat.patch		\
   %D%/packages/patches/quickswitch-fix-dmenu-check.patch	\
   %D%/packages/patches/qtwebkit-pbutils-include.patch		\
+  %D%/packages/patches/qtwebkit-fix-building-with-bison-3.7.patch \
   %D%/packages/patches/qtwebkit-fix-building-with-python-3.9.patch	\
   %D%/packages/patches/qtwebkit-fix-building-with-icu-68.patch	\
   %D%/packages/patches/qtwebkit-fix-building-with-glib-2.68.patch	\
diff --git a/gnu/packages/patches/qtwebkit-fix-building-with-bison-3.7.patch b/gnu/packages/patches/qtwebkit-fix-building-with-bison-3.7.patch
new file mode 100644
index 0000000000..ddaf8e2849
--- /dev/null
+++ b/gnu/packages/patches/qtwebkit-fix-building-with-bison-3.7.patch
@@ -0,0 +1,54 @@
+Fix build with Bison 3.7
+
+https://bugs.gentoo.org/736499
+
+Patch copied from upstream source repository:
+
+https://github.com/qtwebkit/qtwebkit/commit/d92b11fea65364fefa700249bd3340e0cd4c5b31
+
+From d92b11fea65364fefa700249bd3340e0cd4c5b31 Mon Sep 17 00:00:00 2001
+From: Dmitry Shachnev <[email-masked]>
+Date: Tue, 4 Aug 2020 21:04:06 +0300
+Subject: [PATCH] Let Bison generate the header directly, to fix build with
+ Bison 3.7
+
+Starting with Bison 3.7, the generated C++ file #include's the header
+by default, instead of duplicating it. So we should not delete it.
+
+Remove the code to add #ifdef guards to the header, since Bison adds
+them itself since version 2.6.3.
+---
+ Source/WebCore/css/makegrammar.pl | 21 +--------------------
+ 1 file changed, 1 insertion(+), 20 deletions(-)
+
+diff --git a/Source/WebCore/css/makegrammar.pl b/Source/WebCore/css/makegrammar.pl
+index 5d63b08102eb5..9435701c70612 100644
+--- a/Source/WebCore/css/makegrammar.pl
++++ b/Source/WebCore/css/makegrammar.pl
+@@ -73,25 +73,6 @@
+ }
+ 
+ my $fileBase = File::Spec->join($outputDir, $filename);
+-my @bisonCommand = ($bison, "-d", "-p", $symbolsPrefix, $grammarFilePath, "-o", "$fileBase.cpp");
++my @bisonCommand = ($bison, "--defines=$fileBase.h", "-p", $symbolsPrefix, $grammarFilePath, "-o", "$fileBase.cpp");
+ push @bisonCommand, "--no-lines" if $^O eq "MSWin32"; # Work around bug in bison >= 3.0 on Windows where it puts backslashes into #line directives.
+ system(@bisonCommand) == 0 or die;
+-
+-open HEADER, ">$fileBase.h" or die;
+-print HEADER << "EOF";
+-#ifndef CSSGRAMMAR_H
+-#define CSSGRAMMAR_H
+-EOF
+-
+-open HPP, "<$fileBase.cpp.h" or open HPP, "<$fileBase.hpp" or die;
+-while (<HPP>) {
+-    print HEADER;
+-}
+-close HPP;
+-
+-print HEADER "#endif\n";
+-close HEADER;
+-
+-unlink("$fileBase.cpp.h");
+-unlink("$fileBase.hpp");
+-
diff --git a/gnu/packages/qt.scm b/gnu/packages/qt.scm
index a6b3f65f1f..5c0576c880 100644
--- a/gnu/packages/qt.scm
+++ b/gnu/packages/qt.scm
@@ -2625,6 +2625,7 @@ different kinds of sliders, and much more.")
          (base32
           "1rm9sjkabxna67dl7myx9d9vpdyfxfdhrk9w7b94srkkjbd2d8cw"))
         (patches (search-patches "qtwebkit-pbutils-include.patch"
+                                 "qtwebkit-fix-building-with-bison-3.7.patch"
                                  "qtwebkit-fix-building-with-glib-2.68.patch"
                                  "qtwebkit-fix-building-with-icu-68.patch"
                                  "qtwebkit-fix-building-with-python-3.9.patch"))))
-- 
2.32.0