2013-06-25 08:53:37 +01:00
|
|
|
{ stdenv, fetchurl, noSysDirs, zlib
|
2013-09-09 09:34:37 +01:00
|
|
|
, cross ? null, gold ? true, bison ? null
|
2014-01-07 12:57:42 +00:00
|
|
|
}:
|
2004-03-09 17:16:02 +00:00
|
|
|
|
2013-09-11 08:25:10 +01:00
|
|
|
let basename = "binutils-2.23.1"; in
|
2013-09-02 14:54:12 +01:00
|
|
|
|
|
|
|
with { inherit (stdenv.lib) optional optionals optionalString; };
|
|
|
|
|
2012-03-12 15:34:00 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2013-09-02 14:54:12 +01:00
|
|
|
name = basename + optionalString (cross != null) "-${cross.config}";
|
2009-11-08 00:32:12 +00:00
|
|
|
|
2003-11-03 10:22:00 +00:00
|
|
|
src = fetchurl {
|
2011-10-03 20:11:09 +01:00
|
|
|
url = "mirror://gnu/binutils/${basename}.tar.bz2";
|
2013-09-11 08:25:10 +01:00
|
|
|
sha256 = "06bs5v5ndb4g5qx96d52lc818gkbskd1m0sz57314v887sqfbcia";
|
2003-11-03 10:22:00 +00:00
|
|
|
};
|
2008-05-29 15:16:35 +01:00
|
|
|
|
|
|
|
patches = [
|
|
|
|
# Turn on --enable-new-dtags by default to make the linker set
|
|
|
|
# RUNPATH instead of RPATH on binaries. This is important because
|
|
|
|
# RUNPATH can be overriden using LD_LIBRARY_PATH at runtime.
|
|
|
|
./new-dtags.patch
|
2012-12-20 15:20:23 +00:00
|
|
|
|
|
|
|
# Since binutils 2.22, DT_NEEDED flags aren't copied for dynamic outputs.
|
|
|
|
# That requires upstream changes for things to work. So we can patch it to
|
|
|
|
# get the old behaviour by now.
|
|
|
|
./dtneeded.patch
|
2014-01-07 12:57:42 +00:00
|
|
|
|
|
|
|
# Make binutils output deterministic by default.
|
|
|
|
./deterministic.patch
|
2014-03-08 20:57:18 +00:00
|
|
|
|
|
|
|
# Always add PaX flags section to ELF files.
|
|
|
|
# This is needed, for instance, so that running "ldd" on a binary that is
|
|
|
|
# PaX-marked to disable mprotect doesn't fail with permission denied.
|
|
|
|
./pt-pax-flags-20121023.patch
|
2014-01-07 12:57:42 +00:00
|
|
|
];
|
2009-11-08 00:32:12 +00:00
|
|
|
|
2015-01-28 23:34:32 +00:00
|
|
|
nativeBuildInputs = optional gold bison;
|
|
|
|
buildInputs = [ zlib ];
|
2010-12-12 23:35:16 +00:00
|
|
|
|
2004-03-29 18:23:01 +01:00
|
|
|
inherit noSysDirs;
|
2008-05-29 15:16:35 +01:00
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
# Clear the default library search path.
|
|
|
|
if test "$noSysDirs" = "1"; then
|
2013-09-02 14:54:12 +01:00
|
|
|
echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt
|
2008-05-29 15:16:35 +01:00
|
|
|
fi
|
2010-01-19 17:41:54 +00:00
|
|
|
|
|
|
|
# Use symlinks instead of hard links to save space ("strip" in the
|
|
|
|
# fixup phase strips each hard link separately).
|
2014-01-07 13:55:55 +00:00
|
|
|
for i in binutils/Makefile.in gas/Makefile.in ld/Makefile.in gold/Makefile.in; do
|
2012-01-19 15:02:47 +00:00
|
|
|
sed -i "$i" -e 's|ln |ln -s |'
|
2010-01-19 17:41:54 +00:00
|
|
|
done
|
2008-05-29 15:16:35 +01:00
|
|
|
'';
|
2009-11-08 00:32:12 +00:00
|
|
|
|
2011-10-25 19:35:17 +01:00
|
|
|
# As binutils takes part in the stdenv building, we don't want references
|
|
|
|
# to the bootstrap-tools libgcc (as uses to happen on arm/mips)
|
2015-06-12 01:58:26 +01:00
|
|
|
NIX_CFLAGS_COMPILE = if stdenv.isDarwin
|
|
|
|
then "-Wno-string-plus-int -Wno-deprecated-declarations"
|
|
|
|
else "-static-libgcc";
|
2011-10-25 19:35:17 +01:00
|
|
|
|
2014-01-07 12:57:42 +00:00
|
|
|
configureFlags =
|
2015-05-12 11:40:31 +01:00
|
|
|
[ "--enable-shared" "--enable-deterministic-archives" "--disable-werror" ]
|
2013-09-02 14:54:12 +01:00
|
|
|
++ optional (stdenv.system == "mips64el-linux") "--enable-fix-loongson2f-nop"
|
|
|
|
++ optional (cross != null) "--target=${cross.config}"
|
|
|
|
++ optionals gold [ "--enable-gold" "--enable-plugins" ]
|
2014-01-07 12:57:42 +00:00
|
|
|
++ optional (stdenv.system == "i686-linux") "--enable-targets=x86_64-linux-gnu";
|
2007-04-28 00:30:07 +01:00
|
|
|
|
2011-12-14 14:31:56 +00:00
|
|
|
enableParallelBuilding = true;
|
2013-09-02 14:54:12 +01:00
|
|
|
|
2007-04-28 00:30:07 +01:00
|
|
|
meta = {
|
2014-08-24 15:21:08 +01:00
|
|
|
description = "Tools for manipulating binaries (linker, assembler, etc.)";
|
2009-02-03 19:36:56 +00:00
|
|
|
longDescription = ''
|
|
|
|
The GNU Binutils are a collection of binary tools. The main
|
|
|
|
ones are `ld' (the GNU linker) and `as' (the GNU assembler).
|
|
|
|
They also include the BFD (Binary File Descriptor) library,
|
|
|
|
`gprof', `nm', `strip', etc.
|
|
|
|
'';
|
2008-10-29 08:57:58 +00:00
|
|
|
homepage = http://www.gnu.org/software/binutils/;
|
2014-06-19 05:19:00 +01:00
|
|
|
license = stdenv.lib.licenses.gpl3Plus;
|
2016-01-24 06:47:46 +00:00
|
|
|
platforms = stdenv.lib.platforms.linux;
|
2007-04-28 00:30:07 +01:00
|
|
|
|
|
|
|
/* Give binutils a lower priority than gcc-wrapper to prevent a
|
|
|
|
collision due to the ld/as wrappers/symlinks in the latter. */
|
|
|
|
priority = "10";
|
|
|
|
};
|
2012-03-12 15:34:00 +00:00
|
|
|
}
|