From fef040afae46c0471820ecfd0b3657b52096f167 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Mon, 5 Sep 2022 19:16:31 +0100 Subject: [PATCH] binutils: restore `nm` autodetection on darwin The change restores the patch `nixpkgs` kept for `binutils-2.38`. On top of that we revert the second `binutils-2.39`-specific commit that attempted to fix it. We can drop both reverts once https://sourceware.org/PR29547 is fixed. --- ...libtool.m4-fix-nm-BSD-flag-detection.patch | 137 ++++++++++++++++++ ...4-fix-the-NM-nm-over-here-B-option-w.patch | 42 ++++++ .../tools/misc/binutils/default.nix | 6 + 3 files changed, 185 insertions(+) create mode 100644 pkgs/development/tools/misc/binutils/0001-Revert-libtool.m4-fix-nm-BSD-flag-detection.patch create mode 100644 pkgs/development/tools/misc/binutils/0001-Revert-libtool.m4-fix-the-NM-nm-over-here-B-option-w.patch diff --git a/pkgs/development/tools/misc/binutils/0001-Revert-libtool.m4-fix-nm-BSD-flag-detection.patch b/pkgs/development/tools/misc/binutils/0001-Revert-libtool.m4-fix-nm-BSD-flag-detection.patch new file mode 100644 index 000000000000..f9c6e88d97b4 --- /dev/null +++ b/pkgs/development/tools/misc/binutils/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 +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 +- +- 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 + + 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/0001-Revert-libtool.m4-fix-the-NM-nm-over-here-B-option-w.patch b/pkgs/development/tools/misc/binutils/0001-Revert-libtool.m4-fix-the-NM-nm-over-here-B-option-w.patch new file mode 100644 index 000000000000..b5083d81d71c --- /dev/null +++ b/pkgs/development/tools/misc/binutils/0001-Revert-libtool.m4-fix-the-NM-nm-over-here-B-option-w.patch @@ -0,0 +1,42 @@ +This reverts upstream commit caf606c90d55305967b9253447dda93d2f1835ab +until https://sourceware.org/PR29547 is fixed. + +--- a/libtool.m4 ++++ b/libtool.m4 +@@ -3214,31 +3214,25 @@ AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, + lt_nm_to_check="$lt_nm_to_check nm" + fi + fi +- for lt_tmp_nm in "$lt_nm_to_check"; do ++ 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=. +- # Strip out any user-provided options from the nm to test twice, +- # the first time to test to see if nm (rather than its options) has +- # an explicit path, the second time to yield a file which can be +- # nm'ed itself. +- tmp_nm_path="`$ECHO "$lt_tmp_nm" | sed 's, -.*$,,'`" +- case "$tmp_nm_path" in ++ case "$lt_tmp_nm" in + */*|*\\*) tmp_nm="$lt_tmp_nm";; + *) tmp_nm="$ac_dir/$lt_tmp_nm";; + esac +- tmp_nm_to_nm="`$ECHO "$tmp_nm" | sed 's, -.*$,,'`" +- if test -f "$tmp_nm_to_nm" || test -f "$tmp_nm_to_nm$ac_exeext" ; then ++ 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_to_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in ++ 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_to_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in ++ case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in + *$tmp_nm*) + lt_cv_path_NM="$tmp_nm -p" + break diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix index fb891c67da40..e5ecc365d48b 100644 --- a/pkgs/development/tools/misc/binutils/default.nix +++ b/pkgs/development/tools/misc/binutils/default.nix @@ -68,6 +68,12 @@ stdenv.mkDerivation { # Make binutils output deterministic by default. ./deterministic.patch + + # Breaks nm BSD flag detection, heeds an upstream fix: + # https://sourceware.org/PR29547 + ./0001-Revert-libtool.m4-fix-the-NM-nm-over-here-B-option-w.patch + ./0001-Revert-libtool.m4-fix-nm-BSD-flag-detection.patch + # Required for newer macos versions ./0001-libtool.m4-update-macos-version-detection-block.patch