about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorSergei Trofimovich <slyich@gmail.com>2023-01-29 09:50:57 +0000
committerGitHub <noreply@github.com>2023-01-29 09:50:57 +0000
commit0ba9da441dbbfe9b0307266b851c7b9d72167e75 (patch)
treef7816fef2a36f3c50a25f2d14d7f1698494206d5 /pkgs
parent8932edc3de8f8d9ec0065f1baf554635f6cbc384 (diff)
parente1ef521cffc21c8161582b439789c2377b67f428 (diff)
Merge pull request #211126 from trofi/binutils-update
binutils: 2.39 -> 2.40
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/compilers/llvm/10/llvm/default.nix3
-rw-r--r--pkgs/development/compilers/llvm/11/llvm/default.nix3
-rw-r--r--pkgs/development/compilers/llvm/12/llvm/default.nix3
-rw-r--r--pkgs/development/compilers/llvm/5/llvm/default.nix6
-rw-r--r--pkgs/development/compilers/llvm/6/llvm/default.nix3
-rw-r--r--pkgs/development/compilers/llvm/7/llvm/default.nix3
-rw-r--r--pkgs/development/compilers/llvm/8/llvm/default.nix3
-rw-r--r--pkgs/development/compilers/llvm/9/llvm/default.nix3
-rw-r--r--pkgs/development/compilers/llvm/git/llvm/default.nix3
-rw-r--r--pkgs/development/tools/misc/binutils/build-components-separately.patch155
-rw-r--r--pkgs/development/tools/misc/binutils/default.nix30
-rw-r--r--pkgs/development/tools/misc/binutils/gas-dwarf-zero-PR29451.patch71
-rw-r--r--pkgs/development/tools/misc/binutils/libbfd.nix47
-rw-r--r--pkgs/development/tools/misc/binutils/libopcodes.nix42
-rw-r--r--pkgs/development/tools/misc/binutils/plugins-no-BINDIR.patch25
-rw-r--r--pkgs/development/tools/misc/pahole/default.nix9
-rw-r--r--pkgs/stdenv/darwin/default.nix1
-rw-r--r--pkgs/top-level/all-packages.nix8
18 files changed, 98 insertions, 320 deletions
diff --git a/pkgs/development/compilers/llvm/10/llvm/default.nix b/pkgs/development/compilers/llvm/10/llvm/default.nix
index 95eba5d7fb36e..5cae255b58256 100644
--- a/pkgs/development/compilers/llvm/10/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/10/llvm/default.nix
@@ -5,6 +5,7 @@
 , cmake
 , python3
 , libffi
+, enableGoldPlugin ? (!stdenv.isDarwin && !stdenv.targetPlatform.isWasi)
 , libbfd
 , libpfm
 , libxml2
