···4546 # A strange type of bug: dbus is not immediately found by pkg-config
47 preConfigure = ''
48- export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE $(pkg-config dbus-1 --cflags)"
00000000000049 '';
5051 # Parallel build fails due to missing dependencies between private libaries:
···4546 # A strange type of bug: dbus is not immediately found by pkg-config
47 preConfigure = ''
48+ # binutils 2.37 fix
49+ # https://github.com/afterstep/afterstep/issues/2
50+ fixupList=(
51+ "autoconf/Makefile.defines.in"
52+ "libAfterImage/aftershow/Makefile.in"
53+ "libAfterImage/apps/Makefile.in"
54+ "libAfterBase/Makefile.in"
55+ "libAfterImage/Makefile.in"
56+ )
57+ for toFix in "''${fixupList[@]}"; do
58+ substituteInPlace "$toFix" --replace "clq" "cq"
59+ done
60+ export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE $(pkg-config dbus-1 --cflags)"
61 '';
6263 # Parallel build fails due to missing dependencies between private libaries:
···1+From beca4a2c25ee86e4020f8b8bddc4d8e0ed3430b3 Mon Sep 17 00:00:00 2001
2+From: Andrew Childs <andrew.childs@bibo.com.ph>
3+Date: Tue, 22 Feb 2022 11:28:04 +0900
4+Subject: [PATCH] Revert "libtool.m4: fix nm BSD flag detection"
5+6+This reverts commit bef9ef8ca0f941d743c77cc55b5fe7985990b2a7.
7+---
8+ ChangeLog | 9 ------
9+ libtool.m4 | 88 ++++++++++++++++++++++++++----------------------------
10+ 2 files changed, 43 insertions(+), 54 deletions(-)
11+12+diff --git a/ChangeLog b/ChangeLog
13+index 18e8b6835da..c12f07403c3 100644
14+--- a/ChangeLog
15++++ b/ChangeLog
16+@@ -375,15 +375,6 @@
17+18+ * src-release.sh (GDB_SUPPPORT_DIRS): Add libbacktrace.
19+20+-2021-09-27 Nick Alcock <nick.alcock@oracle.com>
21+-
22+- PR libctf/27967
23+- * libtool.m4 (LT_PATH_NM): Try BSDization flags with a user-provided
24+- NM, if there is one. Run nm on itself, not on /dev/null, to avoid
25+- errors from nms that refuse to work on non-regular files. Remove
26+- other workarounds for this problem. Strip out blank lines from the
27+- nm output.
28+-
29+ 2021-09-27 Nick Alcock <nick.alcock@oracle.com>
30+31+ PR libctf/27967
32+diff --git a/libtool.m4 b/libtool.m4
33+index a216bb14e99..7a711249304 100644
34+--- a/libtool.m4
35++++ b/libtool.m4
36+@@ -3200,55 +3200,53 @@ _LT_DECL([], [file_magic_cmd], [1],
37+38+ # LT_PATH_NM
39+ # ----------
40+-# find the pathname to a BSD- or MS-compatible name lister, and any flags
41+-# needed to make it compatible
42++# find the pathname to a BSD- or MS-compatible name lister
43+ AC_DEFUN([LT_PATH_NM],
44+ [AC_REQUIRE([AC_PROG_CC])dnl
45+ AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
46+ [if test -n "$NM"; then
47+- # Let the user override the nm to test.
48+- lt_nm_to_check="$NM"
49+- else
50+- lt_nm_to_check="${ac_tool_prefix}nm"
51+- if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
52+- lt_nm_to_check="$lt_nm_to_check nm"
53+- fi
54+- fi
55+- for lt_tmp_nm in $lt_nm_to_check; do
56+- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
57+- for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
58+- IFS="$lt_save_ifs"
59+- test -z "$ac_dir" && ac_dir=.
60+- case "$lt_tmp_nm" in
61+- */*|*\\*) tmp_nm="$lt_tmp_nm";;
62+- *) tmp_nm="$ac_dir/$lt_tmp_nm";;
63+- esac
64+- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
65+- # Check to see if the nm accepts a BSD-compat flag.
66+- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
67+- # nm: unknown option "B" ignored
68+- case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
69+- *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
70+- break
71+- ;;
72+- *)
73+- case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
74+- *$tmp_nm*)
75+- lt_cv_path_NM="$tmp_nm -p"
76+- break
77+- ;;
78+- *)
79+- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
80+- continue # so that we can try to find one that supports BSD flags
81+- ;;
82+- esac
83+- ;;
84+- esac
85+- fi
86+- done
87+- IFS="$lt_save_ifs"
88+- done
89+- : ${lt_cv_path_NM=no}])
90++ # Let the user override the test.
91++ lt_cv_path_NM="$NM"
92++else
93++ lt_nm_to_check="${ac_tool_prefix}nm"
94++ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
95++ lt_nm_to_check="$lt_nm_to_check nm"
96++ fi
97++ for lt_tmp_nm in $lt_nm_to_check; do
98++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
99++ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
100++ IFS="$lt_save_ifs"
101++ test -z "$ac_dir" && ac_dir=.
102++ tmp_nm="$ac_dir/$lt_tmp_nm"
103++ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
104++ # Check to see if the nm accepts a BSD-compat flag.
105++ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
106++ # nm: unknown option "B" ignored
107++ # Tru64's nm complains that /dev/null is an invalid object file
108++ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
109++ */dev/null* | *'Invalid file or object type'*)
110++ lt_cv_path_NM="$tmp_nm -B"
111++ break
112++ ;;
113++ *)
114++ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
115++ */dev/null*)
116++ lt_cv_path_NM="$tmp_nm -p"
117++ break
118++ ;;
119++ *)
120++ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
121++ continue # so that we can try to find one that supports BSD flags
122++ ;;
123++ esac
124++ ;;
125++ esac
126++ fi
127++ done
128++ IFS="$lt_save_ifs"
129++ done
130++ : ${lt_cv_path_NM=no}
131++fi])
132+ if test "$lt_cv_path_NM" != "no"; then
133+ NM="$lt_cv_path_NM"
134+ else
135+--
136+2.34.1
137+
···1diff --git a/bfd/configure.ac b/bfd/configure.ac
2-index c5bfbd5d..45ad4c26 100644
3--- a/bfd/configure.ac
4+++ b/bfd/configure.ac
5-@@ -278,31 +278,19 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
67 LT_LIB_M
8···21- if test -n "$x"; then
22- SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty"
23- fi
024-
00025 case "${host}" in
26 # More hacks to build DLLs on Windows.
27 *-*-cygwin*)
28 SHARED_LDFLAGS="-no-undefined"
29-- SHARED_LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin -lkernel32"
30-+ SHARED_LIBADD="-liberty -lintl -lcygwin -lkernel32"
31- ;;
32-33- # Use built-in libintl on macOS, since it is not provided by libc.
34- *-*-darwin*)
35-- SHARED_LIBADD="-L`pwd`/../libiberty/pic -L`pwd`/../intl -liberty -lintl"
36-+ SHARED_LIBADD="-liberty -lintl"
37 ;;
38 esac
3940diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
41-index 4f06074a..6836c589 100644
42--- a/opcodes/Makefile.am
43+++ b/opcodes/Makefile.am
44@@ -51,7 +51,7 @@ libopcodes_la_LDFLAGS += -rpath $(rpath_bfdlibdir)
···5051 BUILD_LIBS = @BUILD_LIBS@
52 BUILD_LIB_DEPS = @BUILD_LIB_DEPS@
53-@@ -301,7 +301,7 @@ OFILES = @BFD_MACHINES@
54 # development.sh is used to determine -Werror default.
55 CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh
56···5960 disassemble.lo: disassemble.c
61 if am__fastdepCC
62-@@ -322,12 +322,21 @@ libopcodes_la_SOURCES = dis-buf.c disassemble.c dis-init.c
63- # old version of libbfd, or to pick up libbfd for the wrong architecture
64- # if host != build. So for building with shared libraries we use a
65- # hardcoded path to libbfd.so instead of relying on the entries in libbfd.la.
66-libopcodes_la_DEPENDENCIES = $(OFILES) @SHARED_DEPENDENCIES@
67+libopcodes_la_DEPENDENCIES = $(OFILES) @SHARED_DEPENDENCIES@ libtool-soversion
68 libopcodes_la_LIBADD = $(OFILES) @SHARED_LIBADD@
···84 # the build directory so that we don't have to convert all the
85 # programs that use libopcodes.a simultaneously. This is a hack which
86diff --git a/opcodes/configure.ac b/opcodes/configure.ac
87-index 00be9c88..6e589ae4 100644
88--- a/opcodes/configure.ac
89+++ b/opcodes/configure.ac
90-@@ -86,6 +86,7 @@ AC_PROG_INSTALL
009192- AC_CHECK_HEADERS(string.h strings.h stdlib.h limits.h)
93- ACX_HEADER_STRING
94+GCC_HEADER_STDINT(bfd_stdint.h)
95-96 AC_CHECK_DECLS([basename, stpcpy])
9798-@@ -137,61 +138,27 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
099100 LT_LIB_M
101···122-SHARED_LIBADD=
123+SHARED_LIBADD=-liberty
124 SHARED_DEPENDENCIES=
125- if test "$enable_shared" = "yes"; then
126-# When building a shared libopcodes, link against the pic version of libiberty
127-# so that apps that use libopcodes won't need libiberty just to satisfy any
128-# libopcodes references.
···131 # Note that linking against libbfd as we do here, which is itself linked
132 # against libiberty, may not satisfy all the libopcodes libiberty references
133 # since libbfd may not pull in the entirety of libiberty.
00134-changequote(,)dnl
135- x=`sed -n -e 's/^[ ]*PICFLAG[ ]*=[ ]*//p' < ../libiberty/Makefile | sed -n '$p'`
136-changequote([,])dnl
137- if test -n "$x"; then
138- SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty"
139- fi
140--
0000141 case "${host}" in
142 *-*-cygwin*)
143 SHARED_LDFLAGS="-no-undefined"
144-- SHARED_LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin"
145-+ SHARED_LIBADD="-lbfd -liberty -lintl -lcygwin"
146 ;;
147-- *-*-darwin*)
148-- SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.dylib ${SHARED_LIBADD}"
149-- SHARED_DEPENDENCIES="../bfd/libbfd.la"
150-- ;;
151 *)
152-- case "$host_vendor" in
153-- hp)
154-- SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.sl ${SHARED_LIBADD}"
155-- ;;
156-- *)
157-- SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.so ${SHARED_LIBADD}"
158-- ;;
159-- esac
160- SHARED_DEPENDENCIES="../bfd/libbfd.la"
161+ SHARED_LIBADD="-lbfd ${SHARED_LIBADD}"
162 ;;
···1diff --git a/bfd/configure.ac b/bfd/configure.ac
2+index fec067b2135..377e1f5443f 100644
3--- a/bfd/configure.ac
4+++ b/bfd/configure.ac
5+@@ -292,30 +292,16 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
67 LT_LIB_M
8···21- if test -n "$x"; then
22- SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty"
23- fi
24+-fi
25-
26+ SHARED_LIBADD="$SHARED_LIBADD $LIBINTL"
27+28+-if test "$enable_shared" = "yes"; then
29 case "${host}" in
30 # More hacks to build DLLs on Windows.
31 *-*-cygwin*)
32 SHARED_LDFLAGS="-no-undefined"
33+- SHARED_LIBADD="-L`pwd`/../libiberty -liberty $SHARED_LIBADD -lcygwin -lkernel32"
34++ SHARED_LIBADD="-liberty $SHARED_LIBADD -lcygwin -lkernel32"
00000035 ;;
36 esac
3738diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
39+index 0e04b4c05c4..848a02662e7 100644
40--- a/opcodes/Makefile.am
41+++ b/opcodes/Makefile.am
42@@ -51,7 +51,7 @@ libopcodes_la_LDFLAGS += -rpath $(rpath_bfdlibdir)
···4849 BUILD_LIBS = @BUILD_LIBS@
50 BUILD_LIB_DEPS = @BUILD_LIB_DEPS@
51+@@ -303,7 +303,7 @@ OFILES = @BFD_MACHINES@
52 # development.sh is used to determine -Werror default.
53 CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh
54···5758 disassemble.lo: disassemble.c
59 if am__fastdepCC
60+@@ -327,9 +327,18 @@ libopcodes_la_SOURCES = dis-buf.c disassemble.c dis-init.c
00061-libopcodes_la_DEPENDENCIES = $(OFILES) @SHARED_DEPENDENCIES@
62+libopcodes_la_DEPENDENCIES = $(OFILES) @SHARED_DEPENDENCIES@ libtool-soversion
63 libopcodes_la_LIBADD = $(OFILES) @SHARED_LIBADD@
···79 # the build directory so that we don't have to convert all the
80 # programs that use libopcodes.a simultaneously. This is a hack which
81diff --git a/opcodes/configure.ac b/opcodes/configure.ac
82+index e564f067334..5da62a3d58b 100644
83--- a/opcodes/configure.ac
84+++ b/opcodes/configure.ac
85+@@ -98,6 +98,8 @@ BFD_64_BIT
86+ AC_SUBST(HDEFINES)
87+ AC_PROG_INSTALL
880089+GCC_HEADER_STDINT(bfd_stdint.h)
90++
91 AC_CHECK_DECLS([basename, stpcpy])
9293+ # Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't do
94+@@ -148,44 +150,21 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
9596 LT_LIB_M
97···118-SHARED_LIBADD=
119+SHARED_LIBADD=-liberty
120 SHARED_DEPENDENCIES=
121+-if test "$enable_shared" = "yes"; then
122-# When building a shared libopcodes, link against the pic version of libiberty
123-# so that apps that use libopcodes won't need libiberty just to satisfy any
124-# libopcodes references.
···127 # Note that linking against libbfd as we do here, which is itself linked
128 # against libiberty, may not satisfy all the libopcodes libiberty references
129 # since libbfd may not pull in the entirety of libiberty.
130+ # Also, jam libintl into the right place in all of this: after libiberty,
131+ # which uses it, but before -lcygwin, which it uses.
132-changequote(,)dnl
133- x=`sed -n -e 's/^[ ]*PICFLAG[ ]*=[ ]*//p' < ../libiberty/Makefile | sed -n '$p'`
134-changequote([,])dnl
135- if test -n "$x"; then
136- SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty"
137- fi
138+-fi
139+140+ SHARED_LIBADD="$SHARED_LIBADD $LIBINTL"
141+142+@@ -193,11 +172,10 @@ if test "$enable_shared" = "yes"; then
143 case "${host}" in
144 *-*-cygwin*)
145 SHARED_LDFLAGS="-no-undefined"
146+- SHARED_LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty $SHARED_LIBADD"
147++ SHARED_LIBADD="-lbfd -liberty $SHARED_LIBADD"
148 ;;
0000149 *)
150+- SHARED_LIBADD="../bfd/libbfd.la ${SHARED_LIBADD}"
0000000151- SHARED_DEPENDENCIES="../bfd/libbfd.la"
152+ SHARED_LIBADD="-lbfd ${SHARED_LIBADD}"
153 ;;
+106-96
pkgs/development/tools/misc/binutils/default.nix
···2 execFormatIsELF = platform: platform.parsed.kernel.execFormat.name == "elf";
3in
45-{ stdenv, lib, buildPackages
6-, fetchFromGitHub, fetchurl, zlib, autoreconfHook, gettext
7-# Enabling all targets increases output size to a multiple.
8-, withAllTargets ? false, libbfd, libopcodes
9-, enableShared ? !stdenv.hostPlatform.isStatic
10-, noSysDirs
11-, gold ? execFormatIsELF stdenv.targetPlatform
12-, bison ? null
13, flex
000014, texinfo
15-, perl
0000016}:
1718-# configure silently disables ld.gold if it's unsupported,
19-# so we need to make sure that intent matches result ourselves.
20-assert gold -> execFormatIsELF stdenv.targetPlatform;
2122-# Note: this package is used for bootstrapping fetchurl, and thus
23-# cannot use fetchpatch! All mutable patches (generated by GitHub or
24-# cgit) that are needed here should be included directly in Nixpkgs as
25-# files.
2627let
28- reuseLibs = enableShared && withAllTargets;
002930- version = "2.35.2";
31- basename = "binutils";
32- # The targetPrefix prepended to binary names to allow multiple binuntils on the
33- # PATH to both be usable.
34- targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
35- "${stdenv.targetPlatform.config}-";
36- vc4-binutils-src = fetchFromGitHub {
37- owner = "itszor";
38- repo = "binutils-vc4";
39- rev = "708acc851880dbeda1dd18aca4fd0a95b2573b36";
40- sha256 = "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63";
41 };
42- # HACK to ensure that we preserve source from bootstrap binutils to not rebuild LLVM
43- normal-src = stdenv.__bootPackages.binutils-unwrapped.src or (fetchurl {
44- url = "mirror://gnu/binutils/${basename}-${version}.tar.bz2";
45- sha256 = "sha256-z6dkTb7PRZHhNutAfBwdoWV4vSsD8MLorNzroZS7nWE=";
46- });
47in
4849stdenv.mkDerivation {
50- pname = targetPrefix + basename;
51 inherit version;
5253- src = if stdenv.targetPlatform.isVc4 then vc4-binutils-src else normal-src;
0005400055 patches = [
56 # Make binutils output deterministic by default.
57 ./deterministic.patch
5859- # Help bfd choose between elf32-littlearm, elf32-littlearm-symbian, and
60- # elf32-littlearm-vxworks in favor of the first.
61- # https://github.com/NixOS/nixpkgs/pull/30484#issuecomment-345472766
62- ./disambiguate-arm-targets.patch
006364 # For some reason bfd ld doesn't search DT_RPATH when cross-compiling. It's
65 # not clear why this behavior was decided upon but it has the unfortunate
···68 # override this behavior, forcing ld to search DT_RPATH even when
69 # cross-compiling.
70 ./always-search-rpath.patch
71-72- # Fix quadratic slowdown in `strip` performance.
73- # See #129467 and https://sourceware.org/bugzilla/show_bug.cgi?id=28058
74- # Remove when we're on binutils > 2.36.1.
75- # The patch is downloaded from
76- # https://sourceware.org/git/?p=binutils-gdb.git;a=blobdiff_plain;f=bfd/elf.c;h=af62aadc3d446cd5b1f0201b207c90c22e7809b1;hp=36733e080dd9d9be28b576b246aaf5bd8c8569c7;hb=84fd26d8209e99fc3a432dd0b09b6c053de1ce65;hpb=abe2a28aaa7a2bfd0f3061c72a98eb898976b721
77- # which is the 2.36 backport (using `TRUE` instead of `true` of binutils master commit:
78- # https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=956ea65cd707707c0f725930214cbc781367a831
79- ./bfd-elf-Dont-read-non-existing-secondary-relocs.patch
80-81- # Fix building plv8’s v8.
82- # https://github.com/NixOS/nixpkgs/issues/134190
83- # Obtained from: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=586e30940e640f67bd55bd72e1d1355a4faf8079
84- ./gold-Update-GNU_PROPERTY_X86_XXX-macros.patch
85-86- ./CVE-2020-35448.patch
87- ./CVE-2021-3487.patch
88- ./CVE-2021-45078.patch
89- ] ++ lib.optional stdenv.targetPlatform.isiOS ./support-ios.patch
90- ++ # This patch was suggested by Nick Clifton to fix
91- # https://sourceware.org/bugzilla/show_bug.cgi?id=16177
92- # It can be removed when that 7-year-old bug is closed.
93- # This binutils bug causes GHC to emit broken binaries on armv7, and
94- # indeed GHC will refuse to compile with a binutils suffering from it. See
95- # this comment for more information:
96- # https://gitlab.haskell.org/ghc/ghc/issues/4210#note_78333
97- lib.optional (stdenv.targetPlatform.isAarch32 && stdenv.hostPlatform.system != stdenv.targetPlatform.system) ./R_ARM_COPY.patch
98- ++ lib.optional stdenv.targetPlatform.isWindows ./windres-locate-gcc.patch;
99100 outputs = [ "out" "info" "man" ];
101···104 bison
105 perl
106 texinfo
107- ] ++ (lib.optionals stdenv.targetPlatform.isiOS [
108- autoreconfHook
109- ]) ++ lib.optionals stdenv.targetPlatform.isVc4 [ flex ];
000110 buildInputs = [ zlib gettext ];
111112 inherit noSysDirs;
113114- preConfigure = ''
000000000115 # Clear the default library search path.
116 if test "$noSysDirs" = "1"; then
117 echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt
···126127 # As binutils takes part in the stdenv building, we don't want references
128 # to the bootstrap-tools libgcc (as uses to happen on arm/mips)
129- NIX_CFLAGS_COMPILE = if stdenv.hostPlatform.isDarwin
0130 then "-Wno-string-plus-int -Wno-deprecated-declarations"
131 else "-static-libgcc";
132···134135 configurePlatforms = [ "build" "host" "target" ];
136137- configureFlags =
138- (if enableShared then [ "--enable-shared" "--disable-static" ]
139- else [ "--disable-shared" "--enable-static" ])
140- ++ lib.optional withAllTargets "--enable-targets=all"
141- ++ [
142 "--enable-64-bit-bfd"
143 "--with-system-zlib"
144···151 # RUNPATH can be overriden using LD_LIBRARY_PATH at runtime.
152 "--enable-new-dtags"
153154- # force target prefix. Some versions of binutils will make it empty
155- # if `--host` and `--target` are too close, even if Nixpkgs thinks
156- # the platforms are different (e.g. because not all the info makes
157- # the `config`). Other versions of binutils will always prefix if
158- # `--target` is passed, even if `--host` and `--target` are the same.
159- # The easiest thing for us to do is not leave it to chance, and force
160- # the program prefix to be what we want it to be.
161 "--program-prefix=${targetPrefix}"
162- ] ++ lib.optionals gold [
163- "--enable-gold"
164- "--enable-plugins"
165- ];
000166167- doCheck = false; # fails
0168169- postFixup = lib.optionalString reuseLibs ''
170 rm "$out"/lib/lib{bfd,opcodes}-${version}.so
171 ln -s '${lib.getLib libbfd}/lib/libbfd-${version}.so' "$out/lib/"
172 ln -s '${lib.getLib libopcodes}/lib/libopcodes-${version}.so' "$out/lib/"
173 '';
174175- # else fails with "./sanity.sh: line 36: $out/bin/size: not found"
176- doInstallCheck = stdenv.buildPlatform == stdenv.hostPlatform && stdenv.hostPlatform == stdenv.targetPlatform;
0177178 enableParallelBuilding = true;
179180 passthru = {
181 inherit targetPrefix;
182- hasGold = gold;
183 isGNU = true;
184 };
185···193 '';
194 homepage = "https://www.gnu.org/software/binutils/";
195 license = licenses.gpl3Plus;
196- maintainers = with maintainers; [ ericson2314 ];
197 platforms = platforms.unix;
198199- /* Give binutils a lower priority than gcc-wrapper to prevent a
200- collision due to the ld/as wrappers/symlinks in the latter. */
201 priority = 10;
202 };
203}
···2 execFormatIsELF = platform: platform.parsed.kernel.execFormat.name == "elf";
3in
45+{ stdenv
6+, autoreconfHook
7+, autoconf269, automake, libtool
8+, bison
9+, buildPackages
10+, fetchFromGitHub
11+, fetchurl
012, flex
13+, gettext
14+, lib
15+, noSysDirs
16+, perl
17, texinfo
18+, zlib
19+20+, enableGold ? execFormatIsELF stdenv.targetPlatform
21+, enableShared ? !stdenv.hostPlatform.isStatic
22+ # WARN: Enabling all targets increases output size to a multiple.
23+, withAllTargets ? false, libbfd, libopcodes
24}:
2526+# WARN: configure silently disables ld.gold if it's unsupported, so we need to
27+# make sure that intent matches result ourselves.
28+assert enableGold -> execFormatIsELF stdenv.targetPlatform;
2900003031let
32+ inherit (stdenv) buildPlatform hostPlatform targetPlatform;
33+34+ version = "2.38";
3536+ srcs = {
37+ normal = fetchurl {
38+ url = "mirror://gnu/binutils/binutils-${version}.tar.bz2";
39+ sha256 = "sha256-Bw7HHPB3pqWOC5WfBaCaNQFTeMLYpR6Q866r/jBZDvg=";
40+ };
41+ vc4-none = fetchFromGitHub {
42+ owner = "itszor";
43+ repo = "binutils-vc4";
44+ rev = "708acc851880dbeda1dd18aca4fd0a95b2573b36";
45+ sha256 = "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63";
46+ };
47 };
48+49+ #INFO: The targetPrefix prepended to binary names to allow multiple binuntils
50+ # on the PATH to both be usable.
51+ targetPrefix = lib.optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
052in
5354stdenv.mkDerivation {
55+ pname = targetPrefix + "binutils";
56 inherit version;
5758+ # HACK: Ensure that we preserve source from bootstrap binutils to not rebuild LLVM
59+ src = stdenv.__bootPackages.binutils-unwrapped.src
60+ or srcs.${targetPlatform.system}
61+ or srcs.normal;
6263+ # WARN: this package is used for bootstrapping fetchurl, and thus cannot use
64+ # fetchpatch! All mutable patches (generated by GitHub or cgit) that are
65+ # needed here should be included directly in Nixpkgs as files.
66 patches = [
67 # Make binutils output deterministic by default.
68 ./deterministic.patch
6970+71+ # Breaks nm BSD flag detection
72+ ./0001-Revert-libtool.m4-fix-nm-BSD-flag-detection.patch
73+74+ # Required for newer macos versions
75+ ./0001-libtool.m4-update-macos-version-detection-block.patch
7677 # For some reason bfd ld doesn't search DT_RPATH when cross-compiling. It's
78 # not clear why this behavior was decided upon but it has the unfortunate
···81 # override this behavior, forcing ld to search DT_RPATH even when
82 # cross-compiling.
83 ./always-search-rpath.patch
84+ ]
85+ ++ lib.optional targetPlatform.isiOS ./support-ios.patch
86+ # This patch was suggested by Nick Clifton to fix
87+ # https://sourceware.org/bugzilla/show_bug.cgi?id=16177
88+ # It can be removed when that 7-year-old bug is closed.
89+ # This binutils bug causes GHC to emit broken binaries on armv7, and indeed
90+ # GHC will refuse to compile with a binutils suffering from it. See this
91+ # comment for more information:
92+ # https://gitlab.haskell.org/ghc/ghc/issues/4210#note_78333
93+ ++ lib.optional (targetPlatform.isAarch32 && hostPlatform.system != targetPlatform.system) ./R_ARM_COPY.patch
94+ ++ lib.optional targetPlatform.isWindows ./windres-locate-gcc.patch;
000000000000000009596 outputs = [ "out" "info" "man" ];
97···100 bison
101 perl
102 texinfo
103+ ]
104+ ++ lib.optionals targetPlatform.isiOS [ autoreconfHook ]
105+ ++ lib.optionals targetPlatform.isDarwin [ autoconf269 automake gettext libtool ]
106+ ++ lib.optionals targetPlatform.isVc4 [ flex ]
107+ ;
108+109 buildInputs = [ zlib gettext ];
110111 inherit noSysDirs;
112113+ preConfigure = (lib.optionalString targetPlatform.isDarwin ''
114+ for i in */configure.ac; do
115+ pushd "$(dirname "$i")"
116+ echo "Running autoreconf in $PWD"
117+ # autoreconf doesn't work, don't know why
118+ # autoreconf ''${autoreconfFlags:---install --force --verbose}
119+ autoconf
120+ popd
121+ done
122+ '') + ''
123 # Clear the default library search path.
124 if test "$noSysDirs" = "1"; then
125 echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt
···134135 # As binutils takes part in the stdenv building, we don't want references
136 # to the bootstrap-tools libgcc (as uses to happen on arm/mips)
137+ NIX_CFLAGS_COMPILE =
138+ if hostPlatform.isDarwin
139 then "-Wno-string-plus-int -Wno-deprecated-declarations"
140 else "-static-libgcc";
141···143144 configurePlatforms = [ "build" "host" "target" ];
145146+ configureFlags = [
0000147 "--enable-64-bit-bfd"
148 "--with-system-zlib"
149···156 # RUNPATH can be overriden using LD_LIBRARY_PATH at runtime.
157 "--enable-new-dtags"
158159+ # force target prefix. Some versions of binutils will make it empty if
160+ # `--host` and `--target` are too close, even if Nixpkgs thinks the
161+ # platforms are different (e.g. because not all the info makes the
162+ # `config`). Other versions of binutils will always prefix if `--target` is
163+ # passed, even if `--host` and `--target` are the same. The easiest thing
164+ # for us to do is not leave it to chance, and force the program prefix to be
165+ # what we want it to be.
166 "--program-prefix=${targetPrefix}"
167+ ]
168+ ++ lib.optionals withAllTargets [ "--enable-targets=all" ]
169+ ++ lib.optionals enableGold [ "--enable-gold" "--enable-plugins" ]
170+ ++ (if enableShared
171+ then [ "--enable-shared" "--disable-static" ]
172+ else [ "--disable-shared" "--enable-static" ])
173+ ;
174175+ # Fails
176+ doCheck = false;
177178+ postFixup = lib.optionalString (enableShared && withAllTargets) ''
179 rm "$out"/lib/lib{bfd,opcodes}-${version}.so
180 ln -s '${lib.getLib libbfd}/lib/libbfd-${version}.so' "$out/lib/"
181 ln -s '${lib.getLib libopcodes}/lib/libopcodes-${version}.so' "$out/lib/"
182 '';
183184+ # INFO: Otherwise it fails with:
185+ # `./sanity.sh: line 36: $out/bin/size: not found`
186+ doInstallCheck = (buildPlatform == hostPlatform) && (hostPlatform == targetPlatform);
187188 enableParallelBuilding = true;
189190 passthru = {
191 inherit targetPrefix;
192+ hasGold = enableGold;
193 isGNU = true;
194 };
195···203 '';
204 homepage = "https://www.gnu.org/software/binutils/";
205 license = licenses.gpl3Plus;
206+ maintainers = with maintainers; [ ericson2314 lovesegfault ];
207 platforms = platforms.unix;
208209+ # INFO: Give binutils a lower priority than gcc-wrapper to prevent a
210+ # collision due to the ld/as wrappers/symlinks in the latter.
211 priority = 10;
212 };
213}