2017-06-04 00:28:05 +00: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 00:28:05 +00:00
|
|
|
let
|
2017-08-16 22:09:51 +00:00
|
|
|
# Note to whoever is upgrading this: 2.29 is broken.
|
|
|
|
# ('nix-build pkgs/stdenv/linux/make-bootstrap-tools.nix -A test' segfaults on aarch64)
|
|
|
|
# Also glibc might need patching, see commit 733e20fee4a6700510f71fbe1a58ac23ea202f6a.
|
2017-08-16 22:02:35 +00:00
|
|
|
version = "2.28.1";
|
2017-06-04 00:28:05 +00:00
|
|
|
basename = "binutils-${version}";
|
|
|
|
inherit (stdenv.lib) optional optionals optionalString;
|
2017-06-23 21:45:27 +00:00
|
|
|
# The prefix prepended to binary names to allow multiple binuntils on the
|
|
|
|
# PATH to both be usable.
|
|
|
|
prefix = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
|
2017-06-04 00:28:05 +00:00
|
|
|
in
|
2013-09-02 13:54:12 +00:00
|
|
|
|
2012-03-12 15:34:00 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2017-06-23 21:45:27 +00:00
|
|
|
name = prefix + basename;
|
2009-11-08 00:32:12 +00:00
|
|
|
|
2003-11-03 10:22:00 +00:00
|
|
|
src = fetchurl {
|
2011-10-03 19:11:09 +00:00
|
|
|
url = "mirror://gnu/binutils/${basename}.tar.bz2";
|
2017-08-16 22:02:35 +00:00
|
|
|
sha256 = "1sj234nd05cdgga1r36zalvvdkvpfbr12g5mir2n8i1dwsdrj939";
|
2003-11-03 10:22:00 +00:00
|
|
|
};
|
2008-05-29 14:16:35 +00: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
|
2016-10-14 15:52:14 +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
|
2017-11-19 03:30:43 +00:00
|
|
|
|
|
|
|
# Help bfd choose between elf32-littlearm, elf32-littlearm-symbian, and
|
|
|
|
# elf32-littlearm-vxworks in favor of the first.
|
|
|
|
# https://github.com/NixOS/nixpkgs/pull/30484#issuecomment-345472766
|
|
|
|
./disambiguate-arm-targets.patch
|
2014-01-07 12:57:42 +00:00
|
|
|
];
|
2009-11-08 00:32:12 +00:00
|
|
|
|
2017-10-17 20:44:24 +00:00
|
|
|
outputs = [ "out" "info" ];
|
2016-02-28 00:10:35 +00:00
|
|
|
|
2017-10-17 20:44:24 +00:00
|
|
|
nativeBuildInputs = [ bison buildPackages.stdenv.cc ];
|
2015-01-28 23:34:32 +00:00
|
|
|
buildInputs = [ zlib ];
|
2010-12-12 23:35:16 +00:00
|
|
|
|
2004-03-29 17:23:01 +00:00
|
|
|
inherit noSysDirs;
|
2008-05-29 14:16:35 +00:00
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
# Clear the default library search path.
|
|
|
|
if test "$noSysDirs" = "1"; then
|
2013-09-02 13:54:12 +00:00
|
|
|
echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt
|
2008-05-29 14:16:35 +00: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 14:16:35 +00:00
|
|
|
'';
|
2009-11-08 00:32:12 +00:00
|
|
|
|
2011-10-25 18:35:17 +00: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 00:28:05 +00:00
|
|
|
NIX_CFLAGS_COMPILE = if hostPlatform.isDarwin
|
2015-06-12 00:58:26 +00:00
|
|
|
then "-Wno-string-plus-int -Wno-deprecated-declarations"
|
|
|
|
else "-static-libgcc";
|
2011-10-25 18:35:17 +00:00
|
|
|
|
2017-06-23 21:45:27 +00:00
|
|
|
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
2017-08-18 17:00:24 +00:00
|
|
|
configurePlatforms =
|
|
|
|
# TODO(@Ericson2314): Figure out what's going wrong with Arm
|
2017-08-23 22:16:02 +00:00
|
|
|
if hostPlatform == targetPlatform && targetPlatform.isArm
|
2017-08-18 17:00:24 +00:00
|
|
|
then []
|
|
|
|
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
|
|
|
|
|
2017-10-17 20:44:24 +00:00
|
|
|
configureFlags = [
|
|
|
|
"--enable-targets=all" "--enable-64-bit-bfd"
|
|
|
|
"--disable-install-libbfd"
|
|
|
|
"--disable-shared" "--enable-static"
|
|
|
|
"--with-system-zlib"
|
|
|
|
|
|
|
|
"--enable-deterministic-archives"
|
|
|
|
"--disable-werror"
|
|
|
|
"--enable-fix-loongson2f-nop"
|
|
|
|
] ++ optionals gold [ "--enable-gold" "--enable-plugins" ];
|
2007-04-27 23:30:07 +00:00
|
|
|
|
2011-12-14 14:31:56 +00:00
|
|
|
enableParallelBuilding = true;
|
2013-09-02 13:54:12 +00:00
|
|
|
|
2017-06-23 21:45:27 +00:00
|
|
|
passthru = {
|
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
2017-10-10 22:48:42 +00:00
|
|
|
inherit prefix version;
|
2017-06-23 21:45:27 +00:00
|
|
|
};
|
|
|
|
|
2016-01-25 10:16:23 +00:00
|
|
|
meta = with stdenv.lib; {
|
2014-08-24 14:21:08 +00: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;
|
2017-11-14 15:49:30 +00:00
|
|
|
maintainers = with maintainers; [ ericson2314 ];
|
2016-01-25 10:16:23 +00:00
|
|
|
platforms = platforms.unix;
|
2007-04-27 23:30:07 +00: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 03:02:37 +00:00
|
|
|
priority = 10;
|
2007-04-27 23:30:07 +00:00
|
|
|
};
|
2012-03-12 15:34:00 +00:00
|
|
|
}
|