2017-06-04 01:28:05 +01:00
|
|
|
{ stdenv, buildPackages
|
|
|
|
, fetchurl, zlib
|
|
|
|
, buildPlatform, hostPlatform, targetPlatform
|
|
|
|
, noSysDirs, gold ? true, bison ? null
|
2014-01-07 12:57:42 +00:00
|
|
|
}:
|
2004-03-09 17:16:02 +00:00
|
|
|
|
2017-06-04 01:28:05 +01:00
|
|
|
let
|
|
|
|
version = "2.28";
|
|
|
|
basename = "binutils-${version}";
|
|
|
|
inherit (stdenv.lib) optional optionals optionalString;
|
|
|
|
in
|
2013-09-02 14:54:12 +01:00
|
|
|
|
2012-03-12 15:34:00 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2017-06-04 01:28:05 +01:00
|
|
|
name = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-" + basename;
|
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";
|
2017-03-07 11:09:41 +00:00
|
|
|
sha256 = "0wiasgns7i8km8nrxas265sh2dfpsw93b3qw195ipc90w4z475v2";
|
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.
|
2016-02-28 00:10:35 +00:00
|
|
|
./pt-pax-flags.patch
|
2017-01-30 13:08:54 +00:00
|
|
|
|
|
|
|
# Bfd looks in BINDIR/../lib for some plugins that don't
|
|
|
|
# exist. This is pointless (since users can't install plugins
|
|
|
|
# there) and causes a cycle between the lib and bin outputs, so
|
|
|
|
# get rid of it.
|
|
|
|
./no-plugins.patch
|
2014-01-07 12:57:42 +00:00
|
|
|
];
|
2009-11-08 00:32:12 +00:00
|
|
|
|
2017-04-24 21:00:11 +01:00
|
|
|
# TODO: all outputs on all platform
|
2017-01-30 13:08:54 +00:00
|
|
|
outputs = [ "out" ]
|
2017-06-04 01:28:05 +01:00
|
|
|
++ optional (targetPlatform == hostPlatform && !hostPlatform.isDarwin) "lib" # problems in Darwin stdenv
|
2017-01-30 13:08:54 +00:00
|
|
|
++ [ "info" ]
|
2017-06-04 01:28:05 +01:00
|
|
|
++ optional (targetPlatform == hostPlatform) "dev";
|
2016-02-28 00:10:35 +00:00
|
|
|
|
2017-06-04 01:28:29 +01:00
|
|
|
nativeBuildInputs = [ bison ]
|
|
|
|
++ optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
|
2015-01-28 23:34:32 +00:00
|
|
|
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
|
|
|
|
2016-02-22 18:32:53 +00:00
|
|
|
# FIXME needs gcc 4.9 in bootstrap tools
|
2016-02-26 17:38:15 +00:00
|
|
|
hardeningDisable = [ "stackprotector" ];
|
2016-02-22 18:32:53 +00:00
|
|
|
|
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)
|
2017-06-04 01:28:05 +01:00
|
|
|
NIX_CFLAGS_COMPILE = if hostPlatform.isDarwin
|
2015-06-12 01:58:26 +01:00
|
|
|
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"
|
2017-06-04 01:28:05 +01:00
|
|
|
++ optional (targetPlatform != hostPlatform) "--target=${targetPlatform.config}" # TODO: make this unconditional
|
2013-09-02 14:54:12 +01:00
|
|
|
++ 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
|
|
|
|
2016-01-25 10:16:23 +00:00
|
|
|
meta = with stdenv.lib; {
|
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/;
|
2016-01-25 10:16:23 +00:00
|
|
|
license = licenses.gpl3Plus;
|
|
|
|
platforms = platforms.unix;
|
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. */
|
2017-04-29 04:02:37 +01:00
|
|
|
priority = 10;
|
2007-04-28 00:30:07 +01:00
|
|
|
};
|
2012-03-12 15:34:00 +00:00
|
|
|
}
|