lol
at 18.09-beta 149 lines 5.7 kB view raw
1{ stdenv, buildPackages 2, fetchurl, zlib, autoreconfHook264 3, noSysDirs, gold ? true, bison ? null 4}: 5 6let 7 # Remove gold-symbol-visibility patch when updating, the proper fix 8 # is now upstream. 9 # https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=330b90b5ffbbc20c5de6ae6c7f60c40fab2e7a4f;hp=99181ccac0fc7d82e7dabb05dc7466e91f1645d3 10 version = "2.30"; 11 basename = "binutils-${version}"; 12 inherit (stdenv.lib) optionals optionalString; 13 # The targetPrefix prepended to binary names to allow multiple binuntils on the 14 # PATH to both be usable. 15 targetPrefix = optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "${stdenv.targetPlatform.config}-"; 16in 17 18stdenv.mkDerivation rec { 19 name = targetPrefix + basename; 20 21 # HACK to ensure that we preserve source from bootstrap binutils to not rebuild LLVM 22 src = stdenv.__bootPackages.binutils-unwrapped.src or (fetchurl { 23 url = "mirror://gnu/binutils/${basename}.tar.bz2"; 24 sha256 = "028cklfqaab24glva1ks2aqa1zxa6w6xmc8q34zs1sb7h22dxspg"; 25 }); 26 27 patches = [ 28 # Since binutils 2.22, DT_NEEDED flags aren't copied for dynamic outputs. 29 # That requires upstream changes for things to work. So we can patch it to 30 # get the old behaviour by now. 31 ./dtneeded.patch 32 33 # Make binutils output deterministic by default. 34 ./deterministic.patch 35 36 # Always add PaX flags section to ELF files. 37 # This is needed, for instance, so that running "ldd" on a binary that is 38 # PaX-marked to disable mprotect doesn't fail with permission denied. 39 ./pt-pax-flags.patch 40 41 # Bfd looks in BINDIR/../lib for some plugins that don't 42 # exist. This is pointless (since users can't install plugins 43 # there) and causes a cycle between the lib and bin outputs, so 44 # get rid of it. 45 ./no-plugins.patch 46 47 # Help bfd choose between elf32-littlearm, elf32-littlearm-symbian, and 48 # elf32-littlearm-vxworks in favor of the first. 49 # https://github.com/NixOS/nixpkgs/pull/30484#issuecomment-345472766 50 ./disambiguate-arm-targets.patch 51 52 # For some reason bfd ld doesn't search DT_RPATH when cross-compiling. It's 53 # not clear why this behavior was decided upon but it has the unfortunate 54 # consequence that the linker will fail to find transitive dependencies of 55 # shared objects when cross-compiling. Consequently, we are forced to 56 # override this behavior, forcing ld to search DT_RPATH even when 57 # cross-compiling. 58 ./always-search-rpath.patch 59 60 # https://sourceware.org/bugzilla/show_bug.cgi?id=22868 61 ./gold-symbol-visibility.patch 62 63 # Version 2.30 introduced strict requirements on ELF relocations which cannot 64 # be satisfied on aarch64 platform. Add backported fix from bugzilla. 65 # https://sourceware.org/bugzilla/show_bug.cgi?id=22764 66 ./relax-R_AARCH64_ABS32-R_AARCH64_ABS16-absolute.patch 67 ] ++ stdenv.lib.optional stdenv.targetPlatform.isiOS ./support-ios.patch; 68 69 outputs = [ "out" "info" "man" ]; 70 71 depsBuildBuild = [ buildPackages.stdenv.cc ]; 72 nativeBuildInputs = [ 73 bison 74 ] ++ stdenv.lib.optionals stdenv.targetPlatform.isiOS [ 75 autoreconfHook264 76 ]; 77 buildInputs = [ zlib ]; 78 79 inherit noSysDirs; 80 81 preConfigure = '' 82 # Clear the default library search path. 83 if test "$noSysDirs" = "1"; then 84 echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt 85 fi 86 87 # Use symlinks instead of hard links to save space ("strip" in the 88 # fixup phase strips each hard link separately). 89 for i in binutils/Makefile.in gas/Makefile.in ld/Makefile.in gold/Makefile.in; do 90 sed -i "$i" -e 's|ln |ln -s |' 91 done 92 ''; 93 94 # As binutils takes part in the stdenv building, we don't want references 95 # to the bootstrap-tools libgcc (as uses to happen on arm/mips) 96 NIX_CFLAGS_COMPILE = if stdenv.hostPlatform.isDarwin 97 then "-Wno-string-plus-int -Wno-deprecated-declarations" 98 else "-static-libgcc"; 99 100 hardeningDisable = [ "format" ]; 101 102 # TODO(@Ericson2314): Always pass "--target" and always targetPrefix. 103 configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (stdenv.targetPlatform != stdenv.hostPlatform) "target"; 104 105 configureFlags = [ 106 "--enable-targets=all" "--enable-64-bit-bfd" 107 "--disable-install-libbfd" 108 "--disable-shared" "--enable-static" 109 "--with-system-zlib" 110 111 "--enable-deterministic-archives" 112 "--disable-werror" 113 "--enable-fix-loongson2f-nop" 114 115 # Turn on --enable-new-dtags by default to make the linker set 116 # RUNPATH instead of RPATH on binaries. This is important because 117 # RUNPATH can be overriden using LD_LIBRARY_PATH at runtime. 118 "--enable-new-dtags" 119 ] ++ optionals gold [ "--enable-gold" "--enable-plugins" ]; 120 121 doCheck = false; # fails 122 123 # else fails with "./sanity.sh: line 36: $out/bin/size: not found" 124 doInstallCheck = stdenv.buildPlatform == stdenv.hostPlatform && stdenv.hostPlatform == stdenv.targetPlatform; 125 126 enableParallelBuilding = true; 127 128 passthru = { 129 inherit targetPrefix version; 130 }; 131 132 meta = with stdenv.lib; { 133 description = "Tools for manipulating binaries (linker, assembler, etc.)"; 134 longDescription = '' 135 The GNU Binutils are a collection of binary tools. The main 136 ones are `ld' (the GNU linker) and `as' (the GNU assembler). 137 They also include the BFD (Binary File Descriptor) library, 138 `gprof', `nm', `strip', etc. 139 ''; 140 homepage = http://www.gnu.org/software/binutils/; 141 license = licenses.gpl3Plus; 142 maintainers = with maintainers; [ ericson2314 ]; 143 platforms = platforms.unix; 144 145 /* Give binutils a lower priority than gcc-wrapper to prevent a 146 collision due to the ld/as wrappers/symlinks in the latter. */ 147 priority = 10; 148 }; 149}