Hi,
There's a bug in binutils 1.37, which we are using on the
core-updates-frozen branch.
It's a file descriptor leak that can lead to 'malformed archive' errors
when linking libraries. We get this problem at least when building
qtwekbit and qtwebengine. A workaround allows us to compile qtwebkit
(see [1]), but it doesn't work for qtwebengine.
The bug was discussed at [2] and upstream has a patch to fix it at [3].
However, adding this patch to our binutils rebuilds the world.
I'm currently trying to build things with the patched binutils.
If everything works, should I push this fix on core-updates-frozen, or
does someone have an idea that would lead to less rebuilds?
P.S.: The patch I'm trying is in attachment.
From d90e95640f0c2bd3271e370516e51fac56929be7 Mon Sep 17 00:00:00 2001
From: Guillaume Le Vaillant
Date: Mon, 6 Sep 2021 17:32:38 +0200
Subject: [PATCH] gnu: binutils: Fix file decriptor leak.
* gnu/packages/patches/binutils-1.37-file-descriptor-leak.patch: New file.
* gnu/packages/local.mk (dist_patch_DATA): Add it.
* gnu/packages/base.scm (binutils)[source]: Use it.
---
gnu/local.mk | 1 +
gnu/packages/base.scm | 17 +-
.../binutils-1.37-file-descriptor-leak.patch | 231 ++
3 files changed, 241 insertions(+), 8 deletions(-)
create mode 100644 gnu/packages/patches/binutils-1.37-file-descriptor-leak.patch
diff --git a/gnu/local.mk b/gnu/local.mk
index 8c41b5b676..5814587ef2 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -884,6 +884,7 @@ dist_patch_DATA = \
%D%/packages/patches/behave-skip-a-couple-of-tests.patch \
%D%/packages/patches/beignet-correct-file-names.patch \
%D%/packages/patches/bidiv-update-fribidi.patch \
+ %D%/packages/patches/binutils-1.37-file-descriptor-leak.patch \
%D%/packages/patches/binutils-boot-2.20.1a.patch \
%D%/packages/patches/binutils-loongson-workaround.patch \
%D%/packages/patches/binutils-mingw-w64-timestamp.patch \
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index b9841a5cef..f5486c6aae 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -510,14 +510,15 @@ change. GNU make offers many powerful extensions over the standard utility.")
(package
(name "binutils")
(version "2.37")
- (source (origin
-(method url-fetch)
-(uri (string-append "mirror://gnu/binutils/binutils-"
-version ".tar.bz2"))
-(sha256
- (base32
- "1m3b2rdfv1dmdpd0bzg1hy7i8a2qng53szc6livyi3nh6101mz37"))
-(patches (search-patches "binutils-loongson-workaround.patch"
+ (source
+(origin
+ (method url-fetch)
+ (uri (string-append "mirror://gnu/binutils/binutils-"
+ version ".tar.bz2"))
+ (sha256
+ (base32 "1m3b2rdfv1dmdpd0bzg1hy7i8a2qng53szc6livyi3nh6101mz37"))
+ (patches (search-patches "binutils-loongson-workaround.patch"
+ "binutils-1.37-file-descriptor-leak.patch"
(build-system gnu-build-system)
;; TODO: Add dependency on zlib + those for Gold.
diff --git a/gnu/packages/patches/binutils-1.37-file-descriptor-leak.patch b/gnu/packages/patches/binutils-1.37-file-descriptor-leak.patch
new file mode 100644
index 00..1fd3d3d9b7
--- /dev/null
+++ b/gnu/packages/patches/binutils-1.37-file-descriptor-leak.patch
@@ -0,0 +1,231 @@
+From 1c611b40e6bfc8029bff7696814330b5bc0ee5c0 Mon Sep 17 00:00:00 2001
+From: "H.J. Lu"
+Date: Mon, 26 Jul 2021 05:59:55 -0700
+Subject: [PATCH] bfd: Close the file descriptor if there is no archive fd
+
+Close the file descriptor if there is no archive plugin file descriptor
+to avoid running out of file descriptors on thin archives with many
+archive members.
+
+bfd/
+
+ PR ld/28138
+ * plugin.c (bfd_plugin_close_file_descriptor): Close the file
+ descriptor there is no archive plugin file descriptor.
+
+ld/
+
+ PR ld/28138
+ * testsuite/ld-plugin/lto.exp: Run tmpdir/pr28138 only for
+ native build.
+
+ PR ld/28138
+ * testsuite/ld-plugin/lto.exp: Run ld/28138 tests.
+ * testsuite/ld-plugin/pr28138.c: New file.
+ * testsuite/ld-plugin/pr28138-1.c: Likewise.
+ * testsuite/ld-plugin/pr28138-2.c: Likewise.
+ * testsuite/ld-plugin/pr28138-3.c: Likewise.
+ * testsuite/ld-plugin/pr28138-4.c: Likewise.
+ * testsuite/ld-plugin/pr28138-5.c: Likewise.
+ * testsuite/ld-plugin/pr28138-6.c: Likewise.
+ * testsuite/ld-plugin/pr28138-7.c: Likewise.
+
+(cherry picked from commit 5a98fb7513b559e20dfebdbaa2a471afda3b4742)
+(cherry picked from commit 7dc37e1e1209c80e0bab784df6b6bac335e836f2)
+---
+ bfd/plugin.c | 8 +++
+ ld/testsuite/ld-plugin/lto.exp | 34 ++
+ ld/testsuite/ld-plugin/pr28138-1.c | 6 ++
+ ld/testsuite/ld-plugin/pr28138-2.c | 6 ++
+ ld/testsuite/ld-plugin/pr28138-3.c | 6 ++
+ ld/testsuite/ld-plugin/pr28138-4.c | 6 ++
+