public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Alcock <nick.alcock@oracle.com>
To: binutils@sourceware.org
Subject: [PATCH 2/4] libtool.m4: adjust kludge for ignoring syntax errors
Date: Fri, 16 Dec 2022 13:25:39 +0000	[thread overview]
Message-ID: <20221216132541.45791-3-nick.alcock@oracle.com> (raw)
In-Reply-To: <20221216132541.45791-1-nick.alcock@oracle.com>

LT_PATH_NM considers an nm to support -p/-B if it returns
output that names the path being checked -- but since that is itself nm
(usually with a path attached), this can trigger false positives with
errors like

/usr/bin/nm: unknown option "B" ignored"

The test currently avoids this case for the single instance of HP-UX
by deleting all but the last line of the output.  Keep on doing that
(so we don't do more work than we need to), but also explicitly
eliminate references to "unknown" and "invalid", with any leading
capitalization.  This handles Darwin, which says

error: nm: invalid argument '-B'

Alas, we cannot check the exit code, because some nm's return nonzero
exit codes if no symbols are found!

Things were also erroneously failing if nm had actual symbols in it,
because we were getting output that did not mention nm by name (its
usual output).  Identify things that look like valid nm output and
let it through.

	PR libctf/29547
	* libtool.m4 (LT_PATH_NM): Explicitly filter out 'unknown'
	and 'invalid' errors when looking for valid output.  Let
	through actual valid nm output too.
---
 libtool.m4 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libtool.m4 b/libtool.m4
index ad63ebbb385..4e5b1884b87 100644
--- a/libtool.m4
+++ b/libtool.m4
@@ -3231,15 +3231,18 @@ AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
      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
        # Check to see if the nm accepts a BSD-compat flag.
-       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       # We discard lines that mention 'unknown', 'invalid', or 'usage', hopefully
+       # placating systems like Darwin and HP-UX, which mention the name of nm
+       # in error output.
        #   nm: unknown option "B" ignored
-       case `"$tmp_nm" -B "$tmp_nm_to_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
-       *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
+       case `"$tmp_nm" -B "$tmp_nm_to_nm" 2>&1 | $GREP -v '^ *$' | $GREP -v 'nknown ' | $GREP -v 'nvalid ' | $GREP -v 'sage: ' | sed '1q'` in
+       *$tmp_nm*|*\ \ \ [[A-Za-z]]\ *|*[[0-9a-f]][[0-9a-f]][[0-9a-f]]\ [[A-Za-z]]\ *)
+	 lt_cv_path_NM="$tmp_nm -B"
 	 break
 	 ;;
        *)
-	 case `"$tmp_nm" -p "$tmp_nm_to_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
-	 *$tmp_nm*)
+	 case `"$tmp_nm" -p "$tmp_nm_to_nm" 2>&1 | $GREP -v '^ *$' | $GREP -v 'nknown ' | $GREP -v 'nvalid ' | $GREP -v 'sage: ' | sed '1q'` in
+	 *$tmp_nm*|*\ \ \ [[A-Za-z]]\ *|*[[0-9a-f]][[0-9a-f]][[0-9a-f]]\ [[A-Za-z]]\ *)
 	   lt_cv_path_NM="$tmp_nm -p"
 	   break
 	   ;;
-- 
2.39.0.267.g7648178303


  parent reply	other threads:[~2022-12-16 13:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16 13:25 [PATCH 0/4] A few backlogged build-system problems Nick Alcock
2022-12-16 13:25 ` [PATCH 1/4] ctf: fix various dreadful typos in the ctf_archive format comments Nick Alcock
2022-12-16 13:25 ` Nick Alcock [this message]
2022-12-16 13:54   ` [PATCH 2/4] libtool.m4: adjust kludge for ignoring syntax errors Andreas Schwab
2022-12-16 15:11     ` Nick Alcock
2022-12-16 15:18       ` Andreas Schwab
2022-12-19 17:30         ` Nick Alcock
2022-12-16 13:25 ` [PATCH 3/4] Regenerate affected configures Nick Alcock
2022-12-16 13:25 ` [PATCH 4/4] libctf: skip the testsuite from inside dejagnu Nick Alcock
2022-12-20 12:53 ` [PATCH 0/4] A few backlogged build-system problems Alan Modra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221216132541.45791-3-nick.alcock@oracle.com \
    --to=nick.alcock@oracle.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).