lol

bfd, opcodes: Init separate derivations for binutils libraries

On most distros, these are just built and distributed as part of
binutils. We don't use binutils across the board, however, but rather
switch between binutils and a cctools-binutils mashup, and change the
outputs on binutils too. This creates a combinatorial conditional soup
which is hard to maintain.

My hope is to lower the the state space. While my patch isn't the most
maintainable, they make downstream packages become more maintainable to
compensate. The additional derivations themselves are completely
platform-agnostic, always they always supports all possible target
platforms, and always yield "out" and "dev" outputs. That, in turn,
allows downstream packages to not worry about a dependency
shape-shifting under them.

In fact, the actual binutils package can avoid needing multiple outputs
now that these serve the requisite libraries, so that also can become
simpler on all platforms, too, removing the original wart this PR
circumnavigates for now. Actually changing the binutils package to
leverage is a mass rebuild, however, so I'll leave that for a separate
PR.

I do hope to upstream something like my patch too, but until then I'll
make myself maintainer of these derivations

+277 -1
+47
pkgs/development/libraries/libbfd/default.nix
··· 1 + { stdenv 2 + , fetchurl, autoreconfHook264, bison, binutils 3 + , libiberty, zlib 4 + }: 5 + 6 + stdenv.mkDerivation rec { 7 + name = "libbfd-${version}"; 8 + inherit (binutils) version src; 9 + 10 + outputs = [ "out" "dev" ]; 11 + 12 + patches = binutils.patches ++ [ 13 + ../../tools/misc/binutils/build-components-separately.patch 14 + ]; 15 + 16 + # We just want to build libbfd 17 + postPatch = '' 18 + cd bfd 19 + ''; 20 + 21 + nativeBuildInputs = [ autoreconfHook264 bison ]; 22 + buildInputs = [ libiberty zlib ]; 23 + 24 + configurePlatforms = [ "build" "host" ]; 25 + configureFlags = [ 26 + "--enable-targets=all" "--enable-64-bit-bfd" 27 + "--enable-install-libbfd" 28 + "--enable-shared" 29 + "--with-system-zlib" 30 + ]; 31 + 32 + enableParallelBuilding = true; 33 + 34 + meta = with stdenv.lib; { 35 + description = "A library for manipulating containers of machine code"; 36 + longDescription = '' 37 + BFD is a library which provides a single interface to read and write 38 + object files, executables, archive files, and core files in any format. 39 + It is associated with GNU Binutils, and elsewhere often distributed with 40 + it. 41 + ''; 42 + homepage = http://www.gnu.org/software/binutils/; 43 + license = licenses.gpl3Plus; 44 + maintainers = with maintainers; [ ericson2314 ]; 45 + platforms = platforms.unix; 46 + }; 47 + }
+43
pkgs/development/libraries/libopcodes/default.nix
··· 1 + { stdenv, buildPackages 2 + , fetchurl, autoreconfHook264, bison, binutils 3 + , libiberty, libbfd 4 + }: 5 + 6 + stdenv.mkDerivation rec { 7 + name = "libopcodes-${version}"; 8 + inherit (binutils) version src; 9 + 10 + outputs = [ "out" "dev" ]; 11 + 12 + patches = binutils.patches ++ [ 13 + ../../tools/misc/binutils/build-components-separately.patch 14 + ]; 15 + 16 + # We just want to build libopcodes 17 + postPatch = '' 18 + cd opcodes 19 + find . ../include/opcode -type f -exec sed {} -i -e 's/"bfd.h"/<bfd.h>/' \; 20 + ''; 21 + 22 + nativeBuildInputs = [ autoreconfHook264 bison buildPackages.stdenv.cc ]; 23 + buildInputs = [ libiberty ]; 24 + # dis-asm.h includes bfd.h 25 + propagatedBuildInputs = [ libbfd ]; 26 + 27 + configurePlatforms = [ "build" "host" ]; 28 + configureFlags = [ 29 + "--enable-targets=all" "--enable-64-bit-bfd" 30 + "--enable-install-libbfd" 31 + "--enable-shared" 32 + ]; 33 + 34 + enableParallelBuilding = true; 35 + 36 + meta = with stdenv.lib; { 37 + description = "A library from binutils for manipulating machine code"; 38 + homepage = http://www.gnu.org/software/binutils/; 39 + license = licenses.gpl3Plus; 40 + maintainers = with maintainers; [ ericson2314 ]; 41 + platforms = platforms.unix; 42 + }; 43 + }
+178
pkgs/development/tools/misc/binutils/build-components-separately.patch
··· 1 + From bc09a9236f67e710d545ac11bcdac7b55dbcc1a0 Mon Sep 17 00:00:00 2001 2 + From: John Ericson <John.Ericson@Obsidian.Systems> 3 + Date: Thu, 12 Oct 2017 11:16:57 -0400 4 + Subject: [PATCH] Build components separately 5 + 6 + --- 7 + bfd/configure.ac | 18 +++--------------- 8 + opcodes/Makefile.am | 17 +++++++++++++---- 9 + opcodes/configure.ac | 45 ++++++--------------------------------------- 10 + 3 files changed, 22 insertions(+), 58 deletions(-) 11 + 12 + diff --git a/bfd/configure.ac b/bfd/configure.ac 13 + index 9a183c1628..8728837384 100644 14 + --- a/bfd/configure.ac 15 + +++ b/bfd/configure.ac 16 + @@ -241,31 +241,19 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed, 17 + 18 + LT_LIB_M 19 + 20 + -# When building a shared libbfd, link against the pic version of libiberty 21 + -# so that apps that use libbfd won't need libiberty just to satisfy any 22 + -# libbfd references. 23 + -# We can't do that if a pic libiberty is unavailable since including non-pic 24 + -# code would insert text relocations into libbfd. 25 + SHARED_LIBADD= 26 + -SHARED_LDFLAGS= 27 + +SHARED_LDFLAGS=-liberty 28 + if test "$enable_shared" = "yes"; then 29 + -changequote(,)dnl 30 + - x=`sed -n -e 's/^[ ]*PICFLAG[ ]*=[ ]*//p' < ../libiberty/Makefile | sed -n '$p'` 31 + -changequote([,])dnl 32 + - if test -n "$x"; then 33 + - SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty" 34 + - fi 35 + - 36 + # More hacks to build DLLs on Windows. 37 + case "${host}" in 38 + *-*-cygwin*) 39 + SHARED_LDFLAGS="-no-undefined" 40 + - SHARED_LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin -lkernel32" 41 + + SHARED_LIBADD="-liberty -lintl -lcygwin -lkernel32" 42 + ;; 43 + 44 + # Hack to build or1k-src on OSX 45 + or1k*-*-darwin*) 46 + - SHARED_LIBADD="-L`pwd`/../libiberty/pic -L`pwd`/../intl -liberty -lintl" 47 + + SHARED_LIBADD="-liberty -lintl" 48 + ;; 49 + esac 50 + 51 + diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am 52 + index 925e7ff651..47b395c195 100644 53 + --- a/opcodes/Makefile.am 54 + +++ b/opcodes/Makefile.am 55 + @@ -52,7 +52,7 @@ libopcodes_la_LDFLAGS += -rpath $(rpath_bfdlibdir) 56 + endif 57 + 58 + # This is where bfd.h lives. 59 + -BFD_H = ../bfd/bfd.h 60 + +BFD_H = $(BFDDIR)/bfd.h 61 + 62 + BUILD_LIBS = @BUILD_LIBS@ 63 + BUILD_LIB_DEPS = @BUILD_LIB_DEPS@ 64 + @@ -303,7 +303,7 @@ OFILES = @BFD_MACHINES@ 65 + # development.sh is used to determine -Werror default. 66 + CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh 67 + 68 + -AM_CPPFLAGS = -I. -I$(srcdir) -I../bfd -I$(INCDIR) -I$(BFDDIR) @HDEFINES@ @INCINTL@ 69 + +AM_CPPFLAGS = -I. -I$(srcdir) -I$(INCDIR) -I$(BFDDIR) @HDEFINES@ @INCINTL@ 70 + 71 + disassemble.lo: disassemble.c 72 + if am__fastdepCC 73 + @@ -324,12 +324,21 @@ libopcodes_la_SOURCES = dis-buf.c disassemble.c dis-init.c 74 + # old version of libbfd, or to pick up libbfd for the wrong architecture 75 + # if host != build. So for building with shared libraries we use a 76 + # hardcoded path to libbfd.so instead of relying on the entries in libbfd.la. 77 + -libopcodes_la_DEPENDENCIES = $(OFILES) @SHARED_DEPENDENCIES@ 78 + +libopcodes_la_DEPENDENCIES = $(OFILES) @SHARED_DEPENDENCIES@ libtool-soversion 79 + libopcodes_la_LIBADD = $(OFILES) @SHARED_LIBADD@ 80 + -libopcodes_la_LDFLAGS += -release `cat ../bfd/libtool-soversion` @SHARED_LDFLAGS@ 81 + +libopcodes_la_LDFLAGS += -release `cat libtool-soversion` @SHARED_LDFLAGS@ 82 + # Allow dependency tracking to work on all the source files. 83 + EXTRA_libopcodes_la_SOURCES = $(LIBOPCODES_CFILES) 84 + 85 + +libtool-soversion: 86 + + @echo "creating $@" 87 + + bfd_soversion="$(VERSION)" ;\ 88 + + . $(BFDDIR)/development.sh ;\ 89 + + if test "$$development" = true ; then \ 90 + + bfd_soversion="$(VERSION).$${bfd_version_date}" ;\ 91 + + fi ;\ 92 + + echo "$${bfd_soversion}" > $@ 93 + + 94 + # libtool will build .libs/libopcodes.a. We create libopcodes.a in 95 + # the build directory so that we don't have to convert all the 96 + # programs that use libopcodes.a simultaneously. This is a hack which 97 + diff --git a/opcodes/configure.ac b/opcodes/configure.ac 98 + index b9f5eb8a4f..ef2c2152b7 100644 99 + --- a/opcodes/configure.ac 100 + +++ b/opcodes/configure.ac 101 + @@ -89,6 +89,7 @@ AC_PROG_INSTALL 102 + 103 + AC_CHECK_HEADERS(string.h strings.h stdlib.h limits.h) 104 + ACX_HEADER_STRING 105 + +GCC_HEADER_STDINT(bfd_stdint.h) 106 + 107 + AC_CHECK_DECLS([basename, stpcpy]) 108 + 109 + @@ -134,61 +135,27 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed, 110 + 111 + LT_LIB_M 112 + 113 + -#Libs for generator progs 114 + -if test "x$cross_compiling" = "xno"; then 115 + - BUILD_LIBS=../libiberty/libiberty.a 116 + - BUILD_LIB_DEPS=$BUILD_LIBS 117 + -else 118 + - # if cross-compiling, assume that the system provides -liberty 119 + - # and that the version is compatible with new headers. 120 + - BUILD_LIBS=-liberty 121 + - BUILD_LIB_DEPS= 122 + -fi 123 + -BUILD_LIBS="$BUILD_LIBS $LIBINTL" 124 + -BUILD_LIB_DEPS="$BUILD_LIB_DEPS $LIBINTL_DEP" 125 + +BUILD_LIBS="-liberty $LIBINTL" 126 + +BUILD_LIB_DEPS="$LIBINTL_DEP" 127 + 128 + AC_SUBST(BUILD_LIBS) 129 + AC_SUBST(BUILD_LIB_DEPS) 130 + 131 + # Horrible hacks to build DLLs on Windows and a shared library elsewhere. 132 + SHARED_LDFLAGS= 133 + -SHARED_LIBADD= 134 + +SHARED_LIBADD=-liberty 135 + SHARED_DEPENDENCIES= 136 + if test "$enable_shared" = "yes"; then 137 + -# When building a shared libopcodes, link against the pic version of libiberty 138 + -# so that apps that use libopcodes won't need libiberty just to satisfy any 139 + -# libopcodes references. 140 + -# We can't do that if a pic libiberty is unavailable since including non-pic 141 + -# code would insert text relocations into libopcodes. 142 + # Note that linking against libbfd as we do here, which is itself linked 143 + # against libiberty, may not satisfy all the libopcodes libiberty references 144 + # since libbfd may not pull in the entirety of libiberty. 145 + -changequote(,)dnl 146 + - x=`sed -n -e 's/^[ ]*PICFLAG[ ]*=[ ]*//p' < ../libiberty/Makefile | sed -n '$p'` 147 + -changequote([,])dnl 148 + - if test -n "$x"; then 149 + - SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty" 150 + - fi 151 + - 152 + case "${host}" in 153 + *-*-cygwin*) 154 + SHARED_LDFLAGS="-no-undefined" 155 + - SHARED_LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin" 156 + + SHARED_LIBADD="-lbfd -liberty -lintl -lcygwin" 157 + ;; 158 + - *-*-darwin*) 159 + - SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.dylib ${SHARED_LIBADD}" 160 + - SHARED_DEPENDENCIES="../bfd/libbfd.la" 161 + - ;; 162 + *) 163 + - case "$host_vendor" in 164 + - hp) 165 + - SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.sl ${SHARED_LIBADD}" 166 + - ;; 167 + - *) 168 + - SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.so ${SHARED_LIBADD}" 169 + - ;; 170 + - esac 171 + - SHARED_DEPENDENCIES="../bfd/libbfd.la" 172 + + SHARED_LIBADD="-lbfd ${SHARED_LIBADD}" 173 + ;; 174 + esac 175 + 176 + -- 177 + 2.14.2 178 +
+1 -1
pkgs/development/tools/misc/binutils/default.nix
··· 96 96 enableParallelBuilding = true; 97 97 98 98 passthru = { 99 - inherit prefix; 99 + inherit prefix version; 100 100 }; 101 101 102 102 meta = with stdenv.lib; {
+8
pkgs/top-level/all-packages.nix
··· 77 77 { deps = [ autoconf automake gettext libtool ]; } 78 78 ../build-support/setup-hooks/autoreconf.sh; 79 79 80 + autoreconfHook264 = makeSetupHook 81 + { deps = [ autoconf264 automake111x gettext libtool ]; } 82 + ../build-support/setup-hooks/autoreconf.sh; 83 + 80 84 ensureNewerSourcesHook = { year }: makeSetupHook {} 81 85 (writeScript "ensure-newer-sources-hook.sh" '' 82 86 postUnpackHooks+=(_ensureNewerSources) ··· 7832 7836 }; 7833 7837 7834 7838 belle-sip = callPackage ../development/libraries/belle-sip { }; 7839 + 7840 + libbfd = callPackage ../development/libraries/libbfd { }; 7841 + 7842 + libopcodes = callPackage ../development/libraries/libopcodes { }; 7835 7843 7836 7844 bobcat = callPackage ../development/libraries/bobcat { }; 7837 7845