public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: gcc-patches@gcc.gnu.org
Cc: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>,
	Arnaud Charlet <charlet@adacore.com>,
	Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>,
	 Jonathan Wakely <jwakely@redhat.com>
Subject: [PATCH v2 5/7] testsuite: stop using obsoleted egrep
Date: Mon, 27 Jun 2022 14:11:23 +0800	[thread overview]
Message-ID: <51908ccd68c022910f59a904556483c123ae428c.camel@xry111.site> (raw)
In-Reply-To: <fb82297845486b14d51905ae3df8dbba726fcf57.camel@xry111.site>

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



  parent reply	other threads:[~2022-06-27  6:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Xi Ruoyao [this message]
2022-06-27  6:50   ` [PATCH v2 5/7] testsuite: stop using obsoleted egrep 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

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=51908ccd68c022910f59a904556483c123ae428c.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=charlet@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=rep.dot.nop@gmail.com \
    --cc=ro@CeBiTec.Uni-Bielefeld.DE \
    /path/to/YOUR_REPLY

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

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