2017-06-04 02:28:05 +02:00
|
|
|
{ stdenv, buildPackages
|
2018-04-16 01:22:08 +02:00
|
|
|
, fetchurl, zlib, autoreconfHook264
|
2017-06-04 02:28:05 +02:00
|
|
|
, buildPlatform, hostPlatform, targetPlatform
|
|
|
|
, noSysDirs, gold ? true, bison ? null
|
2014-01-07 13:57:42 +01:00
|
|
|
}:
|
2004-03-09 18:16:02 +01:00
|
|
|
|
2017-06-04 02:28:05 +02:00
|
|
|
let
|
2018-03-28 18:40:44 +02:00
|
|
|
# Remove gold-symbol-visibility patch when updating, the proper fix
|
|
|
|
# is now upstream.
|
|
|
|
# https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=330b90b5ffbbc20c5de6ae6c7f60c40fab2e7a4f;hp=99181ccac0fc7d82e7dabb05dc7466e91f1645d3
|
2018-02-20 17:15:57 +01:00
|
|
|
version = "2.30";
|
2017-06-04 02:28:05 +02:00
|
|
|
basename = "binutils-${version}";
|
|
|
|
inherit (stdenv.lib) optional optionals optionalString;
|
2017-11-25 19:43:57 +01:00
|
|
|
# The targetPrefix prepended to binary names to allow multiple binuntils on the
|
2017-06-23 23:45:27 +02:00
|
|
|
# PATH to both be usable.
|
2017-11-25 19:43:57 +01:00
|
|
|
targetPrefix = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
|
2017-06-04 02:28:05 +02:00
|
|
|
in
|
2013-09-02 15:54:12 +02:00
|
|
|
|
2012-03-12 16:34:00 +01:00
|
|
|
stdenv.mkDerivation rec {
|
2017-11-25 19:43:57 +01:00
|
|
|
name = targetPrefix + basename;
|
2009-11-08 01:32:12 +01:00
|
|
|
|
2018-05-22 23:37:29 +02:00
|
|
|
# HACK to ensure that we preserve source from bootstrap binutils to not rebuild LLVM
|
|
|
|
src = stdenv.__bootPackages.binutils-unwrapped.src or (fetchurl {
|
2011-10-03 21:11:09 +02:00
|
|
|
url = "mirror://gnu/binutils/${basename}.tar.bz2";
|
2018-02-20 17:15:57 +01:00
|
|
|
sha256 = "028cklfqaab24glva1ks2aqa1zxa6w6xmc8q34zs1sb7h22dxspg";
|
2018-05-22 23:37:29 +02:00
|
|
|
});
|
2008-05-29 16:16:35 +02: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 16:20:23 +01: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 13:57:42 +01:00
|
|
|
|
|
|
|
# Make binutils output deterministic by default.
|
|
|
|
./deterministic.patch
|
2014-03-08 21:57:18 +01: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 01:10:35 +01:00
|
|
|
./pt-pax-flags.patch
|
2016-10-14 17:52:14 +02: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 04:30:43 +01: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
|
2017-10-26 22:00:37 +02:00
|
|
|
|
|
|
|
# For some reason bfd ld doesn't search DT_RPATH when cross-compiling. It's
|
|
|
|
# not clear why this behavior was decided upon but it has the unfortunate
|
|
|
|
# consequence that the linker will fail to find transitive dependencies of
|
|
|
|
# shared objects when cross-compiling. Consequently, we are forced to
|
|
|
|
# override this behavior, forcing ld to search DT_RPATH even when
|
|
|
|
# cross-compiling.
|
|
|
|
./always-search-rpath.patch
|
2018-03-19 16:00:41 +01:00
|
|
|
|
|
|
|
# https://sourceware.org/bugzilla/show_bug.cgi?id=22868
|
|
|
|
./gold-symbol-visibility.patch
|
2018-05-22 02:26:37 +02:00
|
|
|
|
2018-04-17 17:21:28 +02:00
|
|
|
# Version 2.30 introduced strict requirements on ELF relocations which cannot
|
|
|
|
# be satisfied on aarch64 platform. Add backported fix from bugzilla.
|
|
|
|
# https://sourceware.org/bugzilla/show_bug.cgi?id=22764
|
|
|
|
./relax-R_AARCH64_ABS32-R_AARCH64_ABS16-absolute.patch
|
2018-04-16 01:22:08 +02:00
|
|
|
] ++ stdenv.lib.optional targetPlatform.isiOS ./support-ios.patch;
|
2009-11-08 01:32:12 +01:00
|
|
|
|
2017-11-26 20:46:34 +01:00
|
|
|
outputs = [ "out" "info" "man" ];
|
2016-02-28 01:10:35 +01:00
|
|
|
|
2017-06-26 05:10:03 +02:00
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
2018-04-16 01:22:08 +02:00
|
|
|
nativeBuildInputs = [
|
|
|
|
bison
|
|
|
|
] ++ stdenv.lib.optionals targetPlatform.isiOS [
|
|
|
|
autoreconfHook264
|
|
|
|
];
|
2015-01-29 00:34:32 +01:00
|
|
|
buildInputs = [ zlib ];
|
2010-12-13 00:35:16 +01:00
|
|
|
|
2004-03-29 19:23:01 +02:00
|
|
|
inherit noSysDirs;
|
2008-05-29 16:16:35 +02:00
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
# Clear the default library search path.
|
|
|
|
if test "$noSysDirs" = "1"; then
|
2013-09-02 15:54:12 +02:00
|
|
|
echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt
|
2008-05-29 16:16:35 +02:00
|
|
|
fi
|
2010-01-19 18:41:54 +01:00
|
|
|
|
|
|
|
# Use symlinks instead of hard links to save space ("strip" in the
|
|
|
|
# fixup phase strips each hard link separately).
|
2014-01-07 14:55:55 +01:00
|
|
|
for i in binutils/Makefile.in gas/Makefile.in ld/Makefile.in gold/Makefile.in; do
|
2012-01-19 16:02:47 +01:00
|
|
|
sed -i "$i" -e 's|ln |ln -s |'
|
2010-01-19 18:41:54 +01:00
|
|
|
done
|
2008-05-29 16:16:35 +02:00
|
|
|
'';
|
2009-11-08 01:32:12 +01:00
|
|
|
|
2011-10-25 20:35:17 +02: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 02:28:05 +02:00
|
|
|
NIX_CFLAGS_COMPILE = if hostPlatform.isDarwin
|
2015-06-12 02:58:26 +02:00
|
|
|
then "-Wno-string-plus-int -Wno-deprecated-declarations"
|
|
|
|
else "-static-libgcc";
|
2011-10-25 20:35:17 +02:00
|
|
|
|
2018-06-13 04:54:10 +02:00
|
|
|
hardeningDisable = [ "format" ];
|
|
|
|
|
2017-11-25 19:43:57 +01:00
|
|
|
# TODO(@Ericson2314): Always pass "--target" and always targetPrefix.
|
2018-04-27 02:20:37 +02:00
|
|
|
configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
|
2017-08-18 19:00:24 +02:00
|
|
|
|
2017-10-17 22:44:24 +02: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-28 01:30:07 +02:00
|
|
|
|
2018-04-25 05:20:18 +02:00
|
|
|
doCheck = false; # fails
|
|
|
|
|
2011-12-14 15:31:56 +01:00
|
|
|
enableParallelBuilding = true;
|
2013-09-02 15:54:12 +02:00
|
|
|
|
2017-06-23 23:45:27 +02:00
|
|
|
passthru = {
|
2017-11-25 19:43:57 +01:00
|
|
|
inherit targetPrefix version;
|
2017-06-23 23:45:27 +02:00
|
|
|
};
|
|
|
|
|
2016-01-25 11:16:23 +01:00
|
|
|
meta = with stdenv.lib; {
|
2014-08-24 16:21:08 +02:00
|
|
|
description = "Tools for manipulating binaries (linker, assembler, etc.)";
|
2009-02-03 20:36:56 +01: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 09:57:58 +01:00
|
|
|
homepage = http://www.gnu.org/software/binutils/;
|
2016-01-25 11:16:23 +01:00
|
|
|
license = licenses.gpl3Plus;
|
2017-11-14 16:49:30 +01:00
|
|
|
maintainers = with maintainers; [ ericson2314 ];
|
2016-01-25 11:16:23 +01:00
|
|
|
platforms = platforms.unix;
|
2007-04-28 01:30:07 +02: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 05:02:37 +02:00
|
|
|
priority = 10;
|
2007-04-28 01:30:07 +02:00
|
|
|
};
|
2012-03-12 16:34:00 +01:00
|
|
|
}
|