Backport patch to fix "too many open files" when linking libLLVM.dll

This commit is contained in:
Sandro Mani 2019-08-07 01:52:08 +02:00
parent 1e9feaa91f
commit 6b333efe67
2 changed files with 166 additions and 2 deletions

View File

@ -0,0 +1,158 @@
diff -rupN binutils-2.32/bfd/config.bfd binutils-2.32-new/bfd/config.bfd
--- binutils-2.32/bfd/config.bfd 2019-01-19 17:01:32.000000000 +0100
+++ binutils-2.32-new/bfd/config.bfd 2019-08-07 01:44:26.018756048 +0200
@@ -217,11 +217,6 @@ esac
# convention, else the table becomes a real mess to understand and maintain.
case "${targ}" in
- plugin)
- targ_defvec=plugin_vec
- targ_selvecs="plugin_vec"
- ;;
-
# START OF targmatch.h
#ifdef BFD64
aarch64-*-darwin*)
diff -rupN binutils-2.32/bfd/configure binutils-2.32-new/bfd/configure
--- binutils-2.32/bfd/configure 2019-02-02 16:47:56.000000000 +0100
+++ binutils-2.32-new/bfd/configure 2019-08-07 01:44:26.020756037 +0200
@@ -12409,10 +12409,6 @@ else
fi
-if test "$plugins" = "yes"; then
- enable_targets="$enable_targets plugin"
-fi
-
# Check whether --enable-64-bit-bfd was given.
if test "${enable_64_bit_bfd+set}" = set; then :
enableval=$enable_64_bit_bfd; case "${enableval}" in
@@ -14580,12 +14576,12 @@ selarchs=
TDEFINES=
for targ in $target $canon_targets
do
- if test "x$targ" = "xall"; then
+ if test $targ = all; then
all_targets=true
assocvecs="$assocvecs $targ_defvec $targ_selvecs"
- else
+ elif test $targ != plugin; then
. $srcdir/config.bfd
- if test "x$targ" = "x$target"; then
+ if test $targ = $target; then
defvec=$targ_defvec
fi
selvecs="$selvecs $targ_defvec $targ_selvecs"
@@ -14820,7 +14816,6 @@ do
pef_xlib_vec) tb="$tb pef.lo" ;;
pj_elf32_vec) tb="$tb elf32-pj.lo elf32.lo $elf" ;;
pj_elf32_le_vec) tb="$tb elf32-pj.lo elf32.lo $elf" ;;
- plugin_vec) tb="$tb plugin.lo" ;;
powerpc_boot_vec) tb="$tb ppcboot.lo" ;;
powerpc_elf32_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
powerpc_elf32_le_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
@@ -14947,6 +14942,10 @@ do
fi
done
+if test "$plugins" = "yes"; then
+ tb="$tb plugin.lo"
+fi
+
# Target architecture .o files.
# A couple of CPUs use shorter file names to avoid problems on DOS
# filesystems.
diff -rupN binutils-2.32/bfd/configure.ac binutils-2.32-new/bfd/configure.ac
--- binutils-2.32/bfd/configure.ac 2019-01-19 17:01:32.000000000 +0100
+++ binutils-2.32-new/bfd/configure.ac 2019-08-07 01:44:26.020756037 +0200
@@ -46,10 +46,6 @@ ACX_LARGEFILE
AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
-if test "$plugins" = "yes"; then
- enable_targets="$enable_targets plugin"
-fi
-
AC_ARG_ENABLE(64-bit-bfd,
[ --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)],
[case "${enableval}" in
@@ -348,12 +344,12 @@ selarchs=
TDEFINES=
for targ in $target $canon_targets
do
- if test "x$targ" = "xall"; then
+ if test $targ = all; then
all_targets=true
assocvecs="$assocvecs $targ_defvec $targ_selvecs"
- else
+ elif test $targ != plugin; then
. $srcdir/config.bfd
- if test "x$targ" = "x$target"; then
+ if test $targ = $target; then
defvec=$targ_defvec
fi
selvecs="$selvecs $targ_defvec $targ_selvecs"
@@ -588,7 +584,6 @@ do
pef_xlib_vec) tb="$tb pef.lo" ;;
pj_elf32_vec) tb="$tb elf32-pj.lo elf32.lo $elf" ;;
pj_elf32_le_vec) tb="$tb elf32-pj.lo elf32.lo $elf" ;;
- plugin_vec) tb="$tb plugin.lo" ;;
powerpc_boot_vec) tb="$tb ppcboot.lo" ;;
powerpc_elf32_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
powerpc_elf32_le_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
@@ -715,6 +710,10 @@ do
fi
done
+if test "$plugins" = "yes"; then
+ tb="$tb plugin.lo"
+fi
+
# Target architecture .o files.
# A couple of CPUs use shorter file names to avoid problems on DOS
# filesystems.
diff -rupN binutils-2.32/bfd/format.c binutils-2.32-new/bfd/format.c
--- binutils-2.32/bfd/format.c 2019-01-19 17:01:33.000000000 +0100
+++ binutils-2.32-new/bfd/format.c 2019-08-07 01:44:26.021756031 +0200
@@ -290,8 +290,15 @@ bfd_check_format_matches (bfd *abfd, bfd
{
const bfd_target *temp;
- /* Don't check the default target twice. */
+ /* The binary target matches anything, so don't return it when
+ searching. Don't match the plugin target if we have another
+ alternative since we want to properly set the input format
+ before allowing a plugin to claim the file. Also, don't
+ check the default target twice. */
if (*target == &binary_vec
+#if BFD_SUPPORTS_PLUGINS
+ || (match_count != 0 && *target == &plugin_vec)
+#endif
|| (!abfd->target_defaulted && *target == save_targ))
continue;
diff -rupN binutils-2.32/bfd/targets.c binutils-2.32-new/bfd/targets.c
--- binutils-2.32/bfd/targets.c 2019-01-19 17:01:33.000000000 +0100
+++ binutils-2.32-new/bfd/targets.c 2019-08-07 01:44:26.021756031 +0200
@@ -1142,10 +1142,6 @@ static const bfd_target * const _bfd_tar
&pj_elf32_vec,
&pj_elf32_le_vec,
-#if BFD_SUPPORTS_PLUGINS
- &plugin_vec,
-#endif
-
&powerpc_boot_vec,
&powerpc_elf32_vec,
&powerpc_elf32_le_vec,
@@ -1298,6 +1294,10 @@ static const bfd_target * const _bfd_tar
/* Likewise for ihex. */
&ihex_vec,
+#if BFD_SUPPORTS_PLUGINS
+ &plugin_vec,
+#endif
+
/* Add any required traditional-core-file-handler. */
#ifdef AIX386_CORE

View File

@ -2,14 +2,17 @@
Name: mingw-binutils
Version: 2.32
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Cross-compiled version of binutils for Win32 and Win64 environments
License: GPLv2+ and LGPLv2+ and GPLv3+ and LGPLv3+
URL: http://www.gnu.org/software/binutils/
Source0: http://ftp.gnu.org/gnu/binutils/binutils-%{version}.tar.bz2
#Source0: http://www.kernel.org/pub/linux/devel/binutils/binutils-%{version}.tar.bz2
# Backport https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=999d6dff80fab12d22c2a8d91923db6bde7fb3e5
# Fixes "too many open files" when linking libLLVM.dll
Patch0: 0001-Plugin-target-handling.patch
BuildRequires: gcc
BuildRequires: flex
@ -251,6 +254,9 @@ rm -rf $RPM_BUILD_ROOT/multilib
%changelog
* Wed Aug 07 2019 Sandro Mani <manisandro@gmail.com> - 2.32-4
- Backport patch to fix "too many open files" when linking libLLVM.dll
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.32-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild