at v192 3.0 kB view raw
1{ stdenv, fetchurl, noSysDirs, zlib 2, cross ? null, gold ? true, bison ? null 3}: 4 5let basename = "binutils-2.23.1"; in 6 7with { inherit (stdenv.lib) optional optionals optionalString; }; 8 9stdenv.mkDerivation rec { 10 name = basename + optionalString (cross != null) "-${cross.config}"; 11 12 src = fetchurl { 13 url = "mirror://gnu/binutils/${basename}.tar.bz2"; 14 sha256 = "06bs5v5ndb4g5qx96d52lc818gkbskd1m0sz57314v887sqfbcia"; 15 }; 16 17 patches = [ 18 # Turn on --enable-new-dtags by default to make the linker set 19 # RUNPATH instead of RPATH on binaries. This is important because 20 # RUNPATH can be overriden using LD_LIBRARY_PATH at runtime. 21 ./new-dtags.patch 22 23 # Since binutils 2.22, DT_NEEDED flags aren't copied for dynamic outputs. 24 # That requires upstream changes for things to work. So we can patch it to 25 # get the old behaviour by now. 26 ./dtneeded.patch 27 28 # Make binutils output deterministic by default. 29 ./deterministic.patch 30 31 # Always add PaX flags section to ELF files. 32 # This is needed, for instance, so that running "ldd" on a binary that is 33 # PaX-marked to disable mprotect doesn't fail with permission denied. 34 ./pt-pax-flags-20121023.patch 35 ]; 36 37 nativeBuildInputs = optional gold bison; 38 buildInputs = [ zlib ]; 39 40 inherit noSysDirs; 41 42 preConfigure = '' 43 # Clear the default library search path. 44 if test "$noSysDirs" = "1"; then 45 echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt 46 fi 47 48 # Use symlinks instead of hard links to save space ("strip" in the 49 # fixup phase strips each hard link separately). 50 for i in binutils/Makefile.in gas/Makefile.in ld/Makefile.in gold/Makefile.in; do 51 sed -i "$i" -e 's|ln |ln -s |' 52 done 53 ''; 54 55 # As binutils takes part in the stdenv building, we don't want references 56 # to the bootstrap-tools libgcc (as uses to happen on arm/mips) 57 NIX_CFLAGS_COMPILE = if stdenv.isDarwin 58 then "-Wno-string-plus-int -Wno-deprecated-declarations" 59 else "-static-libgcc"; 60 61 configureFlags = 62 [ "--enable-shared" "--enable-deterministic-archives" "--disable-werror" ] 63 ++ optional (stdenv.system == "mips64el-linux") "--enable-fix-loongson2f-nop" 64 ++ optional (cross != null) "--target=${cross.config}" 65 ++ optionals gold [ "--enable-gold" "--enable-plugins" ] 66 ++ optional (stdenv.system == "i686-linux") "--enable-targets=x86_64-linux-gnu"; 67 68 enableParallelBuilding = true; 69 70 meta = { 71 description = "Tools for manipulating binaries (linker, assembler, etc.)"; 72 73 longDescription = '' 74 The GNU Binutils are a collection of binary tools. The main 75 ones are `ld' (the GNU linker) and `as' (the GNU assembler). 76 They also include the BFD (Binary File Descriptor) library, 77 `gprof', `nm', `strip', etc. 78 ''; 79 80 homepage = http://www.gnu.org/software/binutils/; 81 82 license = stdenv.lib.licenses.gpl3Plus; 83 84 /* Give binutils a lower priority than gcc-wrapper to prevent a 85 collision due to the ld/as wrappers/symlinks in the latter. */ 86 priority = "10"; 87 }; 88}