summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/development/libraries/libbfd/default.nix47
-rw-r--r--pkgs/development/libraries/libopcodes/default.nix43
-rw-r--r--pkgs/development/tools/misc/binutils/build-components-separately.patch178
-rw-r--r--pkgs/development/tools/misc/binutils/default.nix2
-rw-r--r--pkgs/top-level/all-packages.nix8
5 files changed, 277 insertions, 1 deletions
diff --git a/pkgs/development/libraries/libbfd/default.nix b/pkgs/development/libraries/libbfd/default.nix
new file mode 100644
index 00000000000..7709f550675
--- /dev/null
+++ b/pkgs/development/libraries/libbfd/default.nix
@@ -0,0 +1,47 @@
+{ stdenv
+, fetchurl, autoreconfHook264, bison, binutils
+, libiberty, zlib
+}:
+
+stdenv.mkDerivation rec {
+  name = "libbfd-${version}";
+  inherit (binutils) version src;
+
+  outputs = [ "out" "dev" ];
+
+  patches = binutils.patches ++ [
+    ../../tools/misc/binutils/build-components-separately.patch
+  ];
+
+  # We just want to build libbfd
+  postPatch = ''
+    cd bfd
+  '';
+
+  nativeBuildInputs = [ autoreconfHook264 bison ];
+  buildInputs = [ libiberty zlib ];
+
+  configurePlatforms = [ "build" "host" ];
+  configureFlags = [
+    "--enable-targets=all" "--enable-64-bit-bfd"
+    "--enable-install-libbfd"
+    "--enable-shared"
+    "--with-system-zlib"
+  ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "A library for manipulating containers of machine code";
+    longDescription = ''
+      BFD is a library which provides a single interface to read and write
+      object files, executables, archive files, and core files in any format.
+      It is associated with GNU Binutils, and elsewhere often distributed with
+      it.
+    '';
+    homepage = http://www.gnu.org/software/binutils/;
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ ericson2314 ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/libraries/libopcodes/default.nix b/pkgs/development/libraries/libopcodes/default.nix
new file mode 100644
index 00000000000..c064ca25c49
--- /dev/null
+++ b/pkgs/development/libraries/libopcodes/default.nix
@@ -0,0 +1,43 @@
+{ stdenv, buildPackages
+, fetchurl, autoreconfHook264, bison, binutils
+, libiberty, libbfd
+}:
+
+stdenv.mkDerivation rec {
+  name = "libopcodes-${version}";
+  inherit (binutils) version src;
+
+  outputs = [ "out" "dev" ];
+
+  patches = binutils.patches ++ [
+    ../../tools/misc/binutils/build-components-separately.patch
+  ];
+
+  # We just want to build libopcodes
+  postPatch = ''
+    cd opcodes
+    find . ../include/opcode -type f -exec sed {} -i -e 's/"bfd.h"/<bfd.h>/' \;
+  '';
+
+  nativeBuildInputs = [ autoreconfHook264 bison buildPackages.stdenv.cc ];
+  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;
+
+  meta = with stdenv.lib; {
+    description = "A library from binutils for manipulating machine code";
+    homepage = http://www.gnu.org/software/binutils/;
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ ericson2314 ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/tools/misc/binutils/build-components-separately.patch b/pkgs/development/tools/misc/binutils/build-components-separately.patch
new file mode 100644
index 00000000000..d3cd0d2131c
--- /dev/null
+++ b/pkgs/development/tools/misc/binutils/build-components-separately.patch
@@ -0,0 +1,178 @@
+From bc09a9236f67e710d545ac11bcdac7b55dbcc1a0 Mon Sep 17 00:00:00 2001
+From: John Ericson <John.Ericson@Obsidian.Systems>
+Date: Thu, 12 Oct 2017 11:16:57 -0400
+Subject: [PATCH] Build components separately
+
+---
+ bfd/configure.ac     | 18 +++---------------
+ opcodes/Makefile.am  | 17 +++++++++++++----
+ opcodes/configure.ac | 45 ++++++---------------------------------------
+ 3 files changed, 22 insertions(+), 58 deletions(-)
+
+diff --git a/bfd/configure.ac b/bfd/configure.ac
+index 9a183c1628..8728837384 100644
+--- a/bfd/configure.ac
++++ b/bfd/configure.ac
+@@ -241,31 +241,19 @@ 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
+-
+ # More hacks to build DLLs on Windows.
+   case "${host}" in
+   *-*-cygwin*)
+     SHARED_LDFLAGS="-no-undefined"
+-    SHARED_LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin -lkernel32"
++    SHARED_LIBADD="-liberty -lintl -lcygwin -lkernel32"
+   ;;
+ 
+   # Hack to build or1k-src on OSX
+   or1k*-*-darwin*)
+-    SHARED_LIBADD="-L`pwd`/../libiberty/pic -L`pwd`/../intl -liberty -lintl"
++    SHARED_LIBADD="-liberty -lintl"
+   ;;
+   esac
+ 
+diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
+index 925e7ff651..47b395c195 100644
+--- a/opcodes/Makefile.am
++++ b/opcodes/Makefile.am
+@@ -52,7 +52,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
+@@ -324,12 +324,21 @@ libopcodes_la_SOURCES =  dis-buf.c disassemble.c dis-init.c
+ # old version of libbfd, or to pick up libbfd for the wrong architecture
+ # if host != build. So for building with shared libraries we use a
+ # hardcoded path to libbfd.so instead of relying on the entries in libbfd.la.
+-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 b9f5eb8a4f..ef2c2152b7 100644
+--- a/opcodes/configure.ac
++++ b/opcodes/configure.ac
+@@ -89,6 +89,7 @@ AC_PROG_INSTALL
+ 
+ AC_CHECK_HEADERS(string.h strings.h stdlib.h limits.h)
+ ACX_HEADER_STRING
++GCC_HEADER_STDINT(bfd_stdint.h)
+ 
+ AC_CHECK_DECLS([basename, stpcpy])
+ 
+@@ -134,61 +135,27 @@ 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.
+-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
+-
+   case "${host}" in
+     *-*-cygwin*)
+       SHARED_LDFLAGS="-no-undefined"
+-      SHARED_LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin"
++      SHARED_LIBADD="-lbfd -liberty -lintl -lcygwin"
+       ;;
+-   *-*-darwin*)
+-     SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.dylib ${SHARED_LIBADD}"
+-     SHARED_DEPENDENCIES="../bfd/libbfd.la"
+-     ;;
+     *)
+-      case "$host_vendor" in
+-        hp)
+-          SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.sl ${SHARED_LIBADD}"
+-	  ;;
+-	*)
+-          SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.so ${SHARED_LIBADD}"
+-	  ;;
+-      esac
+-      SHARED_DEPENDENCIES="../bfd/libbfd.la"
++      SHARED_LIBADD="-lbfd ${SHARED_LIBADD}"
+       ;;
+   esac
+ 
+-- 
+2.14.2
+
diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix
index 62b4812fae5..8a048958a0e 100644
--- a/pkgs/development/tools/misc/binutils/default.nix
+++ b/pkgs/development/tools/misc/binutils/default.nix
@@ -96,7 +96,7 @@ stdenv.mkDerivation rec {
   enableParallelBuilding = true;
 
   passthru = {
-    inherit prefix;
+    inherit prefix version;
   };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 037aa8295d4..b8f638f2a84 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -77,6 +77,10 @@ with pkgs;
     { deps = [ autoconf automake gettext libtool ]; }
     ../build-support/setup-hooks/autoreconf.sh;
 
+  autoreconfHook264 = makeSetupHook
+    { deps = [ autoconf264 automake111x gettext libtool ]; }
+    ../build-support/setup-hooks/autoreconf.sh;
+
   ensureNewerSourcesHook = { year }: makeSetupHook {}
     (writeScript "ensure-newer-sources-hook.sh" ''
       postUnpackHooks+=(_ensureNewerSources)
@@ -7833,6 +7837,10 @@ with pkgs;
 
   belle-sip = callPackage ../development/libraries/belle-sip { };
 
+  libbfd = callPackage ../development/libraries/libbfd { };
+
+  libopcodes = callPackage ../development/libraries/libopcodes { };
+
   bobcat = callPackage ../development/libraries/bobcat { };
 
   boehmgc = callPackage ../development/libraries/boehm-gc { };