···11+From beca4a2c25ee86e4020f8b8bddc4d8e0ed3430b3 Mon Sep 17 00:00:00 2001
22+From: Andrew Childs <andrew.childs@bibo.com.ph>
33+Date: Tue, 22 Feb 2022 11:28:04 +0900
44+Subject: [PATCH] Revert "libtool.m4: fix nm BSD flag detection"
55+66+This reverts commit bef9ef8ca0f941d743c77cc55b5fe7985990b2a7.
77+---
88+ ChangeLog | 9 ------
99+ libtool.m4 | 88 ++++++++++++++++++++++++++----------------------------
1010+ 2 files changed, 43 insertions(+), 54 deletions(-)
1111+1212+diff --git a/ChangeLog b/ChangeLog
1313+index 18e8b6835da..c12f07403c3 100644
1414+--- a/ChangeLog
1515++++ b/ChangeLog
1616+@@ -375,15 +375,6 @@
1717+1818+ * src-release.sh (GDB_SUPPPORT_DIRS): Add libbacktrace.
1919+2020+-2021-09-27 Nick Alcock <nick.alcock@oracle.com>
2121+-
2222+- PR libctf/27967
2323+- * libtool.m4 (LT_PATH_NM): Try BSDization flags with a user-provided
2424+- NM, if there is one. Run nm on itself, not on /dev/null, to avoid
2525+- errors from nms that refuse to work on non-regular files. Remove
2626+- other workarounds for this problem. Strip out blank lines from the
2727+- nm output.
2828+-
2929+ 2021-09-27 Nick Alcock <nick.alcock@oracle.com>
3030+3131+ PR libctf/27967
3232+diff --git a/libtool.m4 b/libtool.m4
3333+index a216bb14e99..7a711249304 100644
3434+--- a/libtool.m4
3535++++ b/libtool.m4
3636+@@ -3200,55 +3200,53 @@ _LT_DECL([], [file_magic_cmd], [1],
3737+3838+ # LT_PATH_NM
3939+ # ----------
4040+-# find the pathname to a BSD- or MS-compatible name lister, and any flags
4141+-# needed to make it compatible
4242++# find the pathname to a BSD- or MS-compatible name lister
4343+ AC_DEFUN([LT_PATH_NM],
4444+ [AC_REQUIRE([AC_PROG_CC])dnl
4545+ AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
4646+ [if test -n "$NM"; then
4747+- # Let the user override the nm to test.
4848+- lt_nm_to_check="$NM"
4949+- else
5050+- lt_nm_to_check="${ac_tool_prefix}nm"
5151+- if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
5252+- lt_nm_to_check="$lt_nm_to_check nm"
5353+- fi
5454+- fi
5555+- for lt_tmp_nm in $lt_nm_to_check; do
5656+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
5757+- for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
5858+- IFS="$lt_save_ifs"
5959+- test -z "$ac_dir" && ac_dir=.
6060+- case "$lt_tmp_nm" in
6161+- */*|*\\*) tmp_nm="$lt_tmp_nm";;
6262+- *) tmp_nm="$ac_dir/$lt_tmp_nm";;
6363+- esac
6464+- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
6565+- # Check to see if the nm accepts a BSD-compat flag.
6666+- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
6767+- # nm: unknown option "B" ignored
6868+- case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
6969+- *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
7070+- break
7171+- ;;
7272+- *)
7373+- case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
7474+- *$tmp_nm*)
7575+- lt_cv_path_NM="$tmp_nm -p"
7676+- break
7777+- ;;
7878+- *)
7979+- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
8080+- continue # so that we can try to find one that supports BSD flags
8181+- ;;
8282+- esac
8383+- ;;
8484+- esac
8585+- fi
8686+- done
8787+- IFS="$lt_save_ifs"
8888+- done
8989+- : ${lt_cv_path_NM=no}])
9090++ # Let the user override the test.
9191++ lt_cv_path_NM="$NM"
9292++else
9393++ lt_nm_to_check="${ac_tool_prefix}nm"
9494++ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
9595++ lt_nm_to_check="$lt_nm_to_check nm"
9696++ fi
9797++ for lt_tmp_nm in $lt_nm_to_check; do
9898++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
9999++ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
100100++ IFS="$lt_save_ifs"
101101++ test -z "$ac_dir" && ac_dir=.
102102++ tmp_nm="$ac_dir/$lt_tmp_nm"
103103++ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
104104++ # Check to see if the nm accepts a BSD-compat flag.
105105++ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
106106++ # nm: unknown option "B" ignored
107107++ # Tru64's nm complains that /dev/null is an invalid object file
108108++ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
109109++ */dev/null* | *'Invalid file or object type'*)
110110++ lt_cv_path_NM="$tmp_nm -B"
111111++ break
112112++ ;;
113113++ *)
114114++ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
115115++ */dev/null*)
116116++ lt_cv_path_NM="$tmp_nm -p"
117117++ break
118118++ ;;
119119++ *)
120120++ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
121121++ continue # so that we can try to find one that supports BSD flags
122122++ ;;
123123++ esac
124124++ ;;
125125++ esac
126126++ fi
127127++ done
128128++ IFS="$lt_save_ifs"
129129++ done
130130++ : ${lt_cv_path_NM=no}
131131++fi])
132132+ if test "$lt_cv_path_NM" != "no"; then
133133+ NM="$lt_cv_path_NM"
134134+ else
135135+--
136136+2.34.1
137137+
···11diff --git a/bfd/configure.ac b/bfd/configure.ac
22-index c5bfbd5d..45ad4c26 100644
22+index fec067b2135..377e1f5443f 100644
33--- a/bfd/configure.ac
44+++ b/bfd/configure.ac
55-@@ -278,31 +278,19 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
55+@@ -292,30 +292,16 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
6677 LT_LIB_M
88···2121- if test -n "$x"; then
2222- SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty"
2323- fi
2424+-fi
2425-
2626+ SHARED_LIBADD="$SHARED_LIBADD $LIBINTL"
2727+2828+-if test "$enable_shared" = "yes"; then
2529 case "${host}" in
2630 # More hacks to build DLLs on Windows.
2731 *-*-cygwin*)
2832 SHARED_LDFLAGS="-no-undefined"
2929-- SHARED_LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin -lkernel32"
3030-+ SHARED_LIBADD="-liberty -lintl -lcygwin -lkernel32"
3131- ;;
3232-3333- # Use built-in libintl on macOS, since it is not provided by libc.
3434- *-*-darwin*)
3535-- SHARED_LIBADD="-L`pwd`/../libiberty/pic -L`pwd`/../intl -liberty -lintl"
3636-+ SHARED_LIBADD="-liberty -lintl"
3333+- SHARED_LIBADD="-L`pwd`/../libiberty -liberty $SHARED_LIBADD -lcygwin -lkernel32"
3434++ SHARED_LIBADD="-liberty $SHARED_LIBADD -lcygwin -lkernel32"
3735 ;;
3836 esac
39374038diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
4141-index 4f06074a..6836c589 100644
3939+index 0e04b4c05c4..848a02662e7 100644
4240--- a/opcodes/Makefile.am
4341+++ b/opcodes/Makefile.am
4442@@ -51,7 +51,7 @@ libopcodes_la_LDFLAGS += -rpath $(rpath_bfdlibdir)
···50485149 BUILD_LIBS = @BUILD_LIBS@
5250 BUILD_LIB_DEPS = @BUILD_LIB_DEPS@
5353-@@ -301,7 +301,7 @@ OFILES = @BFD_MACHINES@
5151+@@ -303,7 +303,7 @@ OFILES = @BFD_MACHINES@
5452 # development.sh is used to determine -Werror default.
5553 CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh
5654···59576058 disassemble.lo: disassemble.c
6159 if am__fastdepCC
6262-@@ -322,12 +322,21 @@ libopcodes_la_SOURCES = dis-buf.c disassemble.c dis-init.c
6363- # old version of libbfd, or to pick up libbfd for the wrong architecture
6464- # if host != build. So for building with shared libraries we use a
6565- # hardcoded path to libbfd.so instead of relying on the entries in libbfd.la.
6060+@@ -327,9 +327,18 @@ libopcodes_la_SOURCES = dis-buf.c disassemble.c dis-init.c
6661-libopcodes_la_DEPENDENCIES = $(OFILES) @SHARED_DEPENDENCIES@
6762+libopcodes_la_DEPENDENCIES = $(OFILES) @SHARED_DEPENDENCIES@ libtool-soversion
6863 libopcodes_la_LIBADD = $(OFILES) @SHARED_LIBADD@
···8479 # the build directory so that we don't have to convert all the
8580 # programs that use libopcodes.a simultaneously. This is a hack which
8681diff --git a/opcodes/configure.ac b/opcodes/configure.ac
8787-index 00be9c88..6e589ae4 100644
8282+index e564f067334..5da62a3d58b 100644
8883--- a/opcodes/configure.ac
8984+++ b/opcodes/configure.ac
9090-@@ -86,6 +86,7 @@ AC_PROG_INSTALL
8585+@@ -98,6 +98,8 @@ BFD_64_BIT
8686+ AC_SUBST(HDEFINES)
8787+ AC_PROG_INSTALL
91889292- AC_CHECK_HEADERS(string.h strings.h stdlib.h limits.h)
9393- ACX_HEADER_STRING
9489+GCC_HEADER_STDINT(bfd_stdint.h)
9595-9090++
9691 AC_CHECK_DECLS([basename, stpcpy])
97929898-@@ -137,61 +138,27 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
9393+ # Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't do
9494+@@ -148,44 +150,21 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
999510096 LT_LIB_M
10197···122118-SHARED_LIBADD=
123119+SHARED_LIBADD=-liberty
124120 SHARED_DEPENDENCIES=
125125- if test "$enable_shared" = "yes"; then
121121+-if test "$enable_shared" = "yes"; then
126122-# When building a shared libopcodes, link against the pic version of libiberty
127123-# so that apps that use libopcodes won't need libiberty just to satisfy any
128124-# libopcodes references.
···131127 # Note that linking against libbfd as we do here, which is itself linked
132128 # against libiberty, may not satisfy all the libopcodes libiberty references
133129 # since libbfd may not pull in the entirety of libiberty.
130130+ # Also, jam libintl into the right place in all of this: after libiberty,
131131+ # which uses it, but before -lcygwin, which it uses.
134132-changequote(,)dnl
135133- x=`sed -n -e 's/^[ ]*PICFLAG[ ]*=[ ]*//p' < ../libiberty/Makefile | sed -n '$p'`
136134-changequote([,])dnl
137135- if test -n "$x"; then
138136- SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty"
139137- fi
140140--
138138+-fi
139139+140140+ SHARED_LIBADD="$SHARED_LIBADD $LIBINTL"
141141+142142+@@ -193,11 +172,10 @@ if test "$enable_shared" = "yes"; then
141143 case "${host}" in
142144 *-*-cygwin*)
143145 SHARED_LDFLAGS="-no-undefined"
144144-- SHARED_LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin"
145145-+ SHARED_LIBADD="-lbfd -liberty -lintl -lcygwin"
146146+- SHARED_LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty $SHARED_LIBADD"
147147++ SHARED_LIBADD="-lbfd -liberty $SHARED_LIBADD"
146148 ;;
147147-- *-*-darwin*)
148148-- SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.dylib ${SHARED_LIBADD}"
149149-- SHARED_DEPENDENCIES="../bfd/libbfd.la"
150150-- ;;
151149 *)
152152-- case "$host_vendor" in
153153-- hp)
154154-- SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.sl ${SHARED_LIBADD}"
155155-- ;;
156156-- *)
157157-- SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.so ${SHARED_LIBADD}"
158158-- ;;
159159-- esac
150150+- SHARED_LIBADD="../bfd/libbfd.la ${SHARED_LIBADD}"
160151- SHARED_DEPENDENCIES="../bfd/libbfd.la"
161152+ SHARED_LIBADD="-lbfd ${SHARED_LIBADD}"
162153 ;;
+106-96
pkgs/development/tools/misc/binutils/default.nix
···22 execFormatIsELF = platform: platform.parsed.kernel.execFormat.name == "elf";
33in
4455-{ stdenv, lib, buildPackages
66-, fetchFromGitHub, fetchurl, zlib, autoreconfHook, gettext
77-# Enabling all targets increases output size to a multiple.
88-, withAllTargets ? false, libbfd, libopcodes
99-, enableShared ? !stdenv.hostPlatform.isStatic
1010-, noSysDirs
1111-, gold ? execFormatIsELF stdenv.targetPlatform
1212-, bison ? null
55+{ stdenv
66+, autoreconfHook
77+, autoconf269, automake, libtool
88+, bison
99+, buildPackages
1010+, fetchFromGitHub
1111+, fetchurl
1312, flex
1313+, gettext
1414+, lib
1515+, noSysDirs
1616+, perl
1417, texinfo
1515-, perl
1818+, zlib
1919+2020+, enableGold ? execFormatIsELF stdenv.targetPlatform
2121+, enableShared ? !stdenv.hostPlatform.isStatic
2222+ # WARN: Enabling all targets increases output size to a multiple.
2323+, withAllTargets ? false, libbfd, libopcodes
1624}:
17251818-# configure silently disables ld.gold if it's unsupported,
1919-# so we need to make sure that intent matches result ourselves.
2020-assert gold -> execFormatIsELF stdenv.targetPlatform;
2626+# WARN: configure silently disables ld.gold if it's unsupported, so we need to
2727+# make sure that intent matches result ourselves.
2828+assert enableGold -> execFormatIsELF stdenv.targetPlatform;
21292222-# Note: this package is used for bootstrapping fetchurl, and thus
2323-# cannot use fetchpatch! All mutable patches (generated by GitHub or
2424-# cgit) that are needed here should be included directly in Nixpkgs as
2525-# files.
26302731let
2828- reuseLibs = enableShared && withAllTargets;
3232+ inherit (stdenv) buildPlatform hostPlatform targetPlatform;
3333+3434+ version = "2.38";
29353030- version = "2.35.2";
3131- basename = "binutils";
3232- # The targetPrefix prepended to binary names to allow multiple binuntils on the
3333- # PATH to both be usable.
3434- targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
3535- "${stdenv.targetPlatform.config}-";
3636- vc4-binutils-src = fetchFromGitHub {
3737- owner = "itszor";
3838- repo = "binutils-vc4";
3939- rev = "708acc851880dbeda1dd18aca4fd0a95b2573b36";
4040- sha256 = "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63";
3636+ srcs = {
3737+ normal = fetchurl {
3838+ url = "mirror://gnu/binutils/binutils-${version}.tar.bz2";
3939+ sha256 = "sha256-Bw7HHPB3pqWOC5WfBaCaNQFTeMLYpR6Q866r/jBZDvg=";
4040+ };
4141+ vc4-none = fetchFromGitHub {
4242+ owner = "itszor";
4343+ repo = "binutils-vc4";
4444+ rev = "708acc851880dbeda1dd18aca4fd0a95b2573b36";
4545+ sha256 = "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63";
4646+ };
4147 };
4242- # HACK to ensure that we preserve source from bootstrap binutils to not rebuild LLVM
4343- normal-src = stdenv.__bootPackages.binutils-unwrapped.src or (fetchurl {
4444- url = "mirror://gnu/binutils/${basename}-${version}.tar.bz2";
4545- sha256 = "sha256-z6dkTb7PRZHhNutAfBwdoWV4vSsD8MLorNzroZS7nWE=";
4646- });
4848+4949+ #INFO: The targetPrefix prepended to binary names to allow multiple binuntils
5050+ # on the PATH to both be usable.
5151+ targetPrefix = lib.optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
4752in
48534954stdenv.mkDerivation {
5050- pname = targetPrefix + basename;
5555+ pname = targetPrefix + "binutils";
5156 inherit version;
52575353- src = if stdenv.targetPlatform.isVc4 then vc4-binutils-src else normal-src;
5858+ # HACK: Ensure that we preserve source from bootstrap binutils to not rebuild LLVM
5959+ src = stdenv.__bootPackages.binutils-unwrapped.src
6060+ or srcs.${targetPlatform.system}
6161+ or srcs.normal;
54626363+ # WARN: this package is used for bootstrapping fetchurl, and thus cannot use
6464+ # fetchpatch! All mutable patches (generated by GitHub or cgit) that are
6565+ # needed here should be included directly in Nixpkgs as files.
5566 patches = [
5667 # Make binutils output deterministic by default.
5768 ./deterministic.patch
58695959- # Help bfd choose between elf32-littlearm, elf32-littlearm-symbian, and
6060- # elf32-littlearm-vxworks in favor of the first.
6161- # https://github.com/NixOS/nixpkgs/pull/30484#issuecomment-345472766
6262- ./disambiguate-arm-targets.patch
7070+7171+ # Breaks nm BSD flag detection
7272+ ./0001-Revert-libtool.m4-fix-nm-BSD-flag-detection.patch
7373+7474+ # Required for newer macos versions
7575+ ./0001-libtool.m4-update-macos-version-detection-block.patch
63766477 # For some reason bfd ld doesn't search DT_RPATH when cross-compiling. It's
6578 # not clear why this behavior was decided upon but it has the unfortunate
···6881 # override this behavior, forcing ld to search DT_RPATH even when
6982 # cross-compiling.
7083 ./always-search-rpath.patch
7171-7272- # Fix quadratic slowdown in `strip` performance.
7373- # See #129467 and https://sourceware.org/bugzilla/show_bug.cgi?id=28058
7474- # Remove when we're on binutils > 2.36.1.
7575- # The patch is downloaded from
7676- # https://sourceware.org/git/?p=binutils-gdb.git;a=blobdiff_plain;f=bfd/elf.c;h=af62aadc3d446cd5b1f0201b207c90c22e7809b1;hp=36733e080dd9d9be28b576b246aaf5bd8c8569c7;hb=84fd26d8209e99fc3a432dd0b09b6c053de1ce65;hpb=abe2a28aaa7a2bfd0f3061c72a98eb898976b721
7777- # which is the 2.36 backport (using `TRUE` instead of `true` of binutils master commit:
7878- # https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=956ea65cd707707c0f725930214cbc781367a831
7979- ./bfd-elf-Dont-read-non-existing-secondary-relocs.patch
8080-8181- # Fix building plv8’s v8.
8282- # https://github.com/NixOS/nixpkgs/issues/134190
8383- # Obtained from: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=586e30940e640f67bd55bd72e1d1355a4faf8079
8484- ./gold-Update-GNU_PROPERTY_X86_XXX-macros.patch
8585-8686- ./CVE-2020-35448.patch
8787- ./CVE-2021-3487.patch
8888- ./CVE-2021-45078.patch
8989- ] ++ lib.optional stdenv.targetPlatform.isiOS ./support-ios.patch
9090- ++ # This patch was suggested by Nick Clifton to fix
9191- # https://sourceware.org/bugzilla/show_bug.cgi?id=16177
9292- # It can be removed when that 7-year-old bug is closed.
9393- # This binutils bug causes GHC to emit broken binaries on armv7, and
9494- # indeed GHC will refuse to compile with a binutils suffering from it. See
9595- # this comment for more information:
9696- # https://gitlab.haskell.org/ghc/ghc/issues/4210#note_78333
9797- lib.optional (stdenv.targetPlatform.isAarch32 && stdenv.hostPlatform.system != stdenv.targetPlatform.system) ./R_ARM_COPY.patch
9898- ++ lib.optional stdenv.targetPlatform.isWindows ./windres-locate-gcc.patch;
8484+ ]
8585+ ++ lib.optional targetPlatform.isiOS ./support-ios.patch
8686+ # This patch was suggested by Nick Clifton to fix
8787+ # https://sourceware.org/bugzilla/show_bug.cgi?id=16177
8888+ # It can be removed when that 7-year-old bug is closed.
8989+ # This binutils bug causes GHC to emit broken binaries on armv7, and indeed
9090+ # GHC will refuse to compile with a binutils suffering from it. See this
9191+ # comment for more information:
9292+ # https://gitlab.haskell.org/ghc/ghc/issues/4210#note_78333
9393+ ++ lib.optional (targetPlatform.isAarch32 && hostPlatform.system != targetPlatform.system) ./R_ARM_COPY.patch
9494+ ++ lib.optional targetPlatform.isWindows ./windres-locate-gcc.patch;
999510096 outputs = [ "out" "info" "man" ];
10197···104100 bison
105101 perl
106102 texinfo
107107- ] ++ (lib.optionals stdenv.targetPlatform.isiOS [
108108- autoreconfHook
109109- ]) ++ lib.optionals stdenv.targetPlatform.isVc4 [ flex ];
103103+ ]
104104+ ++ lib.optionals targetPlatform.isiOS [ autoreconfHook ]
105105+ ++ lib.optionals targetPlatform.isDarwin [ autoconf269 automake gettext libtool ]
106106+ ++ lib.optionals targetPlatform.isVc4 [ flex ]
107107+ ;
108108+110109 buildInputs = [ zlib gettext ];
111110112111 inherit noSysDirs;
113112114114- preConfigure = ''
113113+ preConfigure = (lib.optionalString targetPlatform.isDarwin ''
114114+ for i in */configure.ac; do
115115+ pushd "$(dirname "$i")"
116116+ echo "Running autoreconf in $PWD"
117117+ # autoreconf doesn't work, don't know why
118118+ # autoreconf ''${autoreconfFlags:---install --force --verbose}
119119+ autoconf
120120+ popd
121121+ done
122122+ '') + ''
115123 # Clear the default library search path.
116124 if test "$noSysDirs" = "1"; then
117125 echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt
···126134127135 # As binutils takes part in the stdenv building, we don't want references
128136 # to the bootstrap-tools libgcc (as uses to happen on arm/mips)
129129- NIX_CFLAGS_COMPILE = if stdenv.hostPlatform.isDarwin
137137+ NIX_CFLAGS_COMPILE =
138138+ if hostPlatform.isDarwin
130139 then "-Wno-string-plus-int -Wno-deprecated-declarations"
131140 else "-static-libgcc";
132141···134143135144 configurePlatforms = [ "build" "host" "target" ];
136145137137- configureFlags =
138138- (if enableShared then [ "--enable-shared" "--disable-static" ]
139139- else [ "--disable-shared" "--enable-static" ])
140140- ++ lib.optional withAllTargets "--enable-targets=all"
141141- ++ [
146146+ configureFlags = [
142147 "--enable-64-bit-bfd"
143148 "--with-system-zlib"
144149···151156 # RUNPATH can be overriden using LD_LIBRARY_PATH at runtime.
152157 "--enable-new-dtags"
153158154154- # force target prefix. Some versions of binutils will make it empty
155155- # if `--host` and `--target` are too close, even if Nixpkgs thinks
156156- # the platforms are different (e.g. because not all the info makes
157157- # the `config`). Other versions of binutils will always prefix if
158158- # `--target` is passed, even if `--host` and `--target` are the same.
159159- # The easiest thing for us to do is not leave it to chance, and force
160160- # the program prefix to be what we want it to be.
159159+ # force target prefix. Some versions of binutils will make it empty if
160160+ # `--host` and `--target` are too close, even if Nixpkgs thinks the
161161+ # platforms are different (e.g. because not all the info makes the
162162+ # `config`). Other versions of binutils will always prefix if `--target` is
163163+ # passed, even if `--host` and `--target` are the same. The easiest thing
164164+ # for us to do is not leave it to chance, and force the program prefix to be
165165+ # what we want it to be.
161166 "--program-prefix=${targetPrefix}"
162162- ] ++ lib.optionals gold [
163163- "--enable-gold"
164164- "--enable-plugins"
165165- ];
167167+ ]
168168+ ++ lib.optionals withAllTargets [ "--enable-targets=all" ]
169169+ ++ lib.optionals enableGold [ "--enable-gold" "--enable-plugins" ]
170170+ ++ (if enableShared
171171+ then [ "--enable-shared" "--disable-static" ]
172172+ else [ "--disable-shared" "--enable-static" ])
173173+ ;
166174167167- doCheck = false; # fails
175175+ # Fails
176176+ doCheck = false;
168177169169- postFixup = lib.optionalString reuseLibs ''
178178+ postFixup = lib.optionalString (enableShared && withAllTargets) ''
170179 rm "$out"/lib/lib{bfd,opcodes}-${version}.so
171180 ln -s '${lib.getLib libbfd}/lib/libbfd-${version}.so' "$out/lib/"
172181 ln -s '${lib.getLib libopcodes}/lib/libopcodes-${version}.so' "$out/lib/"
173182 '';
174183175175- # else fails with "./sanity.sh: line 36: $out/bin/size: not found"
176176- doInstallCheck = stdenv.buildPlatform == stdenv.hostPlatform && stdenv.hostPlatform == stdenv.targetPlatform;
184184+ # INFO: Otherwise it fails with:
185185+ # `./sanity.sh: line 36: $out/bin/size: not found`
186186+ doInstallCheck = (buildPlatform == hostPlatform) && (hostPlatform == targetPlatform);
177187178188 enableParallelBuilding = true;
179189180190 passthru = {
181191 inherit targetPrefix;
182182- hasGold = gold;
192192+ hasGold = enableGold;
183193 isGNU = true;
184194 };
185195···193203 '';
194204 homepage = "https://www.gnu.org/software/binutils/";
195205 license = licenses.gpl3Plus;
196196- maintainers = with maintainers; [ ericson2314 ];
206206+ maintainers = with maintainers; [ ericson2314 lovesegfault ];
197207 platforms = platforms.unix;
198208199199- /* Give binutils a lower priority than gcc-wrapper to prevent a
200200- collision due to the ld/as wrappers/symlinks in the latter. */
209209+ # INFO: Give binutils a lower priority than gcc-wrapper to prevent a
210210+ # collision due to the ld/as wrappers/symlinks in the latter.
201211 priority = 10;
202212 };
203213}