public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v2 0/7] Avoid using obsoleted egrep/fgrep
@ 2022-06-27  6:04 Xi Ruoyao
  2022-06-27  6:07 ` [PATCH v2 1/7] config: use $EGREP instead of egrep Xi Ruoyao
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Xi Ruoyao @ 2022-06-27  6:04 UTC (permalink / raw)
  To: gcc-patches
  Cc: Rainer Orth, Arnaud Charlet, Bernhard Reutner-Fischer, Jonathan Wakely

egrep and fgrep have been deprecated for a long time, and the next grep
release will emit a warning if egrep or fgrep is invoked:

https://git.savannah.gnu.org/cgit/grep.git/commit/?id=a951562

To prevent us from a lot of these warnings in the future, we should stop
using egrep and fgrep.  These patches will remove most of the use of
egrep or fgrep from GCC building system.

I've not touched libgo because I'm not familiar with it.  And, for
contrib/gen_auto_fdo_event.py and gcc/config/i386/gcc-auto-profile I'll
submit a patch porting gen_auto_fdo_event.py to Python 3 and regenerate
gcc-auto-profile separately and include the egrep fix in that patch.

Bootstrapped and regtested on x86_64-linux-gnu and sparc-sun-solaris2.11
(gcc211.fsffrance.org, where grep does not support -E and autoconf sets
EGREP="ggrep -E").

Xi Ruoyao (7):
  config: use $EGREP instead of egrep
  fixincludes: use grep instead of egrep/fgrep
  libbacktrace: use grep instead of fgrep
  fortran: use grep instead of fgrep
  testsuite: stop using obsoleted egrep
  contrib: use grep -E instead of egrep
  libffi: Use $EGREP instead of egrep

 config.rpath                       |  10 +-
 config/lib-ld.m4                   |   6 +-
 config/lib-link.m4                 |   4 +-
 configure                          | 136 ++++++++++++++-
 configure.ac                       |   5 +-
 contrib/check_GNU_style.sh         |  10 +-
 contrib/test_summary               |  13 +-
 contrib/warn_summary               |  13 +-
 fixincludes/fixinc.in              |   2 +-
 fixincludes/fixincl.x              |  10 +-
 fixincludes/genfixes               |   2 +-
 fixincludes/inclhack.def           |   6 +-
 gcc/Makefile.in                    |   1 +
 gcc/ada/gcc-interface/Make-lang.in |   3 +-
 gcc/configure                      |  80 ++++++++-
 gcc/configure.ac                   |   1 +
 gcc/fortran/Make-lang.in           |   2 +-
 gcc/testsuite/ada/acats/run_all.sh |   8 +-
 gcc/testsuite/go.test/go-test.exp  |   2 +-
 intl/configure                     |   9 +-
 libbacktrace/configure             |   2 +-
 libbacktrace/configure.ac          |   2 +-
 libcpp/configure                   |   9 +-
 libffi/configure                   | 270 ++++++++++++++---------------
 libffi/configure.ac                |   3 +-
 libgcc/configure                   |   2 +-
 libstdc++-v3/configure             |   9 +-
 27 files changed, 430 insertions(+), 190 deletions(-)

-- 
2.36.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 1/7] config: use $EGREP instead of egrep
  2022-06-27  6:04 [PATCH v2 0/7] Avoid using obsoleted egrep/fgrep Xi Ruoyao
@ 2022-06-27  6:07 ` Xi Ruoyao
  2022-07-05  0:58   ` Hans-Peter Nilsson
  2022-07-08  3:46   ` Eric Gallager
  2022-06-27  6:09 ` [PATCH v2 2/7] fixincludes: use grep instead of egrep/fgrep Xi Ruoyao
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 18+ messages in thread
From: Xi Ruoyao @ 2022-06-27  6:07 UTC (permalink / raw)
  To: gcc-patches
  Cc: Rainer Orth, Arnaud Charlet, Bernhard Reutner-Fischer,
	Jonathan Wakely, libstdc++

egrep has been deprecated in favor of grep -E for a long time, and the
next GNU grep release (3.8 or 4.0) will print a warning if egrep is used.
Unfortunately, old hosts with non-GNU grep may lack the support for -E
option.  Use AC_PROG_EGREP and $EGREP variable so we'll work fine on
both old and new platforms.

ChangeLog:

	* configure.ac: Call AC_PROG_EGREP, and use $EGREP instead of
	egrep.
	* config.rpath: Use $EGREP instead of egrep.
	* configure: Regenerate.

config/ChangeLog:

	* lib-ld.m4 (AC_LIB_PROG_LD_GNU): Call AC_PROG_EGREP, and use
	$EGREP instead of egrep.
	(acl_cv_path_LD): Likewise.
	* lib-link.m4 (AC_LIB_RPATH): Call AC_PROG_EGREP, and pass
	$EGREP to config.rpath.

gcc/ChangeLog:

	* configure: Regenerate.

intl/ChangeLog:

	* configure: Regenerate.

libcpp/ChangeLog:

	* configure: Regenerate.

libgcc/ChangeLog:

	* configure: Regenerate.

libstdc++-v3/ChangeLog:

	* configure: Regenerate.
---
 config.rpath           |  10 +--
 config/lib-ld.m4       |   6 +-
 config/lib-link.m4     |   4 +-
 configure              | 136 ++++++++++++++++++++++++++++++++++++++++-
 configure.ac           |   5 +-
 gcc/configure          |  13 ++--
 intl/configure         |   9 +--
 libcpp/configure       |   9 +--
 libgcc/configure       |   2 +-
 libstdc++-v3/configure |   9 +--
 10 files changed, 172 insertions(+), 31 deletions(-)

diff --git a/config.rpath b/config.rpath
index 4dea75957c2..4ada7468c22 100755
--- a/config.rpath
+++ b/config.rpath
@@ -29,7 +29,7 @@
 #    CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
 # or
 #    CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
+# The environment variables CC, GCC, EGREP, LDFLAGS, LD, with_gnu_ld
 # should be set by the caller.
 #
 # The set of defined variables is at the end of this script.
@@ -143,7 +143,7 @@ if test "$with_gnu_ld" = yes; then
       ld_shlibs=no
       ;;
     beos*)
-      if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null; then
         :
       else
         ld_shlibs=no
@@ -162,9 +162,9 @@ if test "$with_gnu_ld" = yes; then
     netbsd*)
       ;;
     solaris* | sysv5*)
-      if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
+      if $LD -v 2>&1 | $EGREP 'BFD 2\.8' > /dev/null; then
         ld_shlibs=no
-      elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      elif $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null; then
         :
       else
         ld_shlibs=no
@@ -174,7 +174,7 @@ if test "$with_gnu_ld" = yes; then
       hardcode_direct=yes
       ;;
     *)
-      if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null; then
         :
       else
         ld_shlibs=no
diff --git a/config/lib-ld.m4 b/config/lib-ld.m4
index 11d0ce77342..88a014b7a74 100644
--- a/config/lib-ld.m4
+++ b/config/lib-ld.m4
@@ -14,7 +14,8 @@ dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
 AC_DEFUN([AC_LIB_PROG_LD_GNU],
 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
-if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+AC_REQUIRE([AC_PROG_EGREP])dnl
+if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
   acl_cv_prog_gnu_ld=yes
 else
   acl_cv_prog_gnu_ld=no
@@ -28,6 +29,7 @@ AC_DEFUN([AC_LIB_PROG_LD],
 [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
 AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_EGREP])dnl
 AC_REQUIRE([AC_CANONICAL_HOST])dnl
 # Prepare PATH_SEPARATOR.
 # The user is always right.
@@ -88,7 +90,7 @@ AC_CACHE_VAL(acl_cv_path_LD,
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
-      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | $EGREP '(GNU|with BFD)' > /dev/null; then
 	test "$with_gnu_ld" != no && break
       else
 	test "$with_gnu_ld" != yes && break
diff --git a/config/lib-link.m4 b/config/lib-link.m4
index 20e281fd323..5bbbd999de0 100644
--- a/config/lib-link.m4
+++ b/config/lib-link.m4
@@ -99,8 +99,10 @@ AC_DEFUN([AC_LIB_RPATH],
   AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
   AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
   AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
+  AC_REQUIRE([AC_PROG_EGREP])             dnl we use $GREP
   AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
-    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" EGREP="$EGREP" \
+    with_gnu_ld="$with_gnu_ld" \
     ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
     . ./conftest.sh
     rm -f ./conftest.sh
diff --git a/configure b/configure
index 5dcaab14ae9..e0f9a0708ea 100755
--- a/configure
+++ b/configure
@@ -724,6 +724,8 @@ target_subdir
 host_subdir
 build_subdir
 build_libsubdir
+EGREP
+GREP
 AWK
 SED
 LN_S
@@ -2763,6 +2765,136 @@ fi
   test -n "$AWK" && break
 done
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
 
 srcpwd=`cd ${srcdir} ; ${PWDCMD-pwd}`
 
@@ -9448,7 +9580,7 @@ if test x${use_gnu_as} = x &&
 fi
 
 if test x${use_gnu_ld} = x &&
-   echo " ${configdirs} " | egrep " (go)?ld " > /dev/null 2>&1 ; then
+   echo " ${configdirs} " | $EGREP " (go)?ld " > /dev/null 2>&1 ; then
   with_gnu_ld=yes
   extra_host_args="$extra_host_args --with-gnu-ld"
 fi
@@ -10620,7 +10752,7 @@ case " $build_configdirs " in
     # For an installed makeinfo, we require it to be from texinfo 4.7 or
     # higher, else we use the "missing" dummy.
     if ${MAKEINFO} --version \
-       | egrep 'texinfo[^0-9]*(4\.([7-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
+       | $EGREP 'texinfo[^0-9]*(4\.([7-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
       :
     else
       MAKEINFO="$MISSING makeinfo"
diff --git a/configure.ac b/configure.ac
index 85977482aee..19d34edba1c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -88,6 +88,7 @@ ACX_PROG_LN
 AC_PROG_LN_S
 AC_PROG_SED
 AC_PROG_AWK
+AC_PROG_EGREP
 
 srcpwd=`cd ${srcdir} ; ${PWDCMD-pwd}`
 
@@ -2634,7 +2635,7 @@ if test x${use_gnu_as} = x &&
 fi
 
 if test x${use_gnu_ld} = x &&
-   echo " ${configdirs} " | egrep " (go)?ld " > /dev/null 2>&1 ; then
+   echo " ${configdirs} " | $EGREP " (go)?ld " > /dev/null 2>&1 ; then
   with_gnu_ld=yes
   extra_host_args="$extra_host_args --with-gnu-ld"
 fi
@@ -3549,7 +3550,7 @@ changequote(,)
     # For an installed makeinfo, we require it to be from texinfo 4.7 or
     # higher, else we use the "missing" dummy.
     if ${MAKEINFO} --version \
-       | egrep 'texinfo[^0-9]*(4\.([7-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
+       | $EGREP 'texinfo[^0-9]*(4\.([7-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
       :
     else
       MAKEINFO="$MISSING makeinfo"
diff --git a/gcc/configure b/gcc/configure
index f43dc989d02..c58ec9b2273 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -11160,7 +11160,7 @@ else
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
-      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | $EGREP '(GNU|with BFD)' > /dev/null; then
 	test "$with_gnu_ld" != no && break
       else
 	test "$with_gnu_ld" != yes && break
@@ -11188,7 +11188,7 @@ if ${acl_cv_prog_gnu_ld+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   # I'd rather use --version here, but apparently some GNU ld's only accept -v.
-if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
   acl_cv_prog_gnu_ld=yes
 else
   acl_cv_prog_gnu_ld=no
@@ -11200,13 +11200,14 @@ with_gnu_ld=$acl_cv_prog_gnu_ld
 
 
 
-                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
+                                                               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
 $as_echo_n "checking for shared library run path origin... " >&6; }
 if ${acl_cv_rpath+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
-    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" EGREP="$EGREP" \
+    with_gnu_ld="$with_gnu_ld" \
     ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
     . ./conftest.sh
     rm -f ./conftest.sh
@@ -19674,7 +19675,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19679 "configure"
+#line 19678 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19780,7 +19781,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19785 "configure"
+#line 19784 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/intl/configure b/intl/configure
index 03f40487a92..3caa5a51940 100755
--- a/intl/configure
+++ b/intl/configure
@@ -5090,7 +5090,7 @@ else
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
-      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | $EGREP '(GNU|with BFD)' > /dev/null; then
 	test "$with_gnu_ld" != no && break
       else
 	test "$with_gnu_ld" != yes && break
@@ -5118,7 +5118,7 @@ if ${acl_cv_prog_gnu_ld+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   # I'd rather use --version here, but apparently some GNU ld's only accept -v.
-if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
   acl_cv_prog_gnu_ld=yes
 else
   acl_cv_prog_gnu_ld=no
@@ -5130,13 +5130,14 @@ with_gnu_ld=$acl_cv_prog_gnu_ld
 
 
 
-                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
+                                                               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
 $as_echo_n "checking for shared library run path origin... " >&6; }
 if ${acl_cv_rpath+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
-    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" EGREP="$EGREP" \
+    with_gnu_ld="$with_gnu_ld" \
     ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
     . ./conftest.sh
     rm -f ./conftest.sh
diff --git a/libcpp/configure b/libcpp/configure
index 75145390215..800b0bad595 100755
--- a/libcpp/configure
+++ b/libcpp/configure
@@ -6807,7 +6807,7 @@ else
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
-      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | $EGREP '(GNU|with BFD)' > /dev/null; then
 	test "$with_gnu_ld" != no && break
       else
 	test "$with_gnu_ld" != yes && break
@@ -6835,7 +6835,7 @@ if ${acl_cv_prog_gnu_ld+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   # I'd rather use --version here, but apparently some GNU ld's only accept -v.
-if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
   acl_cv_prog_gnu_ld=yes
 else
   acl_cv_prog_gnu_ld=no
@@ -6847,13 +6847,14 @@ with_gnu_ld=$acl_cv_prog_gnu_ld
 
 
 
-                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
+                                                               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
 $as_echo_n "checking for shared library run path origin... " >&6; }
 if ${acl_cv_rpath+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
-    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" EGREP="$EGREP" \
+    with_gnu_ld="$with_gnu_ld" \
     ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
     . ./conftest.sh
     rm -f ./conftest.sh
diff --git a/libgcc/configure b/libgcc/configure
index 61f3ace2891..181420e67f2 100755
--- a/libgcc/configure
+++ b/libgcc/configure
@@ -5032,7 +5032,7 @@ if ${acl_cv_prog_gnu_ld+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   # I'd rather use --version here, but apparently some GNU ld's only accept -v.
-if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
   acl_cv_prog_gnu_ld=yes
 else
   acl_cv_prog_gnu_ld=no
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index eac60392121..f715029375b 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -28473,7 +28473,7 @@ else
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
-      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | $EGREP '(GNU|with BFD)' > /dev/null; then
 	test "$with_gnu_ld" != no && break
       else
 	test "$with_gnu_ld" != yes && break
@@ -28501,7 +28501,7 @@ if ${acl_cv_prog_gnu_ld+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   # I'd rather use --version here, but apparently some GNU ld's only accept -v.
-if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
   acl_cv_prog_gnu_ld=yes
 else
   acl_cv_prog_gnu_ld=no
@@ -28513,13 +28513,14 @@ with_gnu_ld=$acl_cv_prog_gnu_ld
 
 
 
-                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
+                                                               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
 $as_echo_n "checking for shared library run path origin... " >&6; }
 if ${acl_cv_rpath+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
-    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" EGREP="$EGREP" \
+    with_gnu_ld="$with_gnu_ld" \
     ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
     . ./conftest.sh
     rm -f ./conftest.sh
-- 
2.36.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 2/7] fixincludes: use grep instead of egrep/fgrep
  2022-06-27  6:04 [PATCH v2 0/7] Avoid using obsoleted egrep/fgrep Xi Ruoyao
  2022-06-27  6:07 ` [PATCH v2 1/7] config: use $EGREP instead of egrep Xi Ruoyao
