diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2021-12-03 16:33:25 +0000 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2022-03-25 12:02:35 +0000 |
commit | caf606c90d55305967b9253447dda93d2f1835ab (patch) | |
tree | 4ae0d1d66def1f3b4db0d8f3c69fa07c66a6b728 /gprof/configure | |
parent | ee41183df40c738e3f7e5530e469357762ce2101 (diff) | |
download | gdb-caf606c90d55305967b9253447dda93d2f1835ab.zip gdb-caf606c90d55305967b9253447dda93d2f1835ab.tar.gz gdb-caf606c90d55305967b9253447dda93d2f1835ab.tar.bz2 |
libtool.m4: fix the NM="/nm/over/here -B/option/with/path" case
My previous nm patch handled all cases but one -- if the user set NM in
the environment to a path which contained an option, libtool's nm
detection tries to run nm against a copy of nm with the options in it:
e.g. if NM was set to "nm --blargle", and nm was found in /usr/bin, the
test would try to run "/usr/bin/nm --blargle /usr/bin/nm --blargle".
This is unlikely to be desirable: in this case we should run
"/usr/bin/nm --blargle /usr/bin/nm".
Furthermore, as part of this nm has to detect when the passed-in $NM
contains a path, and in that case avoid doing a path search itself.
This too was thrown off if an option contained something that looked
like a path, e.g. NM="nm -B../prev-gcc"; libtool then tries to run
"nm -B../prev-gcc nm" which rarely works well (and indeed it looks
to see whether that nm exists, finds it doesn't, and wrongly concludes
that nm -p or whatever does not work).
Fix all of these by clipping all options (defined as everything
including and after the first " -") before deciding whether nm
contains a path (but not using the clipped value for anything else),
and then removing all options from the path-modified nm before
looking to see whether that nm existed.
NM=my-nm now does a path search and runs e.g.
/usr/bin/my-nm -B /usr/bin/my-nm
NM=/usr/bin/my-nm now avoids a path search and runs e.g.
/usr/bin/my-nm -B /usr/bin/my-nm
NM="my-nm -p../wombat" now does a path search and runs e.g.
/usr/bin/my-nm -p../wombat -B /usr/bin/my-nm
NM="../prev-binutils/new-nm -B../prev-gcc" now avoids a path search:
../prev-binutils/my-nm -B../prev-gcc -B ../prev-binutils/my-nm
This seems to be all combinations, including those used by GCC bootstrap
(which, before this commit, fails to bootstrap when configured
--with-build-config=bootstrap-lto, because the lto plugin is now using
--export-symbols-regex, which requires libtool to find a working nm,
while also using -B../prev-gcc to point at the lto plugin associated
with the GCC just built.)
Regenerate all affected configure scripts.
* libtool.m4 (LT_PATH_NM): Handle user-specified NM with
options, including options containing paths.
Diffstat (limited to 'gprof/configure')
-rwxr-xr-x | gprof/configure | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/gprof/configure b/gprof/configure index 8cb3921..41a2662 100755 --- a/gprof/configure +++ b/gprof/configure @@ -4890,25 +4890,31 @@ else 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=. - case "$lt_tmp_nm" in + # 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 */*|*\\*) 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 + 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: # nm: unknown option "B" ignored - case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in + case `"$tmp_nm" -B "$tmp_nm_to_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 + case `"$tmp_nm" -p "$tmp_nm_to_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in *$tmp_nm*) lt_cv_path_NM="$tmp_nm -p" break @@ -10598,7 +10604,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10601 "configure" +#line 10607 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10704,7 +10710,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10707 "configure" +#line 10713 "configure" #include "confdefs.h" #if HAVE_DLFCN_H |