@@ -191,7 +192,7 @@ in stdenv.mkDerivation (rec {
     "-DSPHINX_OUTPUT_MAN=ON"
     "-DSPHINX_OUTPUT_HTML=OFF"
     "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-  ] ++ optionals (!isDarwin) [
+  ] ++ optionals (enableGoldPlugin) [
     "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
   ] ++ optionals isDarwin [
     "-DLLVM_ENABLE_LIBCXX=ON"
diff --git a/pkgs/development/compilers/llvm/11/llvm/default.nix b/pkgs/development/compilers/llvm/11/llvm/default.nix
index 2123efdf23519..67f23bfa6604e 100644
--- a/pkgs/development/compilers/llvm/11/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/11/llvm/default.nix
@@ -5,6 +5,7 @@
 , cmake
 , python3
 , libffi
+, enableGoldPlugin ? (!stdenv.isDarwin && !stdenv.targetPlatform.isWasi)
 , libbfd
 , libpfm
 , libxml2
@@ -203,7 +204,7 @@ in stdenv.mkDerivation (rec {
     "-DSPHINX_OUTPUT_MAN=ON"
     "-DSPHINX_OUTPUT_HTML=OFF"
     "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-  ] ++ optionals (!isDarwin) [
+  ] ++ optionals (enableGoldPlugin) [
     "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
   ] ++ optionals isDarwin [
     "-DLLVM_ENABLE_LIBCXX=ON"
diff --git a/pkgs/development/compilers/llvm/12/llvm/default.nix b/pkgs/development/compilers/llvm/12/llvm/default.nix
index b04eeb3c72693..29f722ae015ac 100644
--- a/pkgs/development/compilers/llvm/12/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/12/llvm/default.nix
@@ -5,6 +5,7 @@
 , cmake
 , python3
 , libffi
+, enableGoldPlugin ? (!stdenv.isDarwin && !stdenv.targetPlatform.isWasi)
 , libbfd
 , libpfm
 , libxml2
@@ -191,7 +192,7 @@ in stdenv.mkDerivation (rec {
     "-DSPHINX_OUTPUT_MAN=ON"
     "-DSPHINX_OUTPUT_HTML=OFF"
     "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-  ] ++ optionals (!isDarwin) [
+  ] ++ optionals (enableGoldPlugin) [
     "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
   ] ++ optionals isDarwin [
     "-DLLVM_ENABLE_LIBCXX=ON"
diff --git a/pkgs/development/compilers/llvm/5/llvm/default.nix b/pkgs/development/compilers/llvm/5/llvm/default.nix
index a4d04f0618c7e..45cf4ca90dd8e 100644
--- a/pkgs/development/compilers/llvm/5/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/5/llvm/default.nix
@@ -5,6 +5,7 @@
 , cmake
 , python3
 , libffi
+, enableGoldPlugin ? (!stdenv.isDarwin && !stdenv.targetPlatform.isWasi)
 , libbfd
 , libxml2
 , ncurses
@@ -168,10 +169,9 @@ stdenv.mkDerivation (rec {
     "-DSPHINX_OUTPUT_MAN=ON"
     "-DSPHINX_OUTPUT_HTML=OFF"
     "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-  ]
-  ++ lib.optional (!isDarwin)
+  ] ++ lib.optionals (enableGoldPlugin) [
     "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
-  ++ lib.optionals (isDarwin) [
+  ] ++ lib.optionals (isDarwin) [
     "-DLLVM_ENABLE_LIBCXX=ON"
     "-DCAN_TARGET_i386=false"
   ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
diff --git a/pkgs/development/compilers/llvm/6/llvm/default.nix b/pkgs/development/compilers/llvm/6/llvm/default.nix
index d18bf2149e1d7..5caeb2381d2de 100644
--- a/pkgs/development/compilers/llvm/6/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/6/llvm/default.nix
@@ -4,6 +4,7 @@
 , cmake
 , python3
 , libffi
+, enableGoldPlugin ? (!stdenv.isDarwin && !stdenv.targetPlatform.isWasi)
 , libbfd
 , libxml2
 , ncurses
@@ -162,7 +163,7 @@ stdenv.mkDerivation (rec {
     "-DSPHINX_OUTPUT_MAN=ON"
     "-DSPHINX_OUTPUT_HTML=OFF"
     "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-  ] ++ optionals (!isDarwin) [
+  ] ++ optionals (enableGoldPlugin) [
     "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
   ] ++ optionals (isDarwin) [
     "-DLLVM_ENABLE_LIBCXX=ON"
diff --git a/pkgs/development/compilers/llvm/7/llvm/default.nix b/pkgs/development/compilers/llvm/7/llvm/default.nix
index da72bb8b35ae3..f06d7bd772c16 100644
--- a/pkgs/development/compilers/llvm/7/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/7/llvm/default.nix
@@ -5,6 +5,7 @@
 , cmake
 , python3
 , libffi
+, enableGoldPlugin ? (!stdenv.isDarwin && !stdenv.targetPlatform.isWasi)
 , libbfd
 , libpfm
 , libxml2
@@ -180,7 +181,7 @@ in stdenv.mkDerivation (rec {
     "-DSPHINX_OUTPUT_MAN=ON"
     "-DSPHINX_OUTPUT_HTML=OFF"
     "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-  ] ++ optionals (!isDarwin) [
+  ] ++ optionals (enableGoldPlugin) [
     "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
   ] ++ optionals (isDarwin) [
     "-DLLVM_ENABLE_LIBCXX=ON"
diff --git a/pkgs/development/compilers/llvm/8/llvm/default.nix b/pkgs/development/compilers/llvm/8/llvm/default.nix
index 5c381a896e152..7e5f705ba7be6 100644
--- a/pkgs/development/compilers/llvm/8/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/8/llvm/default.nix
@@ -5,6 +5,7 @@
 , cmake
 , python3
 , libffi
+, enableGoldPlugin ? (!stdenv.isDarwin && !stdenv.targetPlatform.isWasi)
 , libbfd
 , libpfm
 , libxml2
@@ -173,7 +174,7 @@ in stdenv.mkDerivation (rec {
     "-DSPHINX_OUTPUT_MAN=ON"
     "-DSPHINX_OUTPUT_HTML=OFF"
     "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-  ] ++ optionals (!isDarwin) [
+  ] ++ optionals (enableGoldPlugin) [
     "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
   ] ++ optionals (isDarwin) [
     "-DLLVM_ENABLE_LIBCXX=ON"
diff --git a/pkgs/development/compilers/llvm/9/llvm/default.nix b/pkgs/development/compilers/llvm/9/llvm/default.nix
index f8b6a8170f85a..f97512168031d 100644
--- a/pkgs/development/compilers/llvm/9/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/9/llvm/default.nix
@@ -5,6 +5,7 @@
 , cmake
 , python3
 , libffi
+, enableGoldPlugin ? (!stdenv.isDarwin && !stdenv.targetPlatform.isWasi)
 , libbfd
 , libpfm
 , libxml2
@@ -188,7 +189,7 @@ in stdenv.mkDerivation (rec {
     "-DSPHINX_OUTPUT_MAN=ON"
     "-DSPHINX_OUTPUT_HTML=OFF"
     "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-  ] ++ optionals (!isDarwin) [
+  ] ++ optionals (enableGoldPlugin) [
     "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
   ] ++ optionals (isDarwin) [
     "-DLLVM_ENABLE_LIBCXX=ON"
diff --git a/pkgs/development/compilers/llvm/git/llvm/default.nix b/pkgs/development/compilers/llvm/git/llvm/default.nix
index b4e2757f20ca1..9a0d375df9c37 100644
--- a/pkgs/development/compilers/llvm/git/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/git/llvm/default.nix
@@ -6,6 +6,7 @@
 , cmake
 , python3
 , libffi
+, enableGoldPlugin ? (!stdenv.isDarwin && !stdenv.targetPlatform.isWasi)
 , libbfd
 , libpfm
 , libxml2
@@ -151,7 +152,7 @@ in stdenv.mkDerivation (rec {
     "-DSPHINX_OUTPUT_MAN=ON"
     "-DSPHINX_OUTPUT_HTML=OFF"
     "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
-  ] ++ optionals (!isDarwin) [
+  ] ++ optionals (enableGoldPlugin) [
     "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
   ] ++ optionals isDarwin [
     "-DLLVM_ENABLE_LIBCXX=ON"
diff --git a/pkgs/development/tools/misc/binutils/build-components-separately.patch b/pkgs/development/tools/misc/binutils/build-components-separately.patch
deleted file mode 100644
index 0b4162d848803..0000000000000
--- a/pkgs/development/tools/misc/binutils/build-components-separately.patch
+++ /dev/null
@@ -1,155 +0,0 @@
-diff --git a/bfd/configure.ac b/bfd/configure.ac
-index fec067b2135..377e1f5443f 100644
---- a/bfd/configure.ac
-+++ b/bfd/configure.ac
-@@ -292,30 +292,16 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
- 
- LT_LIB_M
- 
--# When building a shared libbfd, link against the pic version of libiberty
--# so that apps that use libbfd won't need libiberty just to satisfy any
--# libbfd references.
--# We can't do that if a pic libiberty is unavailable since including non-pic
--# code would insert text relocations into libbfd.
- SHARED_LIBADD=
--SHARED_LDFLAGS=
-+SHARED_LDFLAGS=-liberty
- if test "$enable_shared" = "yes"; then
--changequote(,)dnl
--  x=`sed -n -e 's/^[ 	]*PICFLAG[ 	]*=[ 	]*//p' < ../libiberty/Makefile | sed -n '$p'`
--changequote([,])dnl
--  if test -n "$x"; then
--    SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty"
--  fi
--fi
--
- SHARED_LIBADD="$SHARED_LIBADD $LIBINTL"
- 
--if test "$enable_shared" = "yes"; then
-   case "${host}" in
-   # More hacks to build DLLs on Windows.
-   *-*-cygwin*)
-     SHARED_LDFLAGS="-no-undefined"
--    SHARED_LIBADD="-L`pwd`/../libiberty -liberty $SHARED_LIBADD -lcygwin -lkernel32"
-+    SHARED_LIBADD="-liberty $SHARED_LIBADD -lcygwin -lkernel32"
-   ;;
-   esac
- 
-diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
-index 0e04b4c05c4..848a02662e7 100644
---- a/opcodes/Makefile.am
-+++ b/opcodes/Makefile.am
-@@ -51,7 +51,7 @@ libopcodes_la_LDFLAGS += -rpath $(rpath_bfdlibdir)
- endif
- 
- # This is where bfd.h lives.
--BFD_H = ../bfd/bfd.h
-+BFD_H = $(BFDDIR)/bfd.h
- 
- BUILD_LIBS = @BUILD_LIBS@
- BUILD_LIB_DEPS = @BUILD_LIB_DEPS@
-@@ -303,7 +303,7 @@ OFILES = @BFD_MACHINES@
- # development.sh is used to determine -Werror default.
- CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh
- 
--AM_CPPFLAGS = -I. -I$(srcdir) -I../bfd -I$(INCDIR) -I$(BFDDIR) @HDEFINES@ @INCINTL@
-+AM_CPPFLAGS = -I. -I$(srcdir) -I$(INCDIR) -I$(BFDDIR) @HDEFINES@ @INCINTL@
- 
- disassemble.lo: disassemble.c
- if am__fastdepCC
-@@ -327,9 +327,18 @@ libopcodes_la_SOURCES =  dis-buf.c disassemble.c dis-init.c
--libopcodes_la_DEPENDENCIES = $(OFILES) @SHARED_DEPENDENCIES@
-+libopcodes_la_DEPENDENCIES = $(OFILES) @SHARED_DEPENDENCIES@ libtool-soversion
- libopcodes_la_LIBADD = $(OFILES) @SHARED_LIBADD@
--libopcodes_la_LDFLAGS += -release `cat ../bfd/libtool-soversion` @SHARED_LDFLAGS@
-+libopcodes_la_LDFLAGS += -release `cat libtool-soversion` @SHARED_LDFLAGS@
- # Allow dependency tracking to work on all the source files.
- EXTRA_libopcodes_la_SOURCES = $(LIBOPCODES_CFILES)
- 
-+libtool-soversion:
-+	@echo "creating $@"
-+	bfd_soversion="$(VERSION)" ;\
-+	. $(BFDDIR)/development.sh ;\
-+	if test "$$development" = true ; then \
-+	  bfd_soversion="$(VERSION).$${bfd_version_date}" ;\
-+	fi ;\
-+	echo "$${bfd_soversion}" > $@
-+
- # libtool will build .libs/libopcodes.a.  We create libopcodes.a in
- # the build directory so that we don't have to convert all the
- # programs that use libopcodes.a simultaneously.  This is a hack which
-diff --git a/opcodes/configure.ac b/opcodes/configure.ac
-index e564f067334..5da62a3d58b 100644
---- a/opcodes/configure.ac
-+++ b/opcodes/configure.ac
-@@ -98,6 +98,8 @@ BFD_64_BIT
- AC_SUBST(HDEFINES)
- AC_PROG_INSTALL
- 
-+GCC_HEADER_STDINT(bfd_stdint.h)
-+
- AC_CHECK_DECLS([basename, stpcpy])
- 
- # Check if sigsetjmp is available.  Using AC_CHECK_FUNCS won't do
-@@ -148,44 +150,21 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
- 
- LT_LIB_M
- 
--#Libs for generator progs
--if test "x$cross_compiling" = "xno"; then
--  BUILD_LIBS=../libiberty/libiberty.a
--  BUILD_LIB_DEPS=$BUILD_LIBS
--else
--  # if cross-compiling, assume that the system provides -liberty
--  # and that the version is compatible with new headers.
--  BUILD_LIBS=-liberty
--  BUILD_LIB_DEPS=
--fi
--BUILD_LIBS="$BUILD_LIBS $LIBINTL"
--BUILD_LIB_DEPS="$BUILD_LIB_DEPS $LIBINTL_DEP"
-+BUILD_LIBS="-liberty $LIBINTL"
-+BUILD_LIB_DEPS="$LIBINTL_DEP"
- 
- AC_SUBST(BUILD_LIBS)
- AC_SUBST(BUILD_LIB_DEPS)
- 
- # Horrible hacks to build DLLs on Windows and a shared library elsewhere.
- SHARED_LDFLAGS=
--SHARED_LIBADD=
-+SHARED_LIBADD=-liberty
- SHARED_DEPENDENCIES=
--if test "$enable_shared" = "yes"; then
--# When building a shared libopcodes, link against the pic version of libiberty
--# so that apps that use libopcodes won't need libiberty just to satisfy any
--# libopcodes references.
--# We can't do that if a pic libiberty is unavailable since including non-pic
--# code would insert text relocations into libopcodes.
- # Note that linking against libbfd as we do here, which is itself linked
- # against libiberty, may not satisfy all the libopcodes libiberty references
- # since libbfd may not pull in the entirety of libiberty.
- # Also, jam libintl into the right place in all of this: after libiberty,
- # which uses it, but before -lcygwin, which it uses.
--changequote(,)dnl
--  x=`sed -n -e 's/^[ 	]*PICFLAG[ 	]*=[ 	]*//p' < ../libiberty/Makefile | sed -n '$p'`
--changequote([,])dnl
--  if test -n "$x"; then
--    SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty"
--  fi
--fi
- 
- SHARED_LIBADD="$SHARED_LIBADD $LIBINTL"
- 
-@@ -193,11 +172,10 @@ if test "$enable_shared" = "yes"; then
-   case "${host}" in
-     *-*-cygwin*)
-       SHARED_LDFLAGS="-no-undefined"
--      SHARED_LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty $SHARED_LIBADD"
-+      SHARED_LIBADD="-lbfd -liberty $SHARED_LIBADD"
-       ;;
-     *)
--      SHARED_LIBADD="../bfd/libbfd.la ${SHARED_LIBADD}"
--      SHARED_DEPENDENCIES="../bfd/libbfd.la"
-+      SHARED_LIBADD="-lbfd ${SHARED_LIBADD}"
-       ;;
-   esac
- 
diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix
index 39e852a60bbba..07d4668b29385 100644
--- a/pkgs/development/tools/misc/binutils/default.nix
+++ b/pkgs/development/tools/misc/binutils/default.nix
@@ -31,12 +31,12 @@ assert enableGold -> withGold stdenv.targetPlatform;
 let
   inherit (stdenv) buildPlatform hostPlatform targetPlatform;
 
-  version = "2.39";
+  version = "2.40";
 
   srcs = {
     normal = fetchurl {
       url = "mirror://gnu/binutils/binutils-${version}.tar.bz2";
-      sha256 = "sha256-2iSoT+8iAQLdJAQt8G/eqFHCYUpTd/hu/6KPM7exYUg=";
+      hash = "sha256-+CmOsVOks30RLpRapcsoUAQLzyaj6mW1pxXIOv4F5Io=";
     };
     vc4-none = fetchFromGitHub {
       owner = "itszor";
@@ -84,12 +84,10 @@ stdenv.mkDerivation (finalAttrs: {
     # cross-compiling.
     ./always-search-rpath.patch
 
-    # Upstream backport of https://sourceware.org/PR29451:
-    # Don't emit 0-sized debug entries for objects without size.
-    # Without the change elfutils on i686-linux fail dwarf validity test:
-    #    https://sourceware.org/PR29450
-    # Remove once 2.40 releases.
-    ./gas-dwarf-zero-PR29451.patch
+    # Avoid `lib -> out -> lib` reference. Normally `bfd-plugins` does
+    # not need to know binutils' BINDIR at all. It's an absolute path
+    # where libraries are stored.
+    ./plugins-no-BINDIR.patch
   ]
   ++ lib.optional targetPlatform.isiOS ./support-ios.patch
   # Adds AVR-specific options to "size" for compatibility with Atmel's downstream distribution
@@ -105,7 +103,15 @@ stdenv.mkDerivation (finalAttrs: {
       else ./mips64-default-n64.patch)
   ;
 
-  outputs = [ "out" "info" "man" ];
+  outputs = [ "out" "info" "man" "dev" ]
+  # Ideally we would like to always install 'lib' into a separate
+  # target. Unfortunately cross-compiled binutils installs libraries
+  # across both `$lib/lib/` and `$out/$target/lib` with a reference
+  # from $out to $lib. Probably a binutils bug: all libraries should go
+  # to $lib as binutils does not build target libraries. Let's make our
+  # life slightly simpler by installing everything into $out for
+  # cross-binutils.
+  ++ lib.optionals (targetPlatform == hostPlatform) [ "lib" ];
 
   strictDeps = true;
   depsBuildBuild = [ buildPackages.stdenv.cc ];
@@ -196,8 +202,12 @@ stdenv.mkDerivation (finalAttrs: {
 
     # Unconditionally disable:
     # - musl target needs porting: https://sourceware.org/PR29477
-    # - all targets rely on javac: https://sourceware.org/PR29479
     "--disable-gprofng"
+
+    # By default binutils searches $libdir for libraries. This brings in
+    # libbfd and libopcodes into a default visibility. Drop default lib
+    # path to force users to declare their use of these libraries.
+    "--with-lib-path=:"
   ]
   ++ lib.optionals withAllTargets [ "--enable-targets=all" ]
   ++ lib.optionals enableGold [ "--enable-gold" "--enable-plugins" ]
diff --git a/pkgs/development/tools/misc/binutils/gas-dwarf-zero-PR29451.patch b/pkgs/development/tools/misc/binutils/gas-dwarf-zero-PR29451.patch
deleted file mode 100644
index 5f1293f8f7320..0000000000000
--- a/pkgs/development/tools/misc/binutils/gas-dwarf-zero-PR29451.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=d7abcbcea5ddd40a3bf28758b62f35933c59f996
-
-Don't emit 0-sized debug entries for objects without size.
-Without the change elfutils on i686-linux fail dwarf validity test:
-    https://sourceware.org/PR29450
---- a/gas/dwarf2dbg.c
-+++ b/gas/dwarf2dbg.c
-@@ -2882,6 +2882,7 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT str_seg,
- 	{
- 	  const char *name;
- 	  size_t len;
-+	  expressionS size = { .X_op = O_constant };
- 
- 	  /* Skip warning constructs (see above).  */
- 	  if (symbol_get_bfdsym (symp)->flags & BSF_WARNING)
-@@ -2895,6 +2896,18 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT str_seg,
- 	  if (!S_IS_DEFINED (symp) || !S_IS_FUNCTION (symp))
- 	    continue;
- 
-+#if defined (OBJ_ELF) /* || defined (OBJ_MAYBE_ELF) */
-+	  size.X_add_number = S_GET_SIZE (symp);
-+	  if (size.X_add_number == 0 && IS_ELF
-+	      && symbol_get_obj (symp)->size != NULL)
-+	    {
-+	      size.X_op = O_add;
-+	      size.X_op_symbol = make_expr_symbol (symbol_get_obj (symp)->size);
-+	    }
-+#endif
-+	  if (size.X_op == O_constant && size.X_add_number == 0)
-+	    continue;
-+
- 	  subseg_set (str_seg, 0);
- 	  name_sym = symbol_temp_new_now_octets ();
- 	  name = S_GET_NAME (symp);
-@@ -2920,29 +2933,17 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT str_seg,
- 	  emit_expr (&exp, sizeof_address);
- 
- 	  /* DW_AT_high_pc */
--	  exp.X_op = O_constant;
--#if defined (OBJ_ELF) /* || defined (OBJ_MAYBE_ELF) */
--	  exp.X_add_number = S_GET_SIZE (symp);
--	  if (exp.X_add_number == 0 && IS_ELF
--	      && symbol_get_obj (symp)->size != NULL)
--	    {
--	      exp.X_op = O_add;
--	      exp.X_op_symbol = make_expr_symbol (symbol_get_obj (symp)->size);
--	    }
--#else
--	  exp.X_add_number = 0;
--#endif
- 	  if (DWARF2_VERSION < 4)
- 	    {
--	      if (exp.X_op == O_constant)
--		exp.X_op = O_symbol;
--	      exp.X_add_symbol = symp;
--	      emit_expr (&exp, sizeof_address);
-+	      if (size.X_op == O_constant)
-+		size.X_op = O_symbol;
-+	      size.X_add_symbol = symp;
-+	      emit_expr (&size, sizeof_address);
- 	    }
--	  else if (exp.X_op == O_constant)
--	    out_uleb128 (exp.X_add_number);
-+	  else if (size.X_op == O_constant)
-+	    out_uleb128 (size.X_add_number);
- 	  else
--	    emit_leb128_expr (symbol_get_value_expression (exp.X_op_symbol), 0);
-+	    emit_leb128_expr (symbol_get_value_expression (size.X_op_symbol), 0);
- 	}
- 
-       /* End of children.  */
diff --git a/pkgs/development/tools/misc/binutils/libbfd.nix b/pkgs/development/tools/misc/binutils/libbfd.nix
index 16737a7b5ee84..e28ff993fd26e 100644
--- a/pkgs/development/tools/misc/binutils/libbfd.nix
+++ b/pkgs/development/tools/misc/binutils/libbfd.nix
@@ -1,45 +1,22 @@
 { lib, stdenv
-, buildPackages
-, gnu-config, autoreconfHook, bison, binutils-unwrapped, texinfo
-, libiberty, libintl, zlib
+, binutils-unwrapped-all-targets
 }:
 
 stdenv.mkDerivation {
   pname = "libbfd";
-  inherit (binutils-unwrapped) version src;
-
-  outputs = [ "out" "dev" ];
-
-  patches = binutils-unwrapped.patches ++ [
-    ./build-components-separately.patch
+  inherit (binutils-unwrapped-all-targets) version;
+
+  dontUnpack = true;
+  dontBuild = true;
+  dontInstall = true;
+  propagatedBuildInputs = [
+    binutils-unwrapped-all-targets.dev
+    binutils-unwrapped-all-targets.lib
   ];
 
-  # We just want to build libbfd
-  postPatch = ''
-    cd bfd
-  '';
-
-  postAutoreconf = ''
-    echo "Updating config.guess and config.sub from ${gnu-config}"
-    cp -f ${gnu-config}/config.{guess,sub} ../
-  '';
-
-  # We update these ourselves
-  dontUpdateAutotoolsGnuConfigScripts = true;
-
-  strictDeps = true;
-  nativeBuildInputs = [ autoreconfHook bison texinfo ];
-  buildInputs = [ libiberty zlib ] ++ lib.optionals stdenv.isDarwin [ libintl ];
-  depsBuildBuild = [ buildPackages.stdenv.cc ];
-
-  configurePlatforms = [ "build" "host" ];
-  configureFlags = [
-    "--enable-targets=all" "--enable-64-bit-bfd"
-    "--enable-install-libbfd"
-    "--with-system-zlib"
-  ] ++ lib.optional (!stdenv.hostPlatform.isStatic) "--enable-shared";
-
-  enableParallelBuilding = true;
+  passthru = {
+    dev = binutils-unwrapped-all-targets.dev;
+  };
 
   meta = with lib; {
     description = "A library for manipulating containers of machine code";
diff --git a/pkgs/development/tools/misc/binutils/libopcodes.nix b/pkgs/development/tools/misc/binutils/libopcodes.nix
index e4b6cec41b4f0..003142df9226f 100644
--- a/pkgs/development/tools/misc/binutils/libopcodes.nix
+++ b/pkgs/development/tools/misc/binutils/libopcodes.nix
@@ -1,38 +1,22 @@
-{ lib, stdenv, buildPackages
-, autoreconfHook, bison, binutils-unwrapped
-, libiberty, libbfd
+{ lib, stdenv
+, binutils-unwrapped-all-targets
 }:
 
 stdenv.mkDerivation {
   pname = "libopcodes";
-  inherit (binutils-unwrapped) version src;
-
-  outputs = [ "out" "dev" ];
-
-  patches = binutils-unwrapped.patches ++ [
-    ./build-components-separately.patch
+  inherit (binutils-unwrapped-all-targets) version;
+
+  dontUnpack = true;
+  dontBuild = true;
+  dontInstall = true;
+  propagatedBuildInputs = [
+    binutils-unwrapped-all-targets.dev
+    binutils-unwrapped-all-targets.lib
   ];
 
-  # We just want to build libopcodes
-  postPatch = ''
-    cd opcodes
-    find . ../include/opcode -type f -exec sed {} -i -e 's/"bfd.h"/<bfd.h>/' \;
-  '';
-
-  depsBuildBuild = [ buildPackages.stdenv.cc ];
-  nativeBuildInputs = [ autoreconfHook bison ];
-  buildInputs = [ libiberty ];
-  # dis-asm.h includes bfd.h
-  propagatedBuildInputs = [ libbfd ];
-
-  configurePlatforms = [ "build" "host" ];
-  configureFlags = [
-    "--enable-targets=all" "--enable-64-bit-bfd"
-    "--enable-install-libbfd"
-    "--enable-shared"
-  ];
-
-  enableParallelBuilding = true;
+  passthru = {
+    dev = binutils-unwrapped-all-targets.dev;
+  };
 
   meta = with lib; {
     description = "A library from binutils for manipulating machine code";
diff --git a/pkgs/development/tools/misc/binutils/plugins-no-BINDIR.patch b/pkgs/development/tools/misc/binutils/plugins-no-BINDIR.patch
new file mode 100644
index 0000000000000..562aad33eccd4
--- /dev/null
+++ b/pkgs/development/tools/misc/binutils/plugins-no-BINDIR.patch
@@ -0,0 +1,25 @@
+Avoid `lib -> out -> lib` reference. Normally `bfd-plugins` does not
+need to know binutils' BINDIR at all. It's an absolute path where
+libraries are stored.
+--- a/bfd/plugin.c
++++ b/bfd/plugin.c
+@@ -493,7 +493,7 @@ build_plugin_list (bfd *abfd)
+      when configuring binutils using --libdir.  Search in the proper
+      path first, then the old one for backwards compatibility.  */
+   static const char *path[]
+-    = { LIBDIR "/bfd-plugins", BINDIR "/../lib/bfd-plugins" };
++    = { LIBDIR "/bfd-plugins", };
+   struct stat last_st;
+   unsigned int i;
+ 
+@@ -508,9 +508,7 @@ build_plugin_list (bfd *abfd)
+   last_st.st_ino = 0;
+   for (i = 0; i < sizeof (path) / sizeof (path[0]); i++)
+     {
+-      char *plugin_dir = make_relative_prefix (plugin_program_name,
+-					       BINDIR,
+-					       path[i]);
++      char *plugin_dir = xstrdup (path[i]);
+       if (plugin_dir)
+ 	{
+ 	  struct stat st;
diff --git a/pkgs/development/tools/misc/pahole/default.nix b/pkgs/development/tools/misc/pahole/default.nix
index ec9fb436f7648..39b6baabc836a 100644
--- a/pkgs/development/tools/misc/pahole/default.nix
+++ b/pkgs/development/tools/misc/pahole/default.nix
@@ -2,11 +2,14 @@
 
 stdenv.mkDerivation rec {
   pname = "pahole";
-  version = "1.24";
+  # Need a revision that supports DW_TAG_unspecified_type(0x3b).
+  # Was added after 1.24 release in a series of changes.
+  # Can switch back to release tags once 1.25 is cut.
+  version = "1.24-unstable-2022-11-24";
   src = fetchgit {
     url = "https://git.kernel.org/pub/scm/devel/pahole/pahole.git";
-    rev = "v${version}";
-    sha256 = "sha256-OPseVKt5kIKgK096+ufKrWMS1E/7Z0uxNqCMN6wKfKg=";
+    rev = "02d67c51765dfbd5893087da63744c864c7cc9e0";
+    hash = "sha256-hKc8UKxPtEM2zlYmolSt1pXJKNRt4wC/Uf+dP/Sb7+s=";
   };
 
   nativeBuildInputs = [ cmake pkg-config ];
diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix
index 2ee8c070ae19e..6d3f904e9aaa8 100644
--- a/pkgs/stdenv/darwin/default.nix
+++ b/pkgs/stdenv/darwin/default.nix
@@ -737,6 +737,7 @@ rec {
         pcre.out
         gettext
         binutils.bintools
+        binutils.bintools.lib
         darwin.binutils
         darwin.binutils.bintools
         curl.out
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 608540c2a3cc2..b77c48b03cebe 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -17140,13 +17140,9 @@ with pkgs;
     libc = preLibcCrossHeaders;
   };
 
-  libbfd = callPackage ../development/tools/misc/binutils/libbfd.nix {
-    autoreconfHook = buildPackages.autoreconfHook269;
-  };
+  libbfd = callPackage ../development/tools/misc/binutils/libbfd.nix { };
 
-  libopcodes = callPackage ../development/tools/misc/binutils/libopcodes.nix {
-    autoreconfHook = buildPackages.autoreconfHook269;
-  };
+  libopcodes = callPackage ../development/tools/misc/binutils/libopcodes.nix { };
 
   # Held back 2.38 release. Remove once all dependencies are ported to 2.39.
   binutils-unwrapped_2_38 = callPackage ../development/tools/misc/binutils/2.38 {