@ 2022-06-27  6:09 ` Xi Ruoyao
  2022-06-27  9:54   ` Eric Gallager
  2022-06-27  6:09 ` [PATCH v2 3/7] libbacktrace: use grep instead of fgrep Xi Ruoyao
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Xi Ruoyao @ 2022-06-27  6:09 UTC (permalink / raw)
  To: gcc-patches
  Cc: Rainer Orth, Arnaud Charlet, Bernhard Reutner-Fischer, Jonathan Wakely

egrep/fgrep has been deprecated in favor of grep -E/-F for a long time,
and the next grep release (3.8 or 4.0) will print a warning if egrep or
fgrep is used.  Stop using egrep and fgrep so we won't see the warning.

But, we can't simply replace egrep to grep -E or fgrep to grep -F or the
build will break with some non-GNU grep implementations (lacking -E or
-F support).  autoconf documentation suggests to use AC_PROG_EGREP and
$EGREP or AC_PROG_FGREP and FGREP, but doing so is too complicated for
fixincludes.

So we simply adjust the patterns for a plain grep, instead of relying on
the behavior of grep -E/-F.

Q: Why "[ \t][ \t]*" instead of "[ \t]\\+"?
A: POSIX does not allow escaping + in BRE.

fixincludes/ChangeLog:

	* fixinc.in: Use grep instead of egrep.
	* inclhack.def: Use grep instead of egrep, and adjust an
	regular expression to make it a BRE.
	* genfixes: Use grep instead of egrep, and escape "." in the
	pattern.
	* fixincl.x: Regenerate.
---
 fixincludes/fixinc.in    |  2 +-
 fixincludes/fixincl.x    | 10 +++++-----
 fixincludes/genfixes     |  2 +-
 fixincludes/inclhack.def |  6 +++---
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fixincludes/fixinc.in b/fixincludes/fixinc.in
index 0bd8027a554..a4cd3d0fbb4 100755
--- a/fixincludes/fixinc.in
+++ b/fixincludes/fixinc.in
@@ -448,7 +448,7 @@ while [ $# != 0 ]; do
         chmod a+r $3 2>/dev/null
         if test $VERBOSE -gt 2
         then echo Copied $2 ; fi
-        for include in `egrep '^[ 	]*#[ 	]*include[ 	]*"[^/]' $3 |
+        for include in `grep '^[ 	]*#[ 	]*include[ 	]*"[^/]' $3 |
              sed -e 's/^[ 	]*#[ 	]*include[ 	]*"\([^"]*\)".*$/\1/'`
         do
 	  dir=`echo $2 | sed -e s'|/[^/]*$||'`
diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
index bad490453b7..c9b4cf504f2 100644
--- a/fixincludes/fixincl.x
+++ b/fixincludes/fixincl.x
@@ -2,11 +2,11 @@
  *
  * DO NOT EDIT THIS FILE   (fixincl.x)
  *
- * It has been AutoGen-ed  February 27, 2022 at 07:47:03 PM by AutoGen 5.18.16
+ * It has been AutoGen-ed  June 25, 2022 at 12:44:14 PM by AutoGen 5.18.16
  * From the definitions    inclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Sun Feb 27 19:47:03 UTC 2022
