diff options
author | Sergei Trofimovich <slyich@gmail.com> | 2022-08-24 07:16:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 07:16:39 +0100 |
commit | 8329438e9d03fa06abcc9ce18232579561a6907c (patch) | |
tree | 71ca30ed82cb5037f4f2fdcc938ffc5a5dc18502 /pkgs/development/tools/misc | |
parent | 83874827314ff1093518b2ab71d052a6adeefb6b (diff) | |
parent | 7fe41f922e9f987def3d9a248289acc03b18d2d2 (diff) |
Merge pull request #187972 from trofi/binutils-2.38-holdback
Create binutils 2.38 holdback set of releases
Diffstat (limited to 'pkgs/development/tools/misc')
16 files changed, 1196 insertions, 0 deletions
diff --git a/pkgs/development/tools/misc/binutils/2.38/0001-Revert-libtool.m4-fix-nm-BSD-flag-detection.patch b/pkgs/development/tools/misc/binutils/2.38/0001-Revert-libtool.m4-fix-nm-BSD-flag-detection.patch new file mode 100644 index 0000000000000..f9c6e88d97b45 --- /dev/null +++ b/pkgs/development/tools/misc/binutils/2.38/0001-Revert-libtool.m4-fix-nm-BSD-flag-detection.patch @@ -0,0 +1,137 @@ +From beca4a2c25ee86e4020f8b8bddc4d8e0ed3430b3 Mon Sep 17 00:00:00 2001 +From: Andrew Childs <andrew.childs@bibo.com.ph> +Date: Tue, 22 Feb 2022 11:28:04 +0900 +Subject: [PATCH] Revert "libtool.m4: fix nm BSD flag detection" + +This reverts commit bef9ef8ca0f941d743c77cc55b5fe7985990b2a7. +--- + ChangeLog | 9 ------ + libtool.m4 | 88 ++++++++++++++++++++++++++---------------------------- + 2 files changed, 43 insertions(+), 54 deletions(-) + +diff --git a/ChangeLog b/ChangeLog +index 18e8b6835da..c12f07403c3 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -375,15 +375,6 @@ + + * src-release.sh (GDB_SUPPPORT_DIRS): Add libbacktrace. + +-2021-09-27 Nick Alcock <nick.alcock@oracle.com> +- +- PR libctf/27967 +- * libtool.m4 (LT_PATH_NM): Try BSDization flags with a user-provided +- NM, if there is one. Run nm on itself, not on /dev/null, to avoid +- errors from nms that refuse to work on non-regular files. Remove +- other workarounds for this problem. Strip out blank lines from the +- nm output. +- + 2021-09-27 Nick Alcock <nick.alcock@oracle.com> + + PR libctf/27967 +diff --git a/libtool.m4 b/libtool.m4 +index a216bb14e99..7a711249304 100644 +--- a/libtool.m4 ++++ b/libtool.m4 +@@ -3200,55 +3200,53 @@ _LT_DECL([], [file_magic_cmd], [1], + + # LT_PATH_NM + # ---------- +-# find the pathname to a BSD- or MS-compatible name lister, and any flags +-# needed to make it compatible ++# find the pathname to a BSD- or MS-compatible name lister + AC_DEFUN([LT_PATH_NM], + [AC_REQUIRE([AC_PROG_CC])dnl + AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, + [if test -n "$NM"; then +- # Let the user override the nm to test. +- lt_nm_to_check="$NM" +- else +- lt_nm_to_check="${ac_tool_prefix}nm" +- if test -n "$ac_tool_prefix" && test "$build" = "$host"; then +- lt_nm_to_check="$lt_nm_to_check nm" +- fi +- fi +- for lt_tmp_nm in $lt_nm_to_check; do +- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR +- for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do +- IFS="$lt_save_ifs" +- test -z "$ac_dir" && ac_dir=. +- case "$lt_tmp_nm" in +- */*|*\\*) tmp_nm="$lt_tmp_nm";; +- *) tmp_nm="$ac_dir/$lt_tmp_nm";; +- esac +- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then +- # Check to see if the nm accepts a BSD-compat flag. +- # Adding the `sed 1q' prevents false positives on HP-UX, which says: +- # nm: unknown option "B" ignored +- case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in +- *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B" +- break +- ;; +- *) +- case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in +- *$tmp_nm*) +- lt_cv_path_NM="$tmp_nm -p" +- break +- ;; +- *) +- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but +- continue # so that we can try to find one that supports BSD flags +- ;; +- esac +- ;; +- esac +- fi +- done +- IFS="$lt_save_ifs" +- done +- : ${lt_cv_path_NM=no}]) ++ # Let the user override the test. ++ lt_cv_path_NM="$NM" ++else ++ lt_nm_to_check="${ac_tool_prefix}nm" ++ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then ++ lt_nm_to_check="$lt_nm_to_check nm" ++ fi ++ for lt_tmp_nm in $lt_nm_to_check; do ++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ++ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do ++ IFS="$lt_save_ifs" ++ test -z "$ac_dir" && ac_dir=. ++ tmp_nm="$ac_dir/$lt_tmp_nm" ++ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then ++ # Check to see if the nm accepts a BSD-compat flag. ++ # Adding the `sed 1q' prevents false positives on HP-UX, which says: ++ # nm: unknown option "B" ignored ++ # Tru64's nm complains that /dev/null is an invalid object file ++ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in ++ */dev/null* | *'Invalid file or object type'*) ++ lt_cv_path_NM="$tmp_nm -B" ++ break ++ ;; ++ *) ++ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in ++ */dev/null*) ++ lt_cv_path_NM="$tmp_nm -p" ++ break ++ ;; ++ *) ++ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but ++ continue # so that we can try to find one that supports BSD flags ++ ;; ++ esac ++ ;; ++ esac ++ fi ++ done ++ IFS="$lt_save_ifs" ++ done ++ : ${lt_cv_path_NM=no} ++fi]) + if test "$lt_cv_path_NM" != "no"; then + NM="$lt_cv_path_NM" + else +-- +2.34.1 + diff --git a/pkgs/development/tools/misc/binutils/2.38/0001-libtool.m4-update-macos-version-detection-block.patch b/pkgs/development/tools/misc/binutils/2.38/0001-libtool.m4-update-macos-version-detection-block.patch new file mode 100644 index 0000000000000..e601be3a33082 --- /dev/null +++ b/pkgs/development/tools/misc/binutils/2.38/0001-libtool.m4-update-macos-version-detection-block.patch @@ -0,0 +1,47 @@ +From 33a8dc728eb5da3e1d3439c96810d1f6b2660b89 Mon Sep 17 00:00:00 2001 +From: Andrew Childs <andrew.childs@bibo.com.ph> +Date: Tue, 22 Feb 2022 12:24:46 +0900 +Subject: [PATCH] libtool.m4: update macos version detection block + +Includes upstream change +9e8c882517082fe5755f2524d23efb02f1522490 +--- + libtool.m4 | 21 ++++++++------------- + 1 file changed, 8 insertions(+), 13 deletions(-) + +diff --git a/libtool.m4 b/libtool.m4 +index 7a711249304..f452efb4300 100644 +--- a/libtool.m4 ++++ b/libtool.m4 +@@ -996,20 +996,15 @@ _LT_EOF + ]) + case $host_os in + rhapsody* | darwin1.[[012]]) +- _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; ++ _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; + darwin1.*) +- _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; +- darwin*) # darwin 5.x on +- # if running on 10.5 or later, the deployment target defaults +- # to the OS version, if on x86, and 10.4, the deployment +- # target defaults to 10.4. Don't you love it? +- case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in +- 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) +- _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; +- 10.[[012]][[,.]]*) +- _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; +- 10.*) +- _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; ++ _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; ++ darwin*) ++ case $MACOSX_DEPLOYMENT_TARGET,$host in ++ 10.[[012]],*|,*powerpc*-darwin[[5-8]]*) ++ _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; ++ *) ++ _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac +-- +2.34.1 + diff --git a/pkgs/development/tools/misc/binutils/2.38/R_ARM_COPY.patch b/pkgs/development/tools/misc/binutils/2.38/R_ARM_COPY.patch new file mode 100644 index 0000000000000..874809863523d --- /dev/null +++ b/pkgs/development/tools/misc/binutils/2.38/R_ARM_COPY.patch @@ -0,0 +1,29 @@ +@@ -, +, @@ +--- + bfd/elf32-arm.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) +--- a/bfd/elf32-arm.c ++++ a/bfd/elf32-arm.c +@@ -15398,7 +15398,11 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info, + linker to copy the initial value out of the dynamic object and into + the runtime process image. We need to remember the offset into the + .rel(a).bss section we are going to use. */ +- if ((h->root.u.def.section->flags & SEC_READONLY) != 0) ++ if (info->nocopyreloc == 0 ++ && (h->root.u.def.section->flags & SEC_ALLOC) != 0 ++ /* PR 16177: A copy is only needed if the input section is readonly. */ ++ && (h->root.u.def.section->flags & SEC_READONLY) != 0 ++ && h->size != 0) + { + s = globals->root.sdynrelro; + srel = globals->root.sreldynrelro; +@@ -15410,6 +15414,8 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info, + } + if (info->nocopyreloc == 0 + && (h->root.u.def.section->flags & SEC_ALLOC) != 0 ++ /* PR 16177: A copy is only needed if the input section is readonly. */ ++ && (h->root.u.def.section->flags & SEC_READONLY) != 0 + && h->size != 0) + { + elf32_arm_allocate_dynrelocs (info, srel, 1); + diff --git a/pkgs/development/tools/misc/binutils/2.38/always-search-rpath.patch b/pkgs/development/tools/misc/binutils/2.38/always-search-rpath.patch new file mode 100644 index 0000000000000..2e9956e6b6e45 --- /dev/null +++ b/pkgs/development/tools/misc/binutils/2.38/always-search-rpath.patch @@ -0,0 +1,14 @@ +diff --git a/ld/genscripts.sh b/ld/genscripts.sh +index b6940d376d..0feb1adfd0 100755 +--- a/ld/genscripts.sh ++++ b/ld/genscripts.sh +@@ -125,6 +125,9 @@ if test "x$NATIVE" = "xyes" ; then + USE_LIBPATH=yes + fi + ++# TODO: why is this needed? ++USE_LIBPATH=yes ++ + # Set the library search path, for libraries named by -lfoo. + # If LIB_PATH is defined (e.g., by Makefile) and non-empty, it is used. + # Otherwise, the default is set here. diff --git a/pkgs/development/tools/misc/binutils/2.38/build-components-separately.patch b/pkgs/development/tools/misc/binutils/2.38/build-components-separately.patch new file mode 100644 index 0000000000000..0b4162d848803 --- /dev/null +++ b/pkgs/development/tools/misc/binutils/2.38/build-components-separately.patch @@ -0,0 +1,155 @@ +diff --git a/bfd/configure.ac b/bfd/configure.ac +index fec067b2135..377e1f5443f 100644 +--- a/bfd/configure.ac ++++ b/bfd/configure.ac +@@ -292,30 +292,16 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed, + + LT_LIB_M + +-# When building a shared libbfd, link against the pic version of libiberty +-# so that apps that use libbfd won't need libiberty just to satisfy any +-# libbfd references. +-# We can't do that if a pic libiberty is unavailable since including non-pic +-# code would insert text relocations into libbfd. + SHARED_LIBADD= +-SHARED_LDFLAGS= ++SHARED_LDFLAGS=-liberty + if test "$enable_shared" = "yes"; then +-changequote(,)dnl +- x=`sed -n -e 's/^[ ]*PICFLAG[ ]*=[ ]*//p' < ../libiberty/Makefile | sed -n '$p'` +-changequote([,])dnl +- if test -n "$x"; then +- SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty" +- fi +-fi +- + SHARED_LIBADD="$SHARED_LIBADD $LIBINTL" + +-if test "$enable_shared" = "yes"; then + case "${host}" in + # More hacks to build DLLs on Windows. + *-*-cygwin*) + SHARED_LDFLAGS="-no-undefined" +- SHARED_LIBADD="-L`pwd`/../libiberty -liberty $SHARED_LIBADD -lcygwin -lkernel32" ++ SHARED_LIBADD="-liberty $SHARED_LIBADD -lcygwin -lkernel32" + ;; + esac + +diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am +index 0e04b4c05c4..848a02662e7 100644 +--- a/opcodes/Makefile.am ++++ b/opcodes/Makefile.am +@@ -51,7 +51,7 @@ libopcodes_la_LDFLAGS += -rpath $(rpath_bfdlibdir) + endif + + # This is where bfd.h lives. +-BFD_H = ../bfd/bfd.h ++BFD_H = $(BFDDIR)/bfd.h + + BUILD_LIBS = @BUILD_LIBS@ + BUILD_LIB_DEPS = @BUILD_LIB_DEPS@ +@@ -303,7 +303,7 @@ OFILES = @BFD_MACHINES@ + # development.sh is used to determine -Werror default. + CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh + +-AM_CPPFLAGS = -I. -I$(srcdir) -I../bfd -I$(INCDIR) -I$(BFDDIR) @HDEFINES@ @INCINTL@ ++AM_CPPFLAGS = -I. -I$(srcdir) -I$(INCDIR) -I$(BFDDIR) @HDEFINES@ @INCINTL@ + + disassemble.lo: disassemble.c + if am__fastdepCC +@@ -327,9 +327,18 @@ libopcodes_la_SOURCES = dis-buf.c disassemble.c dis-init.c +-libopcodes_la_DEPENDENCIES = $(OFILES) @SHARED_DEPENDENCIES@ ++libopcodes_la_DEPENDENCIES = $(OFILES) @SHARED_DEPENDENCIES@ libtool-soversion + libopcodes_la_LIBADD = $(OFILES) @SHARED_LIBADD@ +-libopcodes_la_LDFLAGS += -release `cat ../bfd/libtool-soversion` @SHARED_LDFLAGS@ ++libopcodes_la_LDFLAGS += -release `cat libtool-soversion` @SHARED_LDFLAGS@ + # Allow dependency tracking to work on all the source files. + EXTRA_libopcodes_la_SOURCES = $(LIBOPCODES_CFILES) + ++libtool-soversion: ++ @echo "creating $@" ++ bfd_soversion="$(VERSION)" ;\ ++ . $(BFDDIR)/development.sh ;\ ++ if test "$$development" = true ; then \ ++ bfd_soversion="$(VERSION).$${bfd_version_date}" ;\ ++ fi ;\ ++ echo "$${bfd_soversion}" > $@ ++ + # libtool will build .libs/libopcodes.a. We create libopcodes.a in + # the build directory so that we don't have to convert all the + # programs that use libopcodes.a simultaneously. This is a hack which +diff --git a/opcodes/configure.ac b/opcodes/configure.ac +index e564f067334..5da62a3d58b 100644 +--- a/opcodes/configure.ac ++++ b/opcodes/configure.ac +@@ -98,6 +98,8 @@ BFD_64_BIT + AC_SUBST(HDEFINES) + AC_PROG_INSTALL + ++GCC_HEADER_STDINT(bfd_stdint.h) ++ + AC_CHECK_DECLS([basename, stpcpy]) + + # Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't do +@@ -148,44 +150,21 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed, + + LT_LIB_M + +-#Libs for generator progs +-if test "x$cross_compiling" = "xno"; then +- BUILD_LIBS=../libiberty/libiberty.a +- BUILD_LIB_DEPS=$BUILD_LIBS +-else +- # if cross-compiling, assume that the system provides -liberty +- # and that the version is compatible with new headers. +- BUILD_LIBS=-liberty +- BUILD_LIB_DEPS= +-fi +-BUILD_LIBS="$BUILD_LIBS $LIBINTL" +-BUILD_LIB_DEPS="$BUILD_LIB_DEPS $LIBINTL_DEP" ++BUILD_LIBS="-liberty $LIBINTL" ++BUILD_LIB_DEPS="$LIBINTL_DEP" + + AC_SUBST(BUILD_LIBS) + AC_SUBST(BUILD_LIB_DEPS) + + # Horrible hacks to build DLLs on Windows and a shared library elsewhere. + SHARED_LDFLAGS= +-SHARED_LIBADD= ++SHARED_LIBADD=-liberty + SHARED_DEPENDENCIES= +-if test "$enable_shared" = "yes"; then +-# When building a shared libopcodes, link against the pic version of libiberty +-# so that apps that use libopcodes won't need libiberty just to satisfy any +-# libopcodes references. +-# We can't do that if a pic libiberty is unavailable since including non-pic +-# code would insert text relocations into libopcodes. + # Note that linking against libbfd as we do here, which is itself linked + # against libiberty, may not satisfy all the libopcodes libiberty references + # since libbfd may not pull in the entirety of libiberty. + # Also, jam libintl into the right place in all of this: after libiberty, + # which uses it, but before -lcygwin, which it uses. +-changequote(,)dnl +- x=`sed -n -e 's/^[ ]*PICFLAG[ ]*=[ ]*//p' < ../libiberty/Makefile | sed -n '$p'` +-changequote([,])dnl +- if test -n "$x"; then +- SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty" +- fi +-fi + + SHARED_LIBADD="$SHARED_LIBADD $LIBINTL" + +@@ -193,11 +172,10 @@ if test "$enable_shared" = "yes"; then + case "${host}" in + *-*-cygwin*) + SHARED_LDFLAGS="-no-undefined" +- SHARED_LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty $SHARED_LIBADD" ++ SHARED_LIBADD="-lbfd -liberty $SHARED_LIBADD" + ;; + *) +- SHARED_LIBADD="../bfd/libbfd.la ${SHARED_LIBADD}" +- SHARED_DEPENDENCIES="../bfd/libbfd.la" ++ SHARED_LIBADD="-lbfd ${SHARED_LIBADD}" + ;; + esac + diff --git a/pkgs/development/tools/misc/binutils/2.38/default.nix b/pkgs/development/tools/misc/binutils/2.38/default.nix new file mode 100644 index 0000000000000..3ea42ee422999 --- /dev/null +++ b/pkgs/development/tools/misc/binutils/2.38/default.nix @@ -0,0 +1,240 @@ +let + execFormatIsELF = platform: platform.parsed.kernel.execFormat.name == "elf"; +in + +{ stdenv +, autoreconfHook +, autoconf269, automake, libtool +, bison +, buildPackages +, fetchFromGitHub +, fetchurl +, flex +, gettext +, lib +, noSysDirs +, perl +, substitute +, texinfo +, zlib + +, enableGold ? execFormatIsELF stdenv.targetPlatform +, enableShared ? !stdenv.hostPlatform.isStatic + # WARN: Enabling all targets increases output size to a multiple. +, withAllTargets ? false +}: + +# WARN: configure silently disables ld.gold if it's unsupported, so we need to +# make sure that intent matches result ourselves. +assert enableGold -> execFormatIsELF stdenv.targetPlatform; + + +let + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + version = "2.38"; + + srcs = { + normal = fetchurl { + url = "mirror://gnu/binutils/binutils-${version}.tar.bz2"; + sha256 = "sha256-Bw7HHPB3pqWOC5WfBaCaNQFTeMLYpR6Q866r/jBZDvg="; + }; + vc4-none = fetchFromGitHub { + owner = "itszor"; + repo = "binutils-vc4"; + rev = "708acc851880dbeda1dd18aca4fd0a95b2573b36"; + sha256 = "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63"; + }; + }; + + #INFO: The targetPrefix prepended to binary names to allow multiple binuntils + # on the PATH to both be usable. + targetPrefix = lib.optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-"; +in + +stdenv.mkDerivation { + pname = targetPrefix + "binutils"; + inherit version; + + # HACK: Ensure that we preserve source from bootstrap binutils to not rebuild LLVM + src = stdenv.__bootPackages.binutils-unwrapped_2_38.src + or srcs.${targetPlatform.system} + or srcs.normal; + + # WARN: this package is used for bootstrapping fetchurl, and thus cannot use + # fetchpatch! All mutable patches (generated by GitHub or cgit) that are + # needed here should be included directly in Nixpkgs as files. + patches = [ + # Make binutils output deterministic by default. + ./deterministic.patch + + + # Breaks nm BSD flag detection + ./0001-Revert-libtool.m4-fix-nm-BSD-flag-detection.patch + + # Required for newer macos versions + ./0001-libtool.m4-update-macos-version-detection-block.patch + + # 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 + + # Fixed in 2.39 + # https://sourceware.org/bugzilla/show_bug.cgi?id=28885 + # https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=99852365513266afdd793289813e8e565186c9e6 + # https://github.com/NixOS/nixpkgs/issues/170946 + ./deterministic-temp-prefixes.patch + ] + ++ lib.optional targetPlatform.isiOS ./support-ios.patch + # This patch was suggested by Nick Clifton to fix + # https://sourceware.org/bugzilla/show_bug.cgi?id=16177 + # It can be removed when that 7-year-old bug is closed. + # This binutils bug causes GHC to emit broken binaries on armv7, and indeed + # GHC will refuse to compile with a binutils suffering from it. See this + # comment for more information: + # https://gitlab.haskell.org/ghc/ghc/issues/4210#note_78333 + ++ lib.optional (targetPlatform.isAarch32 && hostPlatform.system != targetPlatform.system) ./R_ARM_COPY.patch + ++ lib.optional stdenv.targetPlatform.isWindows ./windres-locate-gcc.patch + ++ lib.optional stdenv.targetPlatform.isMips64n64 + # this patch is from debian: + # https://sources.debian.org/data/main/b/binutils/2.38-3/debian/patches/mips64-default-n64.diff + (if stdenv.targetPlatform.isMusl + then substitute { src = ./mips64-default-n64.patch; replacements = [ "--replace" "gnuabi64" "muslabi64" ]; } + else ./mips64-default-n64.patch) + # On PowerPC, when generating assembly code, GCC generates a `.machine` + # custom instruction which instructs the assembler to generate code for this + # machine. However, some GCC versions generate the wrong one, or make it + # too strict, which leads to some confusing "unrecognized opcode: wrtee" + # or "unrecognized opcode: eieio" errors. + # + # To remove when binutils 2.39 is released. + # + # Upstream commit: + # https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=cebc89b9328eab994f6b0314c263f94e7949a553 + ++ lib.optional stdenv.targetPlatform.isPower ./ppc-make-machine-less-strict.patch + ; + + outputs = [ "out" "info" "man" ]; + + strictDeps = true; + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ + bison + perl + texinfo + ] + ++ lib.optionals targetPlatform.isiOS [ autoreconfHook ] + ++ lib.optionals buildPlatform.isDarwin [ autoconf269 automake gettext libtool ] + ++ lib.optionals targetPlatform.isVc4 [ flex ] + ; + + buildInputs = [ zlib gettext ]; + + inherit noSysDirs; + + preConfigure = (lib.optionalString buildPlatform.isDarwin '' + for i in */configure.ac; do + pushd "$(dirname "$i")" + echo "Running autoreconf in $PWD" + # autoreconf doesn't work, don't know why + # autoreconf ''${autoreconfFlags:---install --force --verbose} + autoconf + popd + done + '') + '' + # Clear the default library search path. + if test "$noSysDirs" = "1"; then + echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt + fi + + # Use symlinks instead of hard links to save space ("strip" in the + # fixup phase strips each hard link separately). + for i in binutils/Makefile.in gas/Makefile.in ld/Makefile.in gold/Makefile.in; do + sed -i "$i" -e 's|ln |ln -s |' + done + ''; + + # 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) + NIX_CFLAGS_COMPILE = + if hostPlatform.isDarwin + then "-Wno-string-plus-int -Wno-deprecated-declarations" + else "-static-libgcc"; + + hardeningDisable = [ "format" "pie" ]; + + configurePlatforms = [ "build" "host" "target" ]; + + configureFlags = [ + "--enable-64-bit-bfd" + "--with-system-zlib" + + "--enable-deterministic-archives" + "--disable-werror" + "--enable-fix-loongson2f-nop" + + # 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. + "--enable-new-dtags" + + # force target prefix. Some versions of binutils will make it empty if + # `--host` and `--target` are too close, even if Nixpkgs thinks the + # platforms are different (e.g. because not all the info makes the + # `config`). Other versions of binutils will always prefix if `--target` is + # passed, even if `--host` and `--target` are the same. The easiest thing + # for us to do is not leave it to chance, and force the program prefix to be + # what we want it to be. + "--program-prefix=${targetPrefix}" + ] + ++ lib.optionals withAllTargets [ "--enable-targets=all" ] + ++ lib.optionals enableGold [ "--enable-gold" "--enable-plugins" ] + ++ (if enableShared + then [ "--enable-shared" "--disable-static" ] + else [ "--disable-shared" "--enable-static" ]) + ; + + # Fails + doCheck = false; + + # Remove on next bump. It's a vestige of past conditional. Stays here to avoid + # mass rebuild. + postFixup = ""; + + # Break dependency on pkgsBuildBuild.gcc when building a cross-binutils + stripDebugList = if stdenv.hostPlatform != stdenv.targetPlatform then "bin lib ${stdenv.hostPlatform.config}" else null; + + # INFO: Otherwise it fails with: + # `./sanity.sh: line 36: $out/bin/size: not found` + doInstallCheck = (buildPlatform == hostPlatform) && (hostPlatform == targetPlatform); + + enableParallelBuilding = true; + + passthru = { + inherit targetPrefix; + hasGold = enableGold; + isGNU = true; + }; + + meta = with lib; { + description = "Tools for manipulating binaries (linker, assembler, etc.)"; + 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. + ''; + homepage = "https://www.gnu.org/software/binutils/"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ ericson2314 lovesegfault ]; + platforms = platforms.unix; + + # INFO: Give binutils a lower priority than gcc-wrapper to prevent a + # collision due to the ld/as wrappers/symlinks in the latter. + priority = 10; + }; +} diff --git a/pkgs/development/tools/misc/binutils/2.38/deterministic-temp-prefixes.patch b/pkgs/development/tools/misc/binutils/2.38/deterministic-temp-prefixes.patch new file mode 100644 index 0000000000000..3c27340b9c042 --- /dev/null +++ b/pkgs/development/tools/misc/binutils/2.38/deterministic-temp-prefixes.patch @@ -0,0 +1,36 @@ +From 99852365513266afdd793289813e8e565186c9e6 Mon Sep 17 00:00:00 2001 +From: Nick Clifton <nickc@redhat.com> +Date: Wed, 23 Mar 2022 11:39:49 +0000 +Subject: [PATCH] dlltool: Use the output name as basis for deterministic temp + prefixes + + PR 28885 + * dlltool.c (main): use imp_name rather than dll_name when + generating a temporary file name. +--- + binutils/ChangeLog | 9 +++++++++ + binutils/dlltool.c | 7 ++++--- + 2 files changed, 13 insertions(+), 3 deletions(-) + +diff --git a/binutils/dlltool.c b/binutils/dlltool.c +index d95bf3f5470..89871510b45 100644 +--- a/binutils/dlltool.c ++++ b/binutils/dlltool.c +@@ -3992,10 +3992,11 @@ main (int ac, char **av) + if (tmp_prefix == NULL) + { + /* If possible use a deterministic prefix. */ +- if (dll_name) ++ if (imp_name || delayimp_name) + { +- tmp_prefix = xmalloc (strlen (dll_name) + 2); +- sprintf (tmp_prefix, "%s_", dll_name); ++ const char *input = imp_name ? imp_name : delayimp_name; ++ tmp_prefix = xmalloc (strlen (input) + 2); ++ sprintf (tmp_prefix, "%s_", input); + for (i = 0; tmp_prefix[i]; i++) + if (!ISALNUM (tmp_prefix[i])) + tmp_prefix[i] = '_'; +-- +2.31.1 + diff --git a/pkgs/development/tools/misc/binutils/2.38/deterministic.patch b/pkgs/development/tools/misc/binutils/2.38/deterministic.patch new file mode 100644 index 0000000000000..736e0aca6ce1f --- /dev/null +++ b/pkgs/development/tools/misc/binutils/2.38/deterministic.patch @@ -0,0 +1,12 @@ +diff -ur orig/binutils-2.23.1/ld/ldlang.c binutils-2.23.1/ld/ldlang.c +--- orig/ld/ldlang.c ++++ new/ld/ldlang.c +@@ -3095,6 +3095,8 @@ + ldfile_output_machine)) + einfo (_("%P%F:%s: can not set architecture: %E\n"), name); + ++ link_info.output_bfd->flags |= BFD_DETERMINISTIC_OUTPUT; ++ + link_info.hash = bfd_link_hash_table_create (link_info.output_bfd); + if (link_info.hash == NULL) + einfo (_("%P%F: can not create hash table: %E\n")); diff --git a/pkgs/development/tools/misc/binutils/2.38/libbfd.nix b/pkgs/development/tools/misc/binutils/2.38/libbfd.nix new file mode 100644 index 0000000000000..feac15b512f9f --- /dev/null +++ b/pkgs/development/tools/misc/binutils/2.38/libbfd.nix @@ -0,0 +1,59 @@ +{ lib, stdenv +, fetchpatch, gnu-config, autoreconfHook, bison, binutils-unwrapped_2_38 +, libiberty, libintl, zlib +}: + +stdenv.mkDerivation { + pname = "libbfd"; + inherit (binutils-unwrapped_2_38) version src; + + outputs = [ "out" "dev" ]; + + patches = binutils-unwrapped_2_38.patches ++ [ + ./build-components-separately.patch + (fetchpatch { + url = "https://raw.githubusercontent.com/mxe/mxe/e1d4c144ee1994f70f86cf7fd8168fe69bd629c6/src/bfd-1-disable-subdir-doc.patch"; + sha256 = "0pzb3i74d1r7lhjan376h59a7kirw15j7swwm8pz3zy9lkdqkj6q"; + }) + ]; + + # We just want to build libbfd + postPatch = '' + cd bfd + ''; + + postAutoreconf = '' + echo "Updating config.guess and config.sub from ${gnu-config}" + cp -f ${gnu-config}/config.{guess,sub} ../ + ''; + + # We update these ourselves + dontUpdateAutotoolsGnuConfigScripts = true; + + strictDeps = true; + nativeBuildInputs = [ autoreconfHook bison ]; + buildInputs = [ libiberty zlib ] ++ lib.optionals stdenv.isDarwin [ libintl ]; + + configurePlatforms = [ "build" "host" ]; + configureFlags = [ + "--enable-targets=all" "--enable-64-bit-bfd" + "--enable-install-libbfd" + "--with-system-zlib" + ] ++ lib.optional (!stdenv.hostPlatform.isStatic) "--enable-shared"; + + enableParallelBuilding = true; + + meta = with lib; { + description = "A library for manipulating containers of machine code"; + longDescription = '' + BFD is a library which provides a single interface to read and write + object files, executables, archive files, and core files in any format. + It is associated with GNU Binutils, and elsewhere often distributed with + it. + ''; + homepage = "https://www.gnu.org/software/binutils/"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ ericson2314 ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/development/tools/misc/binutils/2.38/libopcodes.nix b/pkgs/development/tools/misc/binutils/2.38/libopcodes.nix new file mode 100644 index 0000000000000..16b3695626d76 --- /dev/null +++ b/pkgs/development/tools/misc/binutils/2.38/libopcodes.nix @@ -0,0 +1,44 @@ +{ lib, stdenv, buildPackages +, autoreconfHook, bison, binutils-unwrapped_2_38 +, libiberty, libbfd_2_38 +}: + +stdenv.mkDerivation { + pname = "libopcodes"; + inherit (binutils-unwrapped_2_38) version src; + + outputs = [ "out" "dev" ]; + + patches = binutils-unwrapped_2_38.patches ++ [ + ./build-components-separately.patch + ]; + + # We just want to build libopcodes + postPatch = '' + cd opcodes + find . ../include/opcode -type f -exec sed {} -i -e 's/"bfd.h"/<bfd.h>/' \; + ''; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ autoreconfHook bison ]; + buildInputs = [ libiberty ]; + # dis-asm.h includes bfd.h + propagatedBuildInputs = [ libbfd_2_38 ]; + + configurePlatforms = [ "build" "host" ]; + configureFlags = [ + "--enable-targets=all" "--enable-64-bit-bfd" + "--enable-install-libbfd" + "--enable-shared" + ]; + + enableParallelBuilding = true; + + meta = with lib; { + description = "A library from binutils for manipulating machine code"; + homepage = "https://www.gnu.org/software/binutils/"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ ericson2314 ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/development/tools/misc/binutils/2.38/mips64-default-n64.patch b/pkgs/development/tools/misc/binutils/2.38/mips64-default-n64.patch new file mode 100644 index 0000000000000..00581279f85e5 --- /dev/null +++ b/pkgs/development/tools/misc/binutils/2.38/mips64-default-n64.patch @@ -0,0 +1,82 @@ +--- a/bfd/config.bfd ++++ b/bfd/config.bfd +@@ -927,11 +927,21 @@ case "${targ}" in + targ_defvec=mips_elf32_be_vec + targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec mips_ecoff_be_vec mips_ecoff_le_vec" + ;; +- mips64*el-*-linux*) ++ mips*64*el-*-linux*-gnuabi64) ++ targ_defvec=mips_elf64_trad_le_vec ++ targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_be_vec" ++ want64=true ++ ;; ++ mips*64*-*-linux*-gnuabi64) ++ targ_defvec=mips_elf64_trad_be_vec ++ targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_le_vec" ++ want64=true ++ ;; ++ mips*64*el-*-linux*) + targ_defvec=mips_elf32_ntrad_le_vec + targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_le_vec mips_elf64_trad_be_vec" + ;; +- mips64*-*-linux*) ++ mips*64*-*-linux*) + targ_defvec=mips_elf32_ntrad_be_vec + targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec" + ;; +--- a/binutils/testsuite/binutils-all/mips/mips-note-2-n32.d ++++ b/binutils/testsuite/binutils-all/mips/mips-note-2-n32.d +@@ -1,4 +1,5 @@ + #PROG: objcopy ++#as: -n32 + #readelf: --notes --wide + #objcopy: --merge-notes + #name: MIPS merge notes section (n32) +--- a/gas/configure ++++ b/gas/configure +@@ -12167,6 +12167,9 @@ _ACEOF + esac + # Decide which ABI to target by default. + case ${target} in ++ mips*64*-linux-gnuabi64) ++ mips_default_abi=N64_ABI ++ ;; + mips64*-linux* | mips-sgi-irix6* | mips64*-freebsd* \ + | mips64*-kfreebsd*-gnu | mips64*-ps2-elf*) + mips_default_abi=N32_ABI +--- a/gas/configure.ac ++++ b/gas/configure.ac +@@ -384,6 +384,9 @@ changequote([,])dnl + esac + # Decide which ABI to target by default. + case ${target} in ++ mips*64*-linux-gnuabi64) ++ mips_default_abi=N64_ABI ++ ;; + mips64*-linux* | mips-sgi-irix6* | mips64*-freebsd* \ + | mips64*-kfreebsd*-gnu | mips64*-ps2-elf*) + mips_default_abi=N32_ABI +--- a/ld/configure.tgt ++++ b/ld/configure.tgt +@@ -543,11 +543,19 @@ mips*-*-vxworks*) targ_emul=elf32ebmipvx + ;; + mips*-*-windiss) targ_emul=elf32mipswindiss + ;; +-mips64*el-*-linux-*) targ_emul=elf32ltsmipn32 ++mips*64*el-*-linux-gnuabi64) targ_emul=elf64ltsmip ++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32ltsmip elf32btsmip elf64btsmip" ++ targ_extra_libpath=$targ_extra_emuls ++ ;; ++mips*64*el-*-linux-*) targ_emul=elf32ltsmipn32 + targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip" + targ_extra_libpath=$targ_extra_emuls + ;; +-mips64*-*-linux-*) targ_emul=elf32btsmipn32 ++mips*64*-*-linux-gnuabi64) targ_emul=elf64btsmip ++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32btsmip elf32ltsmip elf64ltsmip" ++ targ_extra_libpath=$targ_extra_emuls ++ ;; ++mips*64*-*-linux-*) targ_emul=elf32btsmipn32 + targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip" + targ_extra_libpath=$targ_extra_emuls + ;; diff --git a/pkgs/development/tools/misc/binutils/2.38/ppc-make-machine-less-strict.patch b/pkgs/development/tools/misc/binutils/2.38/ppc-make-machine-less-strict.patch new file mode 100644 index 0000000000000..c2452414fc7d5 --- /dev/null +++ b/pkgs/development/tools/misc/binutils/2.38/ppc-make-machine-less-strict.patch @@ -0,0 +1,51 @@ +From cebc89b9328eab994f6b0314c263f94e7949a553 Mon Sep 17 00:00:00 2001 +From: Alan Modra <amodra@gmail.com> +Date: Mon, 21 Feb 2022 10:58:57 +1030 +Subject: [PATCH] binutils 2.38 vs. ppc32 linux kernel + +Commit b25f942e18d6 made .machine more strict. Weaken it again. + + * config/tc-ppc.c (ppc_machine): Treat an early .machine specially, + keeping sticky options to work around gcc bugs. +--- + gas/config/tc-ppc.c | 25 ++++++++++++++++++++++++- + 1 file changed, 24 insertions(+), 1 deletion(-) + +diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c +index 054f9c72161..89bc7d3f9b9 100644 +--- a/gas/config/tc-ppc.c ++++ b/gas/config/tc-ppc.c +@@ -5965,7 +5965,30 @@ ppc_machine (int ignore ATTRIBUTE_UNUSED) + options do not count as a new machine, instead they add + to currently selected opcodes. */ + ppc_cpu_t machine_sticky = 0; +- new_cpu = ppc_parse_cpu (ppc_cpu, &machine_sticky, cpu_string); ++ /* Unfortunately, some versions of gcc emit a .machine ++ directive very near the start of the compiler's assembly ++ output file. This is bad because it overrides user -Wa ++ cpu selection. Worse, there are versions of gcc that ++ emit the *wrong* cpu, not even respecting the -mcpu given ++ to gcc. See gcc pr101393. And to compound the problem, ++ as of 20220222 gcc doesn't pass the correct cpu option to ++ gas on the command line. See gcc pr59828. Hack around ++ this by keeping sticky options for an early .machine. */ ++ asection *sec; ++ for (sec = stdoutput->sections; sec != NULL; sec = sec->next) ++ { ++ segment_info_type *info = seg_info (sec); ++ /* Are the frags for this section perturbed from their ++ initial state? Even .align will count here. */ ++ if (info != NULL ++ && (info->frchainP->frch_root != info->frchainP->frch_last ++ || info->frchainP->frch_root->fr_type != rs_fill ++ || info->frchainP->frch_root->fr_fix != 0)) ++ break; ++ } ++ new_cpu = ppc_parse_cpu (ppc_cpu, ++ sec == NULL ? &sticky : &machine_sticky, ++ cpu_string); + if (new_cpu != 0) + ppc_cpu = new_cpu; + else +-- +2.31.1 diff --git a/pkgs/development/tools/misc/binutils/2.38/support-ios.patch b/pkgs/development/tools/misc/binutils/2.38/support-ios.patch new file mode 100644 index 0000000000000..74e56d130ed51 --- /dev/null +++ b/pkgs/development/tools/misc/binutils/2.38/support-ios.patch @@ -0,0 +1,168 @@ +diff --git a/bfd/config.bfd b/bfd/config.bfd +index f04a993f06..1e24a9d030 100644 +--- a/bfd/config.bfd ++++ b/bfd/config.bfd +@@ -238,7 +238,7 @@ case "${targ}" in + + # START OF targmatch.h + #ifdef BFD64 +- aarch64-*-darwin*) ++ aarch64-*-darwin* | aarch64-*-ios*) + targ_defvec=aarch64_mach_o_vec + targ_selvecs="arm_mach_o_vec mach_o_le_vec mach_o_be_vec mach_o_fat_vec" + targ_archs="$targ_archs bfd_i386_arch bfd_powerpc_arch bfd_rs6000_arch" +@@ -358,7 +358,7 @@ case "${targ}" in + targ_selvecs=arc_elf32_be_vec + ;; + +- arm-*-darwin*) ++ arm-*-darwin* | arm-*-ios*) + targ_defvec=arm_mach_o_vec + targ_selvecs="mach_o_le_vec mach_o_be_vec mach_o_fat_vec" + targ_archs="$targ_archs bfd_i386_arch bfd_powerpc_arch bfd_rs6000_arch" +@@ -678,7 +678,7 @@ case "${targ}" in + i[3-7]86-*-aix*) + targ_defvec=i386_coff_vec + ;; +- i[3-7]86-*-darwin* | i[3-7]86-*-macos10* | i[3-7]86-*-rhapsody*) ++ i[3-7]86-*-darwin* | i[3-7]86-*-ios* | i[3-7]86-*-macos10* | i[3-7]86-*-rhapsody*) + targ_defvec=i386_mach_o_vec + targ_selvecs="mach_o_le_vec mach_o_be_vec mach_o_fat_vec pef_vec pef_xlib_vec sym_vec" + targ64_selvecs=x86_64_mach_o_vec +@@ -762,7 +762,7 @@ case "${targ}" in + targ_defvec=x86_64_elf64_cloudabi_vec + want64=true + ;; +- x86_64-*-darwin*) ++ x86_64-*-darwin* | x86_64-*-ios*) + targ_defvec=x86_64_mach_o_vec + targ_selvecs="i386_mach_o_vec mach_o_le_vec mach_o_be_vec mach_o_fat_vec pef_vec pef_xlib_vec sym_vec" + targ_archs="$targ_archs bfd_powerpc_arch bfd_rs6000_arch" +@@ -1402,7 +1402,7 @@ case "${targ}" in + targ_selvecs="powerpc_elf32_le_vec powerpc_boot_vec" + targ64_selvecs="powerpc_elf64_vec powerpc_elf64_le_vec" + ;; +- powerpc-*-darwin* | powerpc-*-macos10* | powerpc-*-rhapsody*) ++ powerpc-*-darwin* | powerpc-*-ios* | powerpc-*-macos10* | powerpc-*-rhapsody*) + targ_defvec=mach_o_be_vec + targ_selvecs="mach_o_be_vec mach_o_le_vec mach_o_fat_vec pef_vec pef_xlib_vec sym_vec" + targ_archs="$targ_archs bfd_i386_arch" +diff --git a/configure.ac b/configure.ac +index aae94501e4..2cceb4dad4 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -510,7 +510,7 @@ if test x$enable_libgomp = x ; then + ;; + *-*-solaris2* | *-*-hpux11*) + ;; +- *-*-darwin* | *-*-aix*) ++ *-*-darwin* | *-*-ios* | *-*-aix*) + ;; + nvptx*-*-*) + ;; +@@ -700,13 +700,13 @@ esac + + # Disable libffi for some systems. + case "${target}" in +- powerpc-*-darwin*) ++ powerpc-*-darwin* | powerpc-*-ios*) + ;; +- i[[3456789]]86-*-darwin*) ++ i[[3456789]]86-*-darwin* | i[[3456789]]86-*-ios*) + ;; +- x86_64-*-darwin[[912]]*) ++ x86_64-*-darwin[[912]]* | x86_64-*-ios[[912]]*) + ;; +- *-*-darwin*) ++ *-*-darwin* | *-*-ios*) + noconfigdirs="$noconfigdirs target-libffi" + ;; + *-*-netware*) +@@ -788,7 +788,7 @@ esac + # Disable the go frontend on systems where it is known to not work. Please keep + # this in sync with contrib/config-list.mk. + case "${target}" in +-*-*-darwin* | *-*-cygwin* | *-*-mingw*) ++*-*-darwin* | *-*-ios* | *-*-cygwin* | *-*-mingw*) + unsupported_languages="$unsupported_languages go" + ;; + esac +@@ -797,7 +797,7 @@ esac + # For testing, you can easily override this with --enable-libgo. + if test x$enable_libgo = x; then + case "${target}" in +- *-*-darwin*) ++ *-*-darwin* | *-*-ios*) + # PR 46986 + noconfigdirs="$noconfigdirs target-libgo" + ;; +@@ -916,27 +916,27 @@ esac + case "${target}" in + *-*-chorusos) + ;; +- aarch64-*-darwin*) ++ aarch64-*-darwin* | aarch64-*-ios*) + noconfigdirs="$noconfigdirs ld gas gdb gprof" + noconfigdirs="$noconfigdirs sim target-rda" + ;; +- arm-*-darwin*) ++ arm-*-darwin* | arm-*-ios*) + noconfigdirs="$noconfigdirs ld gas gdb gprof" + noconfigdirs="$noconfigdirs sim target-rda" + ;; +- powerpc-*-darwin*) ++ powerpc-*-darwin* | powerpc-*-ios*) + noconfigdirs="$noconfigdirs ld gas gdb gprof" + noconfigdirs="$noconfigdirs sim target-rda" + ;; +- i[[3456789]]86-*-darwin*) ++ i[[3456789]]86-*-darwin* | i[[3456789]]86-*-ios*) + noconfigdirs="$noconfigdirs ld gprof" + noconfigdirs="$noconfigdirs sim target-rda" + ;; +- x86_64-*-darwin[[912]]*) ++ x86_64-*-darwin[[912]]* | x86_64-*-ios[[912]]*) + noconfigdirs="$noconfigdirs ld gas gprof" + noconfigdirs="$noconfigdirs sim target-rda" + ;; +- *-*-darwin*) ++ *-*-darwin* | *-*-ios*) + noconfigdirs="$noconfigdirs ld gas gdb gprof" + noconfigdirs="$noconfigdirs sim target-rda" + ;; +@@ -1226,7 +1226,7 @@ case "${host}" in + hppa*-*) + host_makefile_frag="config/mh-pa" + ;; +- *-*-darwin*) ++ *-*-darwin* | *-*-ios*) + host_makefile_frag="config/mh-darwin" + ;; + powerpc-*-aix*) +@@ -1697,7 +1697,7 @@ ACX_ELF_TARGET_IFELSE([# ELF platforms build the lto-plugin always. + build_lto_plugin=yes + ],[if test x"$default_enable_lto" = x"yes" ; then + case $target in +- *-apple-darwin[[912]]* | *-cygwin* | *-mingw* | *djgpp*) ;; ++ *-apple-darwin[[912]]* | *-apple-ios[[912]]* | *-cygwin* | *-mingw* | *djgpp*) ;; + # On other non-ELF platforms, LTO has yet to be validated. + *) enable_lto=no ;; + esac +@@ -1708,7 +1708,7 @@ ACX_ELF_TARGET_IFELSE([# ELF platforms build the lto-plugin always. + # warn during gcc/ subconfigure; unless you're bootstrapping with + # -flto it won't be needed until after installation anyway. + case $target in +- *-cygwin* | *-mingw* | *-apple-darwin* | *djgpp*) ;; ++ *-cygwin* | *-mingw* | *-apple-darwin* | *-apple-ios* | *djgpp*) ;; + *) if test x"$enable_lto" = x"yes"; then + AC_MSG_ERROR([LTO support is not enabled for this target.]) + fi +@@ -2590,7 +2590,7 @@ rm -f conftest* + # Decide which environment variable is used to find dynamic libraries. + case "${host}" in + *-*-hpux*) RPATH_ENVVAR=SHLIB_PATH ;; +- *-*-darwin*) RPATH_ENVVAR=DYLD_LIBRARY_PATH ;; ++ *-*-darwin* | *-*-ios* ) RPATH_ENVVAR=DYLD_LIBRARY_PATH ;; + *-*-mingw* | *-*-cygwin ) RPATH_ENVVAR=PATH ;; + *) RPATH_ENVVAR=LD_LIBRARY_PATH ;; + esac diff --git a/pkgs/development/tools/misc/binutils/2.38/windres-locate-gcc.patch b/pkgs/development/tools/misc/binutils/2.38/windres-locate-gcc.patch new file mode 100644 index 0000000000000..721667c62cecc --- /dev/null +++ b/pkgs/development/tools/misc/binutils/2.38/windres-locate-gcc.patch @@ -0,0 +1,19 @@ +diff --git a/binutils/resrc.c b/binutils/resrc.c +index a875c3a4..0411d047 100644 +--- a/binutils/resrc.c ++++ b/binutils/resrc.c +@@ -521,7 +521,13 @@ read_rc_file (const char *filename, const char *preprocessor, + + cpp_pipe = 0; + +- if (dash) ++ /* Nixpkgs specific : look first at the prefixed path ++ ( there should be no gcc in the binutils folder ) */ ++ if (slash && dash) { ++ cpp_pipe = look_for_default(cmd, slash + 1, dash - slash, preprocargs, filename); ++ } ++ ++ if (dash && ! cpp_pipe) + { + /* First, try looking for a prefixed gcc in the windres + directory, with the same prefix as windres */ diff --git a/pkgs/development/tools/misc/binutils/libbfd.nix b/pkgs/development/tools/misc/binutils/libbfd.nix new file mode 100644 index 0000000000000..eed23a746d2a8 --- /dev/null +++ b/pkgs/development/tools/misc/binutils/libbfd.nix @@ -0,0 +1,59 @@ +{ lib, stdenv +, fetchpatch, gnu-config, autoreconfHook, bison, binutils-unwrapped +, libiberty, libintl, zlib +}: + +stdenv.mkDerivation { + pname = "libbfd"; + inherit (binutils-unwrapped) version src; + + outputs = [ "out" "dev" ]; + + patches = binutils-unwrapped.patches ++ [ + ./build-components-separately.patch + (fetchpatch { + url = "https://raw.githubusercontent.com/mxe/mxe/e1d4c144ee1994f70f86cf7fd8168fe69bd629c6/src/bfd-1-disable-subdir-doc.patch"; + sha256 = "0pzb3i74d1r7lhjan376h59a7kirw15j7swwm8pz3zy9lkdqkj6q"; + }) + ]; + + # We just want to build libbfd + postPatch = '' + cd bfd + ''; + + postAutoreconf = '' + echo "Updating config.guess and config.sub from ${gnu-config}" + cp -f ${gnu-config}/config.{guess,sub} ../ + ''; + + # We update these ourselves + dontUpdateAutotoolsGnuConfigScripts = true; + + strictDeps = true; + nativeBuildInputs = [ autoreconfHook bison ]; + buildInputs = [ libiberty zlib ] ++ lib.optionals stdenv.isDarwin [ libintl ]; + + configurePlatforms = [ "build" "host" ]; + configureFlags = [ + "--enable-targets=all" "--enable-64-bit-bfd" + "--enable-install-libbfd" + "--with-system-zlib" + ] ++ lib.optional (!stdenv.hostPlatform.isStatic) "--enable-shared"; + + enableParallelBuilding = true; + + meta = with lib; { + description = "A library for manipulating containers of machine code"; + longDescription = '' + BFD is a library which provides a single interface to read and write + object files, executables, archive files, and core files in any format. + It is associated with GNU Binutils, and elsewhere often distributed with + it. + ''; + homepage = "https://www.gnu.org/software/binutils/"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ ericson2314 ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/development/tools/misc/binutils/libopcodes.nix b/pkgs/development/tools/misc/binutils/libopcodes.nix new file mode 100644 index 0000000000000..e4b6cec41b4f0 --- /dev/null +++ b/pkgs/development/tools/misc/binutils/libopcodes.nix @@ -0,0 +1,44 @@ +{ lib, stdenv, buildPackages +, autoreconfHook, bison, binutils-unwrapped +, libiberty, libbfd +}: + +stdenv.mkDerivation { + pname = "libopcodes"; + inherit (binutils-unwrapped) version src; + + outputs = [ "out" "dev" ]; + + patches = binutils-unwrapped.patches ++ [ + ./build-components-separately.patch + ]; + + # We just want to build libopcodes + postPatch = '' + cd opcodes + find . ../include/opcode -type f -exec sed {} -i -e 's/"bfd.h"/<bfd.h>/' \; + ''; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ autoreconfHook bison ]; + buildInputs = [ libiberty ]; + # dis-asm.h includes bfd.h + propagatedBuildInputs = [ libbfd ]; + + configurePlatforms = [ "build" "host" ]; + configureFlags = [ + "--enable-targets=all" "--enable-64-bit-bfd" + "--enable-install-libbfd" + "--enable-shared" + ]; + + enableParallelBuilding = true; + + meta = with lib; { + description = "A library from binutils for manipulating machine code"; + homepage = "https://www.gnu.org/software/binutils/"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ ericson2314 ]; + platforms = platforms.unix; + }; +} |