+/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Jun 25 12:44:14 CST 2022
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
@@ -6547,7 +6547,7 @@ static tTestDesc aMath_Huge_Val_From_Dbl_MaxTests[] = {
  *  Fix Command Arguments for Math_Huge_Val_From_Dbl_Max
  */
 static const char* apzMath_Huge_Val_From_Dbl_MaxPatch[] = { "sh", "-c",
-    "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h | sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n\
+    "\tdbl_max_def=`grep 'define[ \t][ \t]*DBL_MAX[ \t][ \t]*.*' float.h | sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n\
 \tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n\
 \tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/s@DBL_MAX@'\"$dbl_max_def@\"\n\
 \telse cat\n\
@@ -10402,9 +10402,9 @@ tSCC zVxworks_Needs_VxworksSelect0[] =
 tSCC zVxworks_Needs_VxworksTest0[] =
        " -r types/vxTypesOld.h";
 tSCC zVxworks_Needs_VxworksTest1[] =
-       " -n \"`egrep '#include' $file`\"";
+       " -n \"`grep '#include' $file`\"";
 tSCC zVxworks_Needs_VxworksTest2[] =
-       " -n \"`egrep ULONG $file`\"";
+       " -n \"`grep ULONG $file`\"";
 
 #define    VXWORKS_NEEDS_VXWORKS_TEST_CT  4
 static tTestDesc aVxworks_Needs_VxworksTests[] = {
diff --git a/fixincludes/genfixes b/fixincludes/genfixes
index 47aad01289d..3a4c05c832b 100755
--- a/fixincludes/genfixes
+++ b/fixincludes/genfixes
@@ -58,7 +58,7 @@ done
 AG="autogen $AG"
 set -e
 
-if [ -z "`${AG} -v | fgrep ' 5.'`" ]
+if [ -z "`${AG} -v | grep ' 5\.'`" ]
 then
   echo "AutoGen appears to be out of date or not correctly installed."
   echo "Please download and install from:"
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index 7605ac89aa2..080bbc010dc 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -3274,7 +3274,7 @@ fix = {
      *  If we do, we will replace the one in math.h with that one.
      */
 
-    "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
+    "\tdbl_max_def=`grep 'define[ \t][ \t]*DBL_MAX[ \t][ \t]*.*' float.h "
                    "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
 
     "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
@@ -5266,8 +5266,8 @@ fix = {
     hackname = vxworks_needs_vxworks;
     files    = sys/stat.h;
     test     = " -r types/vxTypesOld.h";
-    test     = " -n \"`egrep '#include' $file`\"";
-    test     = " -n \"`egrep ULONG $file`\"";
+    test     = " -n \"`grep '#include' $file`\"";
+    test     = " -n \"`grep ULONG $file`\"";
     select   = "#[ \t]define[ \t]+__INCstath";
 
     sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
-- 
2.36.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 3/7] libbacktrace: use grep instead of fgrep
  2022-06-27  6:04 [PATCH v2 0/7] Avoid using obsoleted egrep/fgrep Xi Ruoyao
  2022-06-27  6:07 ` [PATCH v2 1/7] config: use $EGREP instead of egrep Xi Ruoyao
  2022-06-27  6:09 ` [PATCH v2 2/7] fixincludes: use grep instead of egrep/fgrep Xi Ruoyao
@ 2022-06-27  6:09 ` Xi Ruoyao
  2022-06-27  9:07   ` Jonathan Wakely
  2022-06-27 20:00   ` Ian Lance Taylor
  2022-06-27  6:10 ` [PATCH v2 4/7] fortran: " Xi Ruoyao
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 18+ messages in thread
From: Xi Ruoyao @ 2022-06-27  6:09 UTC (permalink / raw)
  To: gcc-patches
  Cc: Rainer Orth, Arnaud Charlet, Bernhard Reutner-Fischer, Jonathan Wakely

fgrep has been deprecated in favor of grep -F for a long time, and the
next grep release (3.8 or 4.0) will print a warning of fgrep is used.
But, we can't simply replace fgrep to grep -F, or the build will break
with some non-GNU grep implementations (lacking -F support).

As "add-gnu-debuglink" is definitely not a non-trivial regex, simply
replace fgrep with grep.

libbacktrace/ChangeLog:

	* configure.ac (AC_PROG_FGREP): Use grep instead of fgrep.
	* configure: Regenerate.
---
 libbacktrace/configure    | 2 +-
 libbacktrace/configure.ac | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libbacktrace/configure b/libbacktrace/configure
index 17f470a4bec..537486d34f2 100755
--- a/libbacktrace/configure
+++ b/libbacktrace/configure
@@ -13831,7 +13831,7 @@ else
   libbacktrace_cv_objcopy_debuglink=no
 elif ! test -n "${OBJCOPY}"; then
   libbacktrace_cv_objcopy_debuglink=no
-elif ${OBJCOPY} --help | fgrep add-gnu-debuglink >/dev/null 2>&1; then
+elif ${OBJCOPY} --help | grep add-gnu-debuglink >/dev/null 2>&1; then
   libbacktrace_cv_objcopy_debuglink=yes
 else
   libbacktrace_cv_objcopy_debuglink=no
diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
index 597c9705db8..857987a2859 100644
--- a/libbacktrace/configure.ac
+++ b/libbacktrace/configure.ac
@@ -500,7 +500,7 @@ AC_CACHE_CHECK([whether objcopy supports debuglink],
   libbacktrace_cv_objcopy_debuglink=no
 elif ! test -n "${OBJCOPY}"; then
   libbacktrace_cv_objcopy_debuglink=no
-elif ${OBJCOPY} --help | fgrep add-gnu-debuglink >/dev/null 2>&1; then
+elif ${OBJCOPY} --help | grep add-gnu-debuglink >/dev/null 2>&1; then
   libbacktrace_cv_objcopy_debuglink=yes
 else
   libbacktrace_cv_objcopy_debuglink=no
-- 
2.36.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 4/7] fortran: use grep instead of fgrep
  2022-06-27  6:04 [PATCH v2 0/7] Avoid using obsoleted egrep/fgrep Xi Ruoyao
                   ` (2 preceding siblings ...)
  2022-06-27  6:09 ` [PATCH v2 3/7] libbacktrace: use grep instead of fgrep Xi Ruoyao
@ 2022-06-27  6:10 ` Xi Ruoyao
  2023-05-10 19:29   ` Bernhard Reutner-Fischer
  2022-06-27  6:11 ` [PATCH v2 5/7] testsuite: stop using obsoleted egrep Xi Ruoyao
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Xi Ruoyao @ 2022-06-27  6:10 UTC (permalink / raw)
  To: gcc-patches
  Cc: Rainer Orth, Arnaud Charlet, Bernhard Reutner-Fischer,
	Jonathan Wakely, fortran

fgrep has been deprecated in favor of grep -F for a long time, and the
next grep release (3.8 or 4.0) will print a warning of fgrep is used.
Stop using fgrep so we won't see the warning.

We can't hard code grep -F here or it may break build on hosts w/o GNU
grep.  autoconf documentation contains a warning about this issue and
suggest to use AC_PROG_FGREP and $FGREP, but these are too overkill in
the specific case: there is no way "debian" could be interpreted as an
non-trivial regex, so we can use a plain grep here.

gcc/fortran/ChangeLog:

	* Make-lang.in: Use grep instead of fgrep.
---
 gcc/fortran/Make-lang.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/fortran/Make-lang.in b/gcc/fortran/Make-lang.in
index 1cb47cb1a52..6eb597d0ca0 100644
--- a/gcc/fortran/Make-lang.in
+++ b/gcc/fortran/Make-lang.in
@@ -278,7 +278,7 @@ $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext): doc/gfortran.1 \
 	-chmod a-x $@
 
 fortran.uninstall:
-	if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
+	if $(SHELL) -c 'install-info --version | sed 1q | grep -s -v -i debian' >/dev/null 2>&1; then \
 	  echo " install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info"; \
 	  install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info || : ; \
 	else : ; fi; \
-- 
2.36.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 5/7] testsuite: stop using obsoleted egrep
  2022-06-27  6:04 [PATCH v2 0/7] Avoid using obsoleted egrep/fgrep Xi Ruoyao
                   ` (3 preceding siblings ...)
  2022-06-27  6:10 ` [PATCH v2 4/7] fortran: " Xi Ruoyao
@ 2022-06-27  6:11 ` Xi Ruoyao
  2022-06-27  6:50   ` Arnaud Charlet
  2022-06-27  6:12 ` [PATCH v2 6/7] contrib: use grep -E instead of egrep Xi Ruoyao
  2022-06-27  6:14 ` [PATCH 7/7] libffi: Use $EGREP " Xi Ruoyao
  6 siblings, 1 reply; 18+ messages in thread
From: Xi Ruoyao @ 2022-06-27  6:11 UTC (permalink / raw)
  To: gcc-patches
  Cc: Rainer Orth, Arnaud Charlet, Bernhard Reutner-Fischer, Jonathan Wakely

egrep has been deprecated in favor of grep -E for a long time, and the
next grep release (3.8 or 4.0) will print a warning of egrep is used.
Stop using egrep so we won't see the warning.

However, simply replacing egrep with grep -E will break build on some
systems (notably Solaris) w/o a POSIX-conform grep.  We detect a
suitable command with AC_PROG_EGREP, and pass it to run_acats.sh for
Ada.

For Go, simply use grep instead of egrep as the pattern does not need
any ERE features.

gcc/ChangeLog:

	* Makefile.in (EGREP): New variable.
	* configure.ac (AC_PROG_EGREP): Call it.
	* configure: Regenerate.

gcc/ada/ChangeLog:

	* gcc-interface/Make-lang.in: Pass EGREP to run_acats.sh.

gcc/testsuite/ChangeLog:

	* ada/acats/run_all.sh: Use $EGREP instead of egrep.
	* go.test/go-test.exp: Use grep intead of egrep.
---
 gcc/Makefile.in                    |  1 +
 gcc/ada/gcc-interface/Make-lang.in |  3 +-
 gcc/configure                      | 71 +++++++++++++++++++++++++++++-
 gcc/configure.ac                   |  1 +
 gcc/testsuite/ada/acats/run_all.sh |  8 +++-
 gcc/testsuite/go.test/go-test.exp  |  2 +-
 6 files changed, 81 insertions(+), 5 deletions(-)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index b6dcc45a58a..8b95ee20b46 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1090,6 +1090,7 @@ BACKENDLIBS = $(ISLLIBS) $(GMPLIBS) $(PLUGINLIBS) $(HOST_LIBS) \
 SYSLIBS = @GNAT_LIBEXC@
 
 # Used from ada/gcc-interface/Make-lang.in
+EGREP = @EGREP@
 GNATBIND = @GNATBIND@
 GNATMAKE = @GNATMAKE@
 
diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in
index 1e245ed3b0f..e0cbb6ab1ed 100644
--- a/gcc/ada/gcc-interface/Make-lang.in
+++ b/gcc/ada/gcc-interface/Make-lang.in
@@ -1050,7 +1050,8 @@ check-acats:
 	  rm -rf $(ACATSDIR)-parallel; \
 	  mkdir $(ACATSDIR)-parallel; \
 	  ( testdir=`cd ${srcdir}/${ACATSDIR} && ${PWD_COMMAND}`; \
-	    export testdir; \
+	    EGREP="$EGREP"; \
+	    export testdir EGREP; \
 	    cd $(ACATSDIR) && $(SHELL) $${testdir}/$(ACATSCMD) NONE ) \
 	    || exit 1; \
 	  GCC_RUNTEST_PARALLELIZE_DIR=$$rootme/$(ACATSDIR)-parallel; \
diff --git a/gcc/configure b/gcc/configure
index c58ec9b2273..8bd384c3fcc 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -8416,6 +8416,73 @@ case ${AWK} in
   "") as_fn_error $? "can't build without awk, bailing out" "$LINENO" 5 ;;
 esac
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
 $as_echo_n "checking whether ln -s works... " >&6; }
 if ${gcc_cv_prog_LN_S+:} false; then :
@@ -19675,7 +19742,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19678 "configure"
+#line 19745 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19781,7 +19848,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19784 "configure"
+#line 19851 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 80bdd8ceef9..bfb124e9456 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1219,6 +1219,7 @@ case ${AWK} in
   "") AC_MSG_ERROR([can't build without awk, bailing out]) ;;
 esac
 
+AC_PROG_EGREP
 gcc_AC_PROG_LN_S
 ACX_PROG_LN($LN_S)
 AC_PROG_RANLIB
diff --git a/gcc/testsuite/ada/acats/run_all.sh b/gcc/testsuite/ada/acats/run_all.sh
index ac2a86bea6c..81d3f9edd5c 100755
--- a/gcc/testsuite/ada/acats/run_all.sh
+++ b/gcc/testsuite/ada/acats/run_all.sh
@@ -53,6 +53,12 @@ if [ "$dir" = "$testdir" ]; then
   exit 1
 fi
 
+if [ -z "$EGREP" ]; then
+  # Set a default suitable for all "modern" system in case this script is
+  # not invoked by GCC building system.
+  EGREP="grep -E"
+fi
+
 GCC="$BASE/xgcc -B$BASE/"
 
 target_gnatchop () {
@@ -367,7 +373,7 @@ for chapter in $chapters; do
       target_run $dir/tests/$chapter/$i/$binmain > $dir/tests/$chapter/$i/${i}.log 2>&1
       cd $dir/tests/$chapter/$i
       cat ${i}.log >> $dir/acats.log
-      egrep -e '(==== |\+\+\+\+ |\!\!\!\! )' ${i}.log > /dev/null 2>&1
+      $EGREP -e '(==== |\+\+\+\+ |\!\!\!\! )' ${i}.log > /dev/null 2>&1
       if [ $? -ne 0 ]; then
          grep 'tasking not implemented' ${i}.log > /dev/null 2>&1
 
diff --git a/gcc/testsuite/go.test/go-test.exp b/gcc/testsuite/go.test/go-test.exp
index 11c178ad7ec..c9dbd72d16a 100644
--- a/gcc/testsuite/go.test/go-test.exp
+++ b/gcc/testsuite/go.test/go-test.exp
@@ -1207,7 +1207,7 @@ proc go-gc-tests { } {
 		   || $test_line == "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } {
 	    # These tests import the same package under two different
 	    # names, which gccgo does not support.
-	} elseif { $test_line == "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } {
+	} elseif { $test_line == "// \$G -S \$D/\$F.go | grep initdone >/dev/null && echo BUG sinit || true" } {
 	    # This tests whether initializers are written out
 	    # statically.  gccgo does not provide a way to test that,
 	    # as an initializer will be generated for any code which
-- 
2.36.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 6/7] contrib: use grep -E instead of egrep
  2022-06-27  6:04 [PATCH v2 0/7] Avoid using obsoleted egrep/fgrep Xi Ruoyao
                   ` (4 preceding siblings ...)
  2022-06-27  6:11 ` [PATCH v2 5/7] testsuite: stop using obsoleted egrep Xi Ruoyao
@ 2022-06-27  6:12 ` Xi Ruoyao
  2022-06-27  9:02   ` Jonathan Wakely
  2022-06-27  6:14 ` [PATCH 7/7] libffi: Use $EGREP " Xi Ruoyao
  6 siblings, 1 reply; 18+ messages in thread
From: Xi Ruoyao @ 2022-06-27  6:12 UTC (permalink / raw)
  To: gcc-patches
  Cc: Rainer Orth, Arnaud Charlet, Bernhard Reutner-Fischer, Jonathan Wakely

egrep has been deprecated in favor of grep -E for a long time, and the
next grep release (3.8 or 4.0) will print a warning of egrep is used.
Stop using egrep so we won't see the warning.

Some non-POSIX grep implementations does not support -E option, so for
test_summary and warn_summary we prefer grep -E, but fallback to egrep
if grep -E does not work.  For check_GNU_style.sh, I think it is only
used by developers so hard coding grep -E is OK.

contrib/ChangeLog:

	* check_GNU_style.sh: Use grep -E instead of egrep.
	* test_summary: Use grep -E instead of egrep if it works.
	* warn_summary: Likewise.
---
 contrib/check_GNU_style.sh | 10 +++++-----
 contrib/test_summary       | 13 ++++++++++++-
 contrib/warn_summary       | 13 ++++++++++++-
 3 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/contrib/check_GNU_style.sh b/contrib/check_GNU_style.sh
index fb7494661ee..535be65f063 100755
--- a/contrib/check_GNU_style.sh
+++ b/contrib/check_GNU_style.sh
@@ -113,7 +113,7 @@ g (){
 
     local found=false
     cat $inp \
-	| egrep $color -- "$arg" \
+	| grep -E $color -- "$arg" \
 	> "$tmp" && found=true
 
     if $found; then
@@ -130,8 +130,8 @@ ag (){
 
     local found=false
     cat $inp \
-	| egrep $color -- "$arg1" \
-	| egrep $color -- "$arg2" \
+	| grep -E $color -- "$arg1" \
+	| grep -E $color -- "$arg2" \
 	> "$tmp" && found=true
 
     if $found; then
@@ -148,8 +148,8 @@ vg (){
 
     local found=false
     cat $inp \
-	| egrep -v -- "$varg" \
-	| egrep $color -- "$arg" \
+	| grep -E -v -- "$varg" \
+	| grep -E $color -- "$arg" \
 	> "$tmp" && found=true
 
     if $found; then
diff --git a/contrib/test_summary b/contrib/test_summary
index 5760b053ec2..f17bf54f8ec 100755
--- a/contrib/test_summary
+++ b/contrib/test_summary
@@ -54,6 +54,17 @@ if test -z "$AWK" ; then
   done
 fi
 
+# Prefer "grep -E" which should work with POSIX-conform grep, but fallback
+# to "egrep" (which is deprecated for a long time) if grep does not support
+# -E.
+if test -z "$EGREP" ; then
+  if echo a | grep -E '(a|b)' > /dev/null 2> /dev/null; then
+    EGREP="grep -E"
+  else
+    EGREP="egrep"
+  fi
+fi
+
 : ${filesuffix=}; export filesuffix
 : ${move=true}; export move
 : ${forcemail=false}; export forcemail
@@ -77,7 +88,7 @@ for file in $files; do
     { $anychange ||
       anychange=`diff $file.sent $file 2>/dev/null |
 	if test ! -f $file.sent ||
-	   egrep '^[<>] (XPASS|FAIL)' >/dev/null; then
+	   $EGREP '^[<>] (XPASS|FAIL)' >/dev/null; then
 	    echo true
 	else
 	    echo false
diff --git a/contrib/warn_summary b/contrib/warn_summary
index d4c8b6cdb19..afa11802ee1 100755
--- a/contrib/warn_summary
+++ b/contrib/warn_summary
@@ -57,7 +57,7 @@ subdirectoryFilter()
   else
     if test "$filter" = nosub ; then
       # Omit all subdirectories.
-      egrep -v '/gcc/(ch|cp|f|fortran|ada|intl|fixinc)/'
+      $EGREP -v '/gcc/(ch|cp|f|fortran|ada|intl|fixinc)/'
     else
       # Pass through only subdir $filter.
       grep "/gcc/$filter/"
@@ -155,6 +155,17 @@ if test -z "$AWK" ; then
   done
 fi
 
+# Prefer "grep -E" which should work with POSIX-conform grep, but fallback
+# to "egrep" (which is deprecated for a long time) if grep does not support
+# -E.
+if test -z "$EGREP" ; then
+  if echo a | grep -E '(a|b)' > /dev/null 2> /dev/null; then
+    EGREP="grep -E"
+  else
+    EGREP="egrep"
+  fi
+fi
+
 # Parse command line arguments.
 while test -n "$1" ; do
  case "$1" in
-- 
2.36.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 7/7] libffi: Use $EGREP instead of egrep
  2022-06-27  6:04 [PATCH v2 0/7] Avoid using obsoleted egrep/fgrep Xi Ruoyao
                   ` (5 preceding siblings ...)
  2022-06-27  6:12 ` [PATCH v2 6/7] contrib: use grep -E instead of egrep Xi Ruoyao
@ 2022-06-27  6:14 ` Xi Ruoyao
  6 siblings, 0 replies; 18+ messages in thread
From: Xi Ruoyao @ 2022-06-27  6:14 UTC (permalink / raw)
  To: gcc-patches
  Cc: Rainer Orth, Arnaud Charlet, Bernhard Reutner-Fischer, Jonathan Wakely

Cherry-pick libffi commit 280fe78d37f58927b280e2e316a2ae19201f2b83,
and regenerate configure.

libffi/ChangeLog:

	* configure.ac: Call AC_PROG_EGREP, and use $EGREP instead of
	egrep.
	* configure: Regenerate.
---
 libffi/configure    | 270 ++++++++++++++++++++++----------------------
 libffi/configure.ac |   3 +-
 2 files changed, 137 insertions(+), 136 deletions(-)

diff --git a/libffi/configure b/libffi/configure
index 575641cca1d..3e490ba22d1 100755
--- a/libffi/configure
+++ b/libffi/configure
@@ -198,6 +198,7 @@ test -x / || exit 1"
   as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
   eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
   test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1
 
   test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || (
     ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
@@ -205,8 +206,7 @@ test -x / || exit 1"
     ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
     PATH=/empty FPATH=/empty; export PATH FPATH
     test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\
-      || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1
-test \$(( 1 + 1 )) = 2 || exit 1"
+      || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1"
   if (eval "$as_required") 2>/dev/null; then :
   as_have_required=yes
 else
@@ -683,10 +683,10 @@ ac_ct_DUMPBIN
 DUMPBIN
 LD
 FGREP
-EGREP
-GREP
 SED
 LIBTOOL
+EGREP
+GREP
 am__fastdepCCAS_FALSE
 am__fastdepCCAS_TRUE
 CCASDEPMODE
@@ -5103,6 +5103,136 @@ fi
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
 case `pwd` in
   *\ * | *\	*)
     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
@@ -5279,136 +5409,6 @@ Xsed="$SED -e 1s/^X//"
 
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
-$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if ${ac_cv_path_GREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$GREP"; then
-  ac_path_GREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in grep ggrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_GREP" || continue
-# Check for GNU ac_path_GREP and select it if it is found.
-  # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'GREP' >> "conftest.nl"
-    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_GREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_GREP="$ac_path_GREP"
-      ac_path_GREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_GREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_GREP"; then
-    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_GREP=$GREP
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
-$as_echo "$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
-$as_echo_n "checking for egrep... " >&6; }
-if ${ac_cv_path_EGREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
-   then ac_cv_path_EGREP="$GREP -E"
-   else
-     if test -z "$EGREP"; then
-  ac_path_EGREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in egrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_EGREP" || continue
-# Check for GNU ac_path_EGREP and select it if it is found.
-  # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'EGREP' >> "conftest.nl"
-    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_EGREP="$ac_path_EGREP"
-      ac_path_EGREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_EGREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_EGREP=$EGREP
-fi
-
-   fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
-$as_echo "$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
-
-
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
 $as_echo_n "checking for fgrep... " >&6; }
 if ${ac_cv_path_FGREP+:} false; then :
@@ -16256,7 +16256,7 @@ else
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; }; then
-  	    if egrep '(\.hidden|\.private_extern).*foo' conftest.s >/dev/null; then
+  	    if $EGREP '(\.hidden|\.private_extern).*foo' conftest.s >/dev/null; then
   		libffi_cv_hidden_visibility_attribute=yes
   	    fi
   	fi
diff --git a/libffi/configure.ac b/libffi/configure.ac
index 014d89d0423..b8f021cb7cb 100644
--- a/libffi/configure.ac
+++ b/libffi/configure.ac
@@ -54,6 +54,7 @@ AC_SUBST(CET_FLAGS)
 
 AM_PROG_AS
 AM_PROG_CC_C_O
+AC_PROG_EGREP
 AC_PROG_LIBTOOL
 
 AC_CHECK_TOOL(READELF, readelf)
@@ -290,7 +291,7 @@ if test "x$GCC" = "xyes"; then
   	echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1  ; }' > conftest.c
   	libffi_cv_hidden_visibility_attribute=no
   	if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
-  	    if egrep '(\.hidden|\.private_extern).*foo' conftest.s >/dev/null; then
+  	    if $EGREP '(\.hidden|\.private_extern).*foo' conftest.s >/dev/null; then
   		libffi_cv_hidden_visibility_attribute=yes
   	    fi
   	fi
-- 
2.36.1



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 5/7] testsuite: stop using obsoleted egrep
  2022-06-27  6:11 ` [PATCH v2 5/7] testsuite: stop using obsoleted egrep Xi Ruoyao
@ 2022-06-27  6:50   ` Arnaud Charlet
  0 siblings, 0 replies; 18+ messages in thread
From: Arnaud Charlet @ 2022-06-27  6:50 UTC (permalink / raw)
  To: Xi Ruoyao
  Cc: gcc-patches, Rainer Orth, Arnaud Charlet,
	Bernhard Reutner-Fischer, Jonathan Wakely

> egrep has been deprecated in favor of grep -E for a long time, and the
> next grep release (3.8 or 4.0) will print a warning of egrep is used.
> Stop using egrep so we won't see the warning.
> 
> However, simply replacing egrep with grep -E will break build on some
> systems (notably Solaris) w/o a POSIX-conform grep.  We detect a
> suitable command with AC_PROG_EGREP, and pass it to run_acats.sh for
> Ada.
> 
> For Go, simply use grep instead of egrep as the pattern does not need
> any ERE features.
> 
> gcc/ChangeLog:
> 
> 	* Makefile.in (EGREP): New variable.
> 	* configure.ac (AC_PROG_EGREP): Call it.
> 	* configure: Regenerate.
> 
> gcc/ada/ChangeLog:
> 
> 	* gcc-interface/Make-lang.in: Pass EGREP to run_acats.sh.

The Ada change is OK

Arno

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 6/7] contrib: use grep -E instead of egrep
  2022-06-27  6:12 ` [PATCH v2 6/7] contrib: use grep -E instead of egrep Xi Ruoyao
@ 2022-06-27  9:02   ` Jonathan Wakely
  0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Wakely @ 2022-06-27  9:02 UTC (permalink / raw)
  To: Xi Ruoyao
  Cc: gcc Patches, Rainer Orth, Arnaud Charlet, Bernhard Reutner-Fischer

On Mon, 27 Jun 2022 at 07:12, Xi Ruoyao <xry111@xry111.site> wrote:
>
> egrep has been deprecated in favor of grep -E for a long time, and the
> next grep release (3.8 or 4.0) will print a warning of egrep is used.
> Stop using egrep so we won't see the warning.
>
> Some non-POSIX grep implementations does not support -E option, so for
> test_summary and warn_summary we prefer grep -E, but fallback to egrep
> if grep -E does not work.  For check_GNU_style.sh, I think it is only
> used by developers so hard coding grep -E is OK.
>
> contrib/ChangeLog:
>
>         * check_GNU_style.sh: Use grep -E instead of egrep.
>         * test_summary: Use grep -E instead of egrep if it works.
>         * warn_summary: Likewise.
> ---
>  contrib/check_GNU_style.sh | 10 +++++-----
>  contrib/test_summary       | 13 ++++++++++++-
>  contrib/warn_summary       | 13 ++++++++++++-
>  3 files changed, 29 insertions(+), 7 deletions(-)
>
> diff --git a/contrib/check_GNU_style.sh b/contrib/check_GNU_style.sh
> index fb7494661ee..535be65f063 100755
> --- a/contrib/check_GNU_style.sh
> +++ b/contrib/check_GNU_style.sh
> @@ -113,7 +113,7 @@ g (){
>
>      local found=false
>      cat $inp \
> -       | egrep $color -- "$arg" \
> +       | grep -E $color -- "$arg" \
>         > "$tmp" && found=true
>
>      if $found; then
> @@ -130,8 +130,8 @@ ag (){
>
>      local found=false
>      cat $inp \
> -       | egrep $color -- "$arg1" \
> -       | egrep $color -- "$arg2" \
> +       | grep -E $color -- "$arg1" \
> +       | grep -E $color -- "$arg2" \
>         > "$tmp" && found=true
>
>      if $found; then
> @@ -148,8 +148,8 @@ vg (){
>
>      local found=false
>      cat $inp \
> -       | egrep -v -- "$varg" \
> -       | egrep $color -- "$arg" \
> +       | grep -E -v -- "$varg" \
> +       | grep -E $color -- "$arg" \
>         > "$tmp" && found=true
>
>      if $found; then
> diff --git a/contrib/test_summary b/contrib/test_summary
> index 5760b053ec2..f17bf54f8ec 100755
> --- a/contrib/test_summary
> +++ b/contrib/test_summary
> @@ -54,6 +54,17 @@ if test -z "$AWK" ; then
>    done
>  fi
>
> +# Prefer "grep -E" which should work with POSIX-conform grep, but fallback

"POSIX-conforming"

> +# to "egrep" (which is deprecated for a long time) if grep does not support

I'd just say "to deprecate egrep" or "to egrep (which is deprecated)".
There's no need to say anything about how long it's been deprecated.


> +# -E.
> +if test -z "$EGREP" ; then
> +  if echo a | grep -E '(a|b)' > /dev/null 2> /dev/null; then
> +    EGREP="grep -E"
> +  else
> +    EGREP="egrep"
> +  fi
> +fi
> +
>  : ${filesuffix=}; export filesuffix
>  : ${move=true}; export move
>  : ${forcemail=false}; export forcemail
> @@ -77,7 +88,7 @@ for file in $files; do
>      { $anychange ||
>        anychange=`diff $file.sent $file 2>/dev/null |
>         if test ! -f $file.sent ||
> -          egrep '^[<>] (XPASS|FAIL)' >/dev/null; then
> +          $EGREP '^[<>] (XPASS|FAIL)' >/dev/null; then
>             echo true
>         else
>             echo false
> diff --git a/contrib/warn_summary b/contrib/warn_summary
> index d4c8b6cdb19..afa11802ee1 100755
> --- a/contrib/warn_summary
> +++ b/contrib/warn_summary
> @@ -57,7 +57,7 @@ subdirectoryFilter()
>    else
>      if test "$filter" = nosub ; then
>        # Omit all subdirectories.
> -      egrep -v '/gcc/(ch|cp|f|fortran|ada|intl|fixinc)/'
> +      $EGREP -v '/gcc/(ch|cp|f|fortran|ada|intl|fixinc)/'
>      else
>        # Pass through only subdir $filter.
>        grep "/gcc/$filter/"
> @@ -155,6 +155,17 @@ if test -z "$AWK" ; then
>    done
>  fi
>
> +# Prefer "grep -E" which should work with POSIX-conform grep, but fallback
> +# to "egrep" (which is deprecated for a long time) if grep does not support

Ditto.

> +# -E.
> +if test -z "$EGREP" ; then
> +  if echo a | grep -E '(a|b)' > /dev/null 2> /dev/null; then
> +    EGREP="grep -E"
> +  else
> +    EGREP="egrep"
> +  fi
> +fi
> +
>  # Parse command line arguments.
>  while test -n "$1" ; do
>   case "$1" in
> --
> 2.36.1
>
>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 3/7] libbacktrace: use grep instead of fgrep
  2022-06-27  6:09 ` [PATCH v2 3/7] libbacktrace: use grep instead of fgrep Xi Ruoyao
@ 2022-06-27  9:07   ` Jonathan Wakely
  2022-06-27 20:00   ` Ian Lance Taylor
  1 sibling, 0 replies; 18+ messages in thread
From: Jonathan Wakely @ 2022-06-27  9:07 UTC (permalink / raw)
  To: Xi Ruoyao
  Cc: gcc Patches, Rainer Orth, Arnaud Charlet, Bernhard Reutner-Fischer

On Mon, 27 Jun 2022 at 07:09, Xi Ruoyao wrote:
>
> fgrep has been deprecated in favor of grep -F for a long time, and the
> next grep release (3.8 or 4.0) will print a warning of fgrep is used.
> But, we can't simply replace fgrep to grep -F, or the build will break
> with some non-GNU grep implementations (lacking -F support).
>
> As "add-gnu-debuglink" is definitely not a non-trivial regex, simply
> replace fgrep with grep.

FWIW, GNU grep will be just as fast when using grep as fgrep in this
case, because it detects that the pattern is a fixed string that
contains no special characters and automatically uses the same
matching engine as fgrep. So for GNU grep, there's no downside to this
change.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 2/7] fixincludes: use grep instead of egrep/fgrep
  2022-06-27  6:09 ` [PATCH v2 2/7] fixincludes: use grep instead of egrep/fgrep Xi Ruoyao
@ 2022-06-27  9:54   ` Eric Gallager
  0 siblings, 0 replies; 18+ messages in thread
From: Eric Gallager @ 2022-06-27  9:54 UTC (permalink / raw)
  To: Xi Ruoyao; +Cc: gcc-patches, Bernhard Reutner-Fischer, Jonathan Wakely

On Mon, Jun 27, 2022 at 2:10 AM Xi Ruoyao via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> egrep/fgrep has been deprecated in favor of grep -E/-F for a long time,
> and the next grep release (3.8 or 4.0) will print a warning if egrep or
> fgrep is used.  Stop using egrep and fgrep so we won't see the warning.
>
> But, we can't simply replace egrep to grep -E or fgrep to grep -F or the
> build will break with some non-GNU grep implementations (lacking -E or
> -F support).  autoconf documentation suggests to use AC_PROG_EGREP and
> $EGREP or AC_PROG_FGREP and FGREP, but doing so is too complicated for
> fixincludes.
>
> So we simply adjust the patterns for a plain grep, instead of relying on
> the behavior of grep -E/-F.
>
> Q: Why "[ \t][ \t]*" instead of "[ \t]\\+"?
> A: POSIX does not allow escaping + in BRE.
>
> fixincludes/ChangeLog:
>
>         * fixinc.in: Use grep instead of egrep.
>         * inclhack.def: Use grep instead of egrep, and adjust an
>         regular expression to make it a BRE.
>         * genfixes: Use grep instead of egrep, and escape "." in the
>         pattern.
>         * fixincl.x: Regenerate.
> ---
>  fixincludes/fixinc.in    |  2 +-
>  fixincludes/fixincl.x    | 10 +++++-----
>  fixincludes/genfixes     |  2 +-
>  fixincludes/inclhack.def |  6 +++---
>  4 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/fixincludes/fixinc.in b/fixincludes/fixinc.in
> index 0bd8027a554..a4cd3d0fbb4 100755
> --- a/fixincludes/fixinc.in
> +++ b/fixincludes/fixinc.in
> @@ -448,7 +448,7 @@ while [ $# != 0 ]; do
>          chmod a+r $3 2>/dev/null
>          if test $VERBOSE -gt 2
>          then echo Copied $2 ; fi
> -        for include in `egrep '^[      ]*#[    ]*include[      ]*"[^/]' $3 |
> +        for include in `grep '^[       ]*#[    ]*include[      ]*"[^/]' $3 |
>               sed -e 's/^[      ]*#[    ]*include[      ]*"\([^"]*\)".*$/\1/'`
>          do
>           dir=`echo $2 | sed -e s'|/[^/]*$||'`
> diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
> index bad490453b7..c9b4cf504f2 100644
> --- a/fixincludes/fixincl.x
> +++ b/fixincludes/fixincl.x
> @@ -2,11 +2,11 @@
>   *
>   * DO NOT EDIT THIS FILE   (fixincl.x)
>   *
> - * It has been AutoGen-ed  February 27, 2022 at 07:47:03 PM by AutoGen 5.18.16
> + * It has been AutoGen-ed  June 25, 2022 at 12:44:14 PM by AutoGen 5.18.16
>   * From the definitions    inclhack.def
>   * and the template file   fixincl
>   */
> -/* DO NOT SVN-MERGE THIS FILE, EITHER Sun Feb 27 19:47:03 UTC 2022
> +/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Jun 25 12:44:14 CST 2022

So, this is kind of a tangent, but since GCC has migrated from SVN to
git, perhaps it's time to update this comment?

>   *
>   * You must regenerate it.  Use the ./genfixes script.
>   *
> @@ -6547,7 +6547,7 @@ static tTestDesc aMath_Huge_Val_From_Dbl_MaxTests[] = {
>   *  Fix Command Arguments for Math_Huge_Val_From_Dbl_Max
>   */
>  static const char* apzMath_Huge_Val_From_Dbl_MaxPatch[] = { "sh", "-c",
> -    "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h | sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n\
> +    "\tdbl_max_def=`grep 'define[ \t][ \t]*DBL_MAX[ \t][ \t]*.*' float.h | sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n\
>  \tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n\
>  \tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/s@DBL_MAX@'\"$dbl_max_def@\"\n\
>  \telse cat\n\
> @@ -10402,9 +10402,9 @@ tSCC zVxworks_Needs_VxworksSelect0[] =
>  tSCC zVxworks_Needs_VxworksTest0[] =
>         " -r types/vxTypesOld.h";
>  tSCC zVxworks_Needs_VxworksTest1[] =
> -       " -n \"`egrep '#include' $file`\"";
> +       " -n \"`grep '#include' $file`\"";
>  tSCC zVxworks_Needs_VxworksTest2[] =
> -       " -n \"`egrep ULONG $file`\"";
> +       " -n \"`grep ULONG $file`\"";
>
>  #define    VXWORKS_NEEDS_VXWORKS_TEST_CT  4
>  static tTestDesc aVxworks_Needs_VxworksTests[] = {
> diff --git a/fixincludes/genfixes b/fixincludes/genfixes
> index 47aad01289d..3a4c05c832b 100755
> --- a/fixincludes/genfixes
> +++ b/fixincludes/genfixes
> @@ -58,7 +58,7 @@ done
>  AG="autogen $AG"
>  set -e
>
> -if [ -z "`${AG} -v | fgrep ' 5.'`" ]
> +if [ -z "`${AG} -v | grep ' 5\.'`" ]
>  then
>    echo "AutoGen appears to be out of date or not correctly installed."
>    echo "Please download and install from:"
> diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
> index 7605ac89aa2..080bbc010dc 100644
> --- a/fixincludes/inclhack.def
> +++ b/fixincludes/inclhack.def
> @@ -3274,7 +3274,7 @@ fix = {
>       *  If we do, we will replace the one in math.h with that one.
>       */
>
> -    "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
> +    "\tdbl_max_def=`grep 'define[ \t][ \t]*DBL_MAX[ \t][ \t]*.*' float.h "
>                     "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
>
>      "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
> @@ -5266,8 +5266,8 @@ fix = {
>      hackname = vxworks_needs_vxworks;
>      files    = sys/stat.h;
>      test     = " -r types/vxTypesOld.h";
> -    test     = " -n \"`egrep '#include' $file`\"";
> -    test     = " -n \"`egrep ULONG $file`\"";
> +    test     = " -n \"`grep '#include' $file`\"";
> +    test     = " -n \"`grep ULONG $file`\"";
>      select   = "#[ \t]define[ \t]+__INCstath";
>
>      sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
> --
> 2.36.1
>
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 3/7] libbacktrace: use grep instead of fgrep
  2022-06-27  6:09 ` [PATCH v2 3/7] libbacktrace: use grep instead of fgrep Xi Ruoyao
  2022-06-27  9:07   ` Jonathan Wakely
@ 2022-06-27 20:00   ` Ian Lance Taylor
  1 sibling, 0 replies; 18+ messages in thread
From: Ian Lance Taylor @ 2022-06-27 20:00 UTC (permalink / raw)
  To: Xi Ruoyao; +Cc: gcc-patches, Bernhard Reutner-Fischer, Jonathan Wakely

On Sun, Jun 26, 2022 at 11:10 PM Xi Ruoyao via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> libbacktrace/ChangeLog:
>
>         * configure.ac (AC_PROG_FGREP): Use grep instead of fgrep.
>         * configure: Regenerate.

Thanks.  Committed to mainline.

Ian

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 1/7] config: use $EGREP instead of egrep
  2022-06-27  6:07 ` [PATCH v2 1/7] config: use $EGREP instead of egrep Xi Ruoyao
@ 2022-07-05  0:58   ` Hans-Peter Nilsson
  2022-07-08  3:46   ` Eric Gallager
  1 sibling, 0 replies; 18+ messages in thread
From: Hans-Peter Nilsson @ 2022-07-05  0:58 UTC (permalink / raw)
  To: Xi Ruoyao
  Cc: gcc-patches, Bernhard Reutner-Fischer, Jonathan Wakely, libstdc++

On Mon, 27 Jun 2022, Xi Ruoyao via Gcc-patches wrote:
> egrep has been deprecated in favor of grep -E for a long time, and the
> next GNU grep release (3.8 or 4.0) will print a warning if egrep is used.
> Unfortunately, old hosts with non-GNU grep may lack the support for -E
> option.  Use AC_PROG_EGREP and $EGREP variable so we'll work fine on
> both old and new platforms.
>
> ChangeLog:
>
> 	* configure.ac: Call AC_PROG_EGREP, and use $EGREP instead of
> 	egrep.

Nit of the day:

> diff --git a/config/lib-link.m4 b/config/lib-link.m4
> index 20e281fd323..5bbbd999de0 100644
> --- a/config/lib-link.m4
> +++ b/config/lib-link.m4
> @@ -99,8 +99,10 @@ AC_DEFUN([AC_LIB_RPATH],
>    AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
>    AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
>    AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
> +  AC_REQUIRE([AC_PROG_EGREP])             dnl we use $GREP

Shouldn't that be "we use $EGREP"?

brgds, H-P

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 1/7] config: use $EGREP instead of egrep
  2022-06-27  6:07 ` [PATCH v2 1/7] config: use $EGREP instead of egrep Xi Ruoyao
  2022-07-05  0:58   ` Hans-Peter Nilsson
@ 2022-07-08  3:46   ` Eric Gallager
  1 sibling, 0 replies; 18+ messages in thread
From: Eric Gallager @ 2022-07-08  3:46 UTC (permalink / raw)
  To: Xi Ruoyao
  Cc: gcc-patches, Bernhard Reutner-Fischer, Jonathan Wakely, libstdc++

On Mon, Jun 27, 2022 at 2:07 AM Xi Ruoyao via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> egrep has been deprecated in favor of grep -E for a long time, and the
> next GNU grep release (3.8 or 4.0) will print a warning if egrep is used.
> Unfortunately, old hosts with non-GNU grep may lack the support for -E
> option.  Use AC_PROG_EGREP and $EGREP variable so we'll work fine on
> both old and new platforms.
>
> ChangeLog:
>
>         * configure.ac: Call AC_PROG_EGREP, and use $EGREP instead of
>         egrep.
>         * config.rpath: Use $EGREP instead of egrep.

config.rpath is imported from gnulib where this problem is already
fixed apparently; wouldn't it make more sense to re-import a fresh
config.rpath from upstream gnulib instead of patching GCC's local
copy?


>         * configure: Regenerate.
>
> config/ChangeLog:
>
>         * lib-ld.m4 (AC_LIB_PROG_LD_GNU): Call AC_PROG_EGREP, and use
>         $EGREP instead of egrep.
>         (acl_cv_path_LD): Likewise.
>         * lib-link.m4 (AC_LIB_RPATH): Call AC_PROG_EGREP, and pass
>         $EGREP to config.rpath.
>
> gcc/ChangeLog:
>
>         * configure: Regenerate.
>
> intl/ChangeLog:
>
>         * configure: Regenerate.
>
> libcpp/ChangeLog:
>
>         * configure: Regenerate.
>
> libgcc/ChangeLog:
>
>         * configure: Regenerate.
>
> libstdc++-v3/ChangeLog:
>
>         * configure: Regenerate.
> ---
>  config.rpath           |  10 +--
>  config/lib-ld.m4       |   6 +-
>  config/lib-link.m4     |   4 +-
>  configure              | 136 ++++++++++++++++++++++++++++++++++++++++-
>  configure.ac           |   5 +-
>  gcc/configure          |  13 ++--
>  intl/configure         |   9 +--
>  libcpp/configure       |   9 +--
>  libgcc/configure       |   2 +-
>  libstdc++-v3/configure |   9 +--
>  10 files changed, 172 insertions(+), 31 deletions(-)
>
> diff --git a/config.rpath b/config.rpath
> index 4dea75957c2..4ada7468c22 100755
> --- a/config.rpath
> +++ b/config.rpath
> @@ -29,7 +29,7 @@
>  #    CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
>  # or
>  #    CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
> -# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
> +# The environment variables CC, GCC, EGREP, LDFLAGS, LD, with_gnu_ld
>  # should be set by the caller.
>  #
>  # The set of defined variables is at the end of this script.
> @@ -143,7 +143,7 @@ if test "$with_gnu_ld" = yes; then
>        ld_shlibs=no
>        ;;
>      beos*)
> -      if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
> +      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null; then
>          :
>        else
>          ld_shlibs=no
> @@ -162,9 +162,9 @@ if test "$with_gnu_ld" = yes; then
>      netbsd*)
>        ;;
>      solaris* | sysv5*)
> -      if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
> +      if $LD -v 2>&1 | $EGREP 'BFD 2\.8' > /dev/null; then
>          ld_shlibs=no
> -      elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
> +      elif $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null; then
>          :
>        else
>          ld_shlibs=no
> @@ -174,7 +174,7 @@ if test "$with_gnu_ld" = yes; then
>        hardcode_direct=yes
>        ;;
>      *)
> -      if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
> +      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null; then
>          :
>        else
>          ld_shlibs=no
> diff --git a/config/lib-ld.m4 b/config/lib-ld.m4
> index 11d0ce77342..88a014b7a74 100644
> --- a/config/lib-ld.m4
> +++ b/config/lib-ld.m4
> @@ -14,7 +14,8 @@ dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
>  AC_DEFUN([AC_LIB_PROG_LD_GNU],
>  [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
>  [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
> -if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +AC_REQUIRE([AC_PROG_EGREP])dnl
> +if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
>    acl_cv_prog_gnu_ld=yes
>  else
>    acl_cv_prog_gnu_ld=no
> @@ -28,6 +29,7 @@ AC_DEFUN([AC_LIB_PROG_LD],
>  [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
>  test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
>  AC_REQUIRE([AC_PROG_CC])dnl
> +AC_REQUIRE([AC_PROG_EGREP])dnl
>  AC_REQUIRE([AC_CANONICAL_HOST])dnl
>  # Prepare PATH_SEPARATOR.
>  # The user is always right.
> @@ -88,7 +90,7 @@ AC_CACHE_VAL(acl_cv_path_LD,
>        # Check to see if the program is GNU ld.  I'd rather use --version,
>        # but apparently some GNU ld's only accept -v.
>        # Break only if it was the GNU/non-GNU ld that we prefer.
> -      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | $EGREP '(GNU|with BFD)' > /dev/null; then
>         test "$with_gnu_ld" != no && break
>        else
>         test "$with_gnu_ld" != yes && break
> diff --git a/config/lib-link.m4 b/config/lib-link.m4
> index 20e281fd323..5bbbd999de0 100644
> --- a/config/lib-link.m4
> +++ b/config/lib-link.m4
> @@ -99,8 +99,10 @@ AC_DEFUN([AC_LIB_RPATH],
>    AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
>    AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
>    AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
> +  AC_REQUIRE([AC_PROG_EGREP])             dnl we use $GREP
>    AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
> -    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" EGREP="$EGREP" \
> +    with_gnu_ld="$with_gnu_ld" \
>      ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
>      . ./conftest.sh
>      rm -f ./conftest.sh
> diff --git a/configure b/configure
> index 5dcaab14ae9..e0f9a0708ea 100755
> --- a/configure
> +++ b/configure
> @@ -724,6 +724,8 @@ target_subdir
>  host_subdir
>  build_subdir
>  build_libsubdir
> +EGREP
> +GREP
>  AWK
>  SED
>  LN_S
> @@ -2763,6 +2765,136 @@ fi
>    test -n "$AWK" && break
>  done
>
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
> +$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
> +if ${ac_cv_path_GREP+:} false; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$GREP"; then
> +  ac_path_GREP_found=false
> +  # Loop through the user's path and test for each of PROGNAME-LIST
> +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
> +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
> +do
> +  IFS=$as_save_IFS
> +  test -z "$as_dir" && as_dir=.
> +    for ac_prog in grep ggrep; do
> +    for ac_exec_ext in '' $ac_executable_extensions; do
> +      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
> +      as_fn_executable_p "$ac_path_GREP" || continue
> +# Check for GNU ac_path_GREP and select it if it is found.
> +  # Check for GNU $ac_path_GREP
> +case `"$ac_path_GREP" --version 2>&1` in
> +*GNU*)
> +  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
> +*)
> +  ac_count=0
> +  $as_echo_n 0123456789 >"conftest.in"
> +  while :
> +  do
> +    cat "conftest.in" "conftest.in" >"conftest.tmp"
> +    mv "conftest.tmp" "conftest.in"
> +    cp "conftest.in" "conftest.nl"
> +    $as_echo 'GREP' >> "conftest.nl"
> +    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
> +    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
> +    as_fn_arith $ac_count + 1 && ac_count=$as_val
> +    if test $ac_count -gt ${ac_path_GREP_max-0}; then
> +      # Best one so far, save it but keep looking for a better one
> +      ac_cv_path_GREP="$ac_path_GREP"
> +      ac_path_GREP_max=$ac_count
> +    fi
> +    # 10*(2^10) chars as input seems more than enough
> +    test $ac_count -gt 10 && break
> +  done
> +  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
> +esac
> +
> +      $ac_path_GREP_found && break 3
> +    done
> +  done
> +  done
> +IFS=$as_save_IFS
> +  if test -z "$ac_cv_path_GREP"; then
> +    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
> +  fi
> +else
> +  ac_cv_path_GREP=$GREP
> +fi
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
> +$as_echo "$ac_cv_path_GREP" >&6; }
> + GREP="$ac_cv_path_GREP"
> +
> +
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
> +$as_echo_n "checking for egrep... " >&6; }
> +if ${ac_cv_path_EGREP+:} false; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
> +   then ac_cv_path_EGREP="$GREP -E"
> +   else
> +     if test -z "$EGREP"; then
> +  ac_path_EGREP_found=false
> +  # Loop through the user's path and test for each of PROGNAME-LIST
> +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
> +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
> +do
> +  IFS=$as_save_IFS
> +  test -z "$as_dir" && as_dir=.
> +    for ac_prog in egrep; do
> +    for ac_exec_ext in '' $ac_executable_extensions; do
> +      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
> +      as_fn_executable_p "$ac_path_EGREP" || continue
> +# Check for GNU ac_path_EGREP and select it if it is found.
> +  # Check for GNU $ac_path_EGREP
> +case `"$ac_path_EGREP" --version 2>&1` in
> +*GNU*)
> +  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
> +*)
> +  ac_count=0
> +  $as_echo_n 0123456789 >"conftest.in"
> +  while :
> +  do
> +    cat "conftest.in" "conftest.in" >"conftest.tmp"
> +    mv "conftest.tmp" "conftest.in"
> +    cp "conftest.in" "conftest.nl"
> +    $as_echo 'EGREP' >> "conftest.nl"
> +    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
> +    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
> +    as_fn_arith $ac_count + 1 && ac_count=$as_val
> +    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
> +      # Best one so far, save it but keep looking for a better one
> +      ac_cv_path_EGREP="$ac_path_EGREP"
> +      ac_path_EGREP_max=$ac_count
> +    fi
> +    # 10*(2^10) chars as input seems more than enough
> +    test $ac_count -gt 10 && break
> +  done
> +  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
> +esac
> +
> +      $ac_path_EGREP_found && break 3
> +    done
> +  done
> +  done
> +IFS=$as_save_IFS
> +  if test -z "$ac_cv_path_EGREP"; then
> +    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
> +  fi
> +else
> +  ac_cv_path_EGREP=$EGREP
> +fi
> +
> +   fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
> +$as_echo "$ac_cv_path_EGREP" >&6; }
> + EGREP="$ac_cv_path_EGREP"
> +
> +
>
>  srcpwd=`cd ${srcdir} ; ${PWDCMD-pwd}`
>
> @@ -9448,7 +9580,7 @@ if test x${use_gnu_as} = x &&
>  fi
>
>  if test x${use_gnu_ld} = x &&
> -   echo " ${configdirs} " | egrep " (go)?ld " > /dev/null 2>&1 ; then
> +   echo " ${configdirs} " | $EGREP " (go)?ld " > /dev/null 2>&1 ; then
>    with_gnu_ld=yes
>    extra_host_args="$extra_host_args --with-gnu-ld"
>  fi
> @@ -10620,7 +10752,7 @@ case " $build_configdirs " in
>      # For an installed makeinfo, we require it to be from texinfo 4.7 or
>      # higher, else we use the "missing" dummy.
>      if ${MAKEINFO} --version \
> -       | egrep 'texinfo[^0-9]*(4\.([7-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
> +       | $EGREP 'texinfo[^0-9]*(4\.([7-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
>        :
>      else
>        MAKEINFO="$MISSING makeinfo"
> diff --git a/configure.ac b/configure.ac
> index 85977482aee..19d34edba1c 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -88,6 +88,7 @@ ACX_PROG_LN
>  AC_PROG_LN_S
>  AC_PROG_SED
>  AC_PROG_AWK
> +AC_PROG_EGREP
>
>  srcpwd=`cd ${srcdir} ; ${PWDCMD-pwd}`
>
> @@ -2634,7 +2635,7 @@ if test x${use_gnu_as} = x &&
>  fi
>
>  if test x${use_gnu_ld} = x &&
> -   echo " ${configdirs} " | egrep " (go)?ld " > /dev/null 2>&1 ; then
> +   echo " ${configdirs} " | $EGREP " (go)?ld " > /dev/null 2>&1 ; then
>    with_gnu_ld=yes
>    extra_host_args="$extra_host_args --with-gnu-ld"
>  fi
> @@ -3549,7 +3550,7 @@ changequote(,)
>      # For an installed makeinfo, we require it to be from texinfo 4.7 or
>      # higher, else we use the "missing" dummy.
>      if ${MAKEINFO} --version \
> -       | egrep 'texinfo[^0-9]*(4\.([7-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
> +       | $EGREP 'texinfo[^0-9]*(4\.([7-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then
>        :
>      else
>        MAKEINFO="$MISSING makeinfo"
> diff --git a/gcc/configure b/gcc/configure
> index f43dc989d02..c58ec9b2273 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -11160,7 +11160,7 @@ else
>        # Check to see if the program is GNU ld.  I'd rather use --version,
>        # but apparently some GNU ld's only accept -v.
>        # Break only if it was the GNU/non-GNU ld that we prefer.
> -      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | $EGREP '(GNU|with BFD)' > /dev/null; then
>         test "$with_gnu_ld" != no && break
>        else
>         test "$with_gnu_ld" != yes && break
> @@ -11188,7 +11188,7 @@ if ${acl_cv_prog_gnu_ld+:} false; then :
>    $as_echo_n "(cached) " >&6
>  else
>    # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> -if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
>    acl_cv_prog_gnu_ld=yes
>  else
>    acl_cv_prog_gnu_ld=no
> @@ -11200,13 +11200,14 @@ with_gnu_ld=$acl_cv_prog_gnu_ld
>
>
>
> -                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +                                                               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
>  $as_echo_n "checking for shared library run path origin... " >&6; }
>  if ${acl_cv_rpath+:} false; then :
>    $as_echo_n "(cached) " >&6
>  else
>
> -    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" EGREP="$EGREP" \
> +    with_gnu_ld="$with_gnu_ld" \
>      ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
>      . ./conftest.sh
>      rm -f ./conftest.sh
> @@ -19674,7 +19675,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 19679 "configure"
> +#line 19678 "configure"
>  #include "confdefs.h"
>
>  #if HAVE_DLFCN_H
> @@ -19780,7 +19781,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 19785 "configure"
> +#line 19784 "configure"
>  #include "confdefs.h"
>
>  #if HAVE_DLFCN_H
> diff --git a/intl/configure b/intl/configure
> index 03f40487a92..3caa5a51940 100755
> --- a/intl/configure
> +++ b/intl/configure
> @@ -5090,7 +5090,7 @@ else
>        # Check to see if the program is GNU ld.  I'd rather use --version,
>        # but apparently some GNU ld's only accept -v.
>        # Break only if it was the GNU/non-GNU ld that we prefer.
> -      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | $EGREP '(GNU|with BFD)' > /dev/null; then
>         test "$with_gnu_ld" != no && break
>        else
>         test "$with_gnu_ld" != yes && break
> @@ -5118,7 +5118,7 @@ if ${acl_cv_prog_gnu_ld+:} false; then :
>    $as_echo_n "(cached) " >&6
>  else
>    # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> -if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
>    acl_cv_prog_gnu_ld=yes
>  else
>    acl_cv_prog_gnu_ld=no
> @@ -5130,13 +5130,14 @@ with_gnu_ld=$acl_cv_prog_gnu_ld
>
>
>
> -                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +                                                               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
>  $as_echo_n "checking for shared library run path origin... " >&6; }
>  if ${acl_cv_rpath+:} false; then :
>    $as_echo_n "(cached) " >&6
>  else
>
> -    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" EGREP="$EGREP" \
> +    with_gnu_ld="$with_gnu_ld" \
>      ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
>      . ./conftest.sh
>      rm -f ./conftest.sh
> diff --git a/libcpp/configure b/libcpp/configure
> index 75145390215..800b0bad595 100755
> --- a/libcpp/configure
> +++ b/libcpp/configure
> @@ -6807,7 +6807,7 @@ else
>        # Check to see if the program is GNU ld.  I'd rather use --version,
>        # but apparently some GNU ld's only accept -v.
>        # Break only if it was the GNU/non-GNU ld that we prefer.
> -      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | $EGREP '(GNU|with BFD)' > /dev/null; then
>         test "$with_gnu_ld" != no && break
>        else
>         test "$with_gnu_ld" != yes && break
> @@ -6835,7 +6835,7 @@ if ${acl_cv_prog_gnu_ld+:} false; then :
>    $as_echo_n "(cached) " >&6
>  else
>    # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> -if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
>    acl_cv_prog_gnu_ld=yes
>  else
>    acl_cv_prog_gnu_ld=no
> @@ -6847,13 +6847,14 @@ with_gnu_ld=$acl_cv_prog_gnu_ld
>
>
>
> -                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +                                                               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
>  $as_echo_n "checking for shared library run path origin... " >&6; }
>  if ${acl_cv_rpath+:} false; then :
>    $as_echo_n "(cached) " >&6
>  else
>
> -    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" EGREP="$EGREP" \
> +    with_gnu_ld="$with_gnu_ld" \
>      ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
>      . ./conftest.sh
>      rm -f ./conftest.sh
> diff --git a/libgcc/configure b/libgcc/configure
> index 61f3ace2891..181420e67f2 100755
> --- a/libgcc/configure
> +++ b/libgcc/configure
> @@ -5032,7 +5032,7 @@ if ${acl_cv_prog_gnu_ld+:} false; then :
>    $as_echo_n "(cached) " >&6
>  else
>    # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> -if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
>    acl_cv_prog_gnu_ld=yes
>  else
>    acl_cv_prog_gnu_ld=no
> diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
> index eac60392121..f715029375b 100755
> --- a/libstdc++-v3/configure
> +++ b/libstdc++-v3/configure
> @@ -28473,7 +28473,7 @@ else
>        # Check to see if the program is GNU ld.  I'd rather use --version,
>        # but apparently some GNU ld's only accept -v.
>        # Break only if it was the GNU/non-GNU ld that we prefer.
> -      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | $EGREP '(GNU|with BFD)' > /dev/null; then
>         test "$with_gnu_ld" != no && break
>        else
>         test "$with_gnu_ld" != yes && break
> @@ -28501,7 +28501,7 @@ if ${acl_cv_prog_gnu_ld+:} false; then :
>    $as_echo_n "(cached) " >&6
>  else
>    # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> -if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
>    acl_cv_prog_gnu_ld=yes
>  else
>    acl_cv_prog_gnu_ld=no
> @@ -28513,13 +28513,14 @@ with_gnu_ld=$acl_cv_prog_gnu_ld
>
>
>
> -                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +                                                               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
>  $as_echo_n "checking for shared library run path origin... " >&6; }
>  if ${acl_cv_rpath+:} false; then :
>    $as_echo_n "(cached) " >&6
>  else
>
> -    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" EGREP="$EGREP" \
> +    with_gnu_ld="$with_gnu_ld" \
>      ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
>      . ./conftest.sh
>      rm -f ./conftest.sh
> --
> 2.36.1
>
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 4/7] fortran: use grep instead of fgrep
  2022-06-27  6:10 ` [PATCH v2 4/7] fortran: " Xi Ruoyao
@ 2023-05-10 19:29   ` Bernhard Reutner-Fischer
  2023-05-10 20:02     ` Thomas Koenig
  0 siblings, 1 reply; 18+ messages in thread
From: Bernhard Reutner-Fischer @ 2023-05-10 19:29 UTC (permalink / raw)
  To: Xi Ruoyao
  Cc: gcc-patches, Rainer Orth, Arnaud Charlet, Jonathan Wakely, fortran

On Mon, 27 Jun 2022 14:10:36 +0800
Xi Ruoyao <xry111@xry111.site> wrote:

> fgrep has been deprecated in favor of grep -F for a long time, and the
> next grep release (3.8 or 4.0) will print a warning of fgrep is used.
> Stop using fgrep so we won't see the warning.
> 
> We can't hard code grep -F here or it may break build on hosts w/o GNU
> grep.  autoconf documentation contains a warning about this issue and
> suggest to use AC_PROG_FGREP and $FGREP, but these are too overkill in
> the specific case: there is no way "debian" could be interpreted as an
> non-trivial regex, so we can use a plain grep here.

LGTM but i cannot approve it. I'd say this one is trivial and obvious
so you could sneak it in under the "obvious" rule..
Thanks for the patch!

> 
> gcc/fortran/ChangeLog:
> 
> 	* Make-lang.in: Use grep instead of fgrep.
> ---
>  gcc/fortran/Make-lang.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gcc/fortran/Make-lang.in b/gcc/fortran/Make-lang.in
> index 1cb47cb1a52..6eb597d0ca0 100644
> --- a/gcc/fortran/Make-lang.in
> +++ b/gcc/fortran/Make-lang.in
> @@ -278,7 +278,7 @@ $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext): doc/gfortran.1 \
>  	-chmod a-x $@
>  
>  fortran.uninstall:
> -	if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
> +	if $(SHELL) -c 'install-info --version | sed 1q | grep -s -v -i debian' >/dev/null 2>&1; then \
>  	  echo " install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info"; \
>  	  install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info || : ; \
>  	else : ; fi; \


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 4/7] fortran: use grep instead of fgrep
  2023-05-10 19:29   ` Bernhard Reutner-Fischer
@ 2023-05-10 20:02     ` Thomas Koenig
  2023-05-11  9:01       ` Pushed: " Xi Ruoyao
  0 siblings, 1 reply; 18+ messages in thread
From: Thomas Koenig @ 2023-05-10 20:02 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer, Xi Ruoyao
  Cc: gcc-patches, Rainer Orth, Arnaud Charlet, Jonathan Wakely, fortran

On 10.05.23 21:29, Bernhard Reutner-Fischer via Fortran wrote:
> On Mon, 27 Jun 2022 14:10:36 +0800
> Xi Ruoyao <xry111@xry111.site> wrote:
> 
>> fgrep has been deprecated in favor of grep -F for a long time, and the
>> next grep release (3.8 or 4.0) will print a warning of fgrep is used.
>> Stop using fgrep so we won't see the warning.
>>
>> We can't hard code grep -F here or it may break build on hosts w/o GNU
>> grep.  autoconf documentation contains a warning about this issue and
>> suggest to use AC_PROG_FGREP and $FGREP, but these are too overkill in
>> the specific case: there is no way "debian" could be interpreted as an
>> non-trivial regex, so we can use a plain grep here.
> 
> LGTM but i cannot approve it. I'd say this one is trivial and obvious
> so you could sneak it in under the "obvious" rule..

I concur, this could also have been obvious.

Anyway, OK for trunk, and

> Thanks for the patch!



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Pushed: [PATCH v2 4/7] fortran: use grep instead of fgrep
  2023-05-10 20:02     ` Thomas Koenig
@ 2023-05-11  9:01       ` Xi Ruoyao
  0 siblings, 0 replies; 18+ messages in thread
From: Xi Ruoyao @ 2023-05-11  9:01 UTC (permalink / raw)
  To: Thomas Koenig, Bernhard Reutner-Fischer
  Cc: gcc-patches, Rainer Orth, Arnaud Charlet, Jonathan Wakely, fortran

On Wed, 2023-05-10 at 22:02 +0200, Thomas Koenig wrote:
> On 10.05.23 21:29, Bernhard Reutner-Fischer via Fortran wrote:
> > On Mon, 27 Jun 2022 14:10:36 +0800
> > Xi Ruoyao <xry111@xry111.site> wrote:
> > 
> > > fgrep has been deprecated in favor of grep -F for a long time, and the
> > > next grep release (3.8 or 4.0) will print a warning of fgrep is used.
> > > Stop using fgrep so we won't see the warning.
> > > 
> > > We can't hard code grep -F here or it may break build on hosts w/o GNU
> > > grep.  autoconf documentation contains a warning about this issue and
> > > suggest to use AC_PROG_FGREP and $FGREP, but these are too overkill in
> > > the specific case: there is no way "debian" could be interpreted as an
> > > non-trivial regex, so we can use a plain grep here.
> > 
> > LGTM but i cannot approve it. I'd say this one is trivial and obvious
> > so you could sneak it in under the "obvious" rule..
> 
> I concur, this could also have been obvious.
> 
> Anyway, OK for trunk, and
> 
> > Thanks for the patch!

Pushed r14-698, with a commit msg change for the status of grep release.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-05-11  9:02 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-27  6:04 [PATCH v2 0/7] Avoid using obsoleted egrep/fgrep Xi Ruoyao
2022-06-27  6:07 ` [PATCH v2 1/7] config: use $EGREP instead of egrep Xi Ruoyao
2022-07-05  0:58   ` Hans-Peter Nilsson
2022-07-08  3:46   ` Eric Gallager
2022-06-27  6:09 ` [PATCH v2 2/7] fixincludes: use grep instead of egrep/fgrep Xi Ruoyao
2022-06-27  9:54   ` Eric Gallager
2022-06-27  6:09 ` [PATCH v2 3/7] libbacktrace: use grep instead of fgrep Xi Ruoyao
2022-06-27  9:07   ` Jonathan Wakely
2022-06-27 20:00   ` Ian Lance Taylor
2022-06-27  6:10 ` [PATCH v2 4/7] fortran: " Xi Ruoyao
2023-05-10 19:29   ` Bernhard Reutner-Fischer
2023-05-10 20:02     ` Thomas Koenig
2023-05-11  9:01       ` Pushed: " Xi Ruoyao
2022-06-27  6:11 ` [PATCH v2 5/7] testsuite: stop using obsoleted egrep Xi Ruoyao
2022-06-27  6:50   ` Arnaud Charlet
2022-06-27  6:12 ` [PATCH v2 6/7] contrib: use grep -E instead of egrep Xi Ruoyao
2022-06-27  9:02   ` Jonathan Wakely
2022-06-27  6:14 ` [PATCH 7/7] libffi: Use $EGREP " Xi Ruoyao

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).