diff mbox

[v4] configure.ac: Avoid empty subexpression in grep

Message ID 92cc0f94-6cde-b6e4-e3c9-7cc2f5349e40@att.net
State New
Headers show

Commit Message

Alexey Neyman March 12, 2017, 8:25 p.m. UTC
On 03/12/2017 11:29 AM, Paul Eggert wrote:
> Alexey Neyman wrote:
>>>
>>>> replace all the /dev/null redirects with a -q flag.
>>>
>>> That also works.
>>>
>> Version 3 of the patch attached.
>
> Hmm, sorry, I forgot about this issue:
>
> https://bugs.gnu.org/24941
>
> The problem is that in many cases
>
>    FOO | grep -q BAR
>
> will cause FOO to output a "Broken pipe" diagnostic, whereas
>
>    FOO | grep BAR >/dev/null
>
> will be quiet (and also less efficient, but nobody cares about 
> performance here). So perhaps we'd better avoid the 
> /dev/null-to-minus-q part of the change, and stick to just fixing the 
> bug at hand for now.
>
v4 attached. Using ERE and 'grep -F' instead of fgrep.

Regards,
Alexey.

Comments

Paul Eggert March 12, 2017, 10 p.m. UTC | #1
Thanks, this looks good.
Mike Frysinger March 12, 2017, 10:25 p.m. UTC | #2
thanks, lgtm
-mike
Alexey Neyman March 13, 2017, 1 a.m. UTC | #3
On 03/12/2017 03:25 PM, Mike Frysinger wrote:
> thanks, lgtm
> -mike

Can any of you push it then?

Regards,
Alexey.
Mike Frysinger March 15, 2017, 8:28 p.m. UTC | #4
On 12 Mar 2017 13:25, Alexey Neyman wrote:
> v4 attached. Using ERE and 'grep -F' instead of fgrep.

pushed, thanks!
-mike
diff mbox

Patch

From 8d936bdacbc5b6e49f316cad02c49d51117415d8 Mon Sep 17 00:00:00 2001
From: Alexey Neyman <stilor@att.net>
Date: Sun, 12 Mar 2017 13:16:18 -0700
Subject: [PATCH v4] Fix combreloc test with BSD grep

The test for "-z combreloc" fails when cross-compiling on a machine
that uses BSD grep (e.g. on macos). grep complains about empty
subexpression and exits with non-zero status, which is interpreted
by configure as "not found". As a result, support for "-z combreloc"
(HAVE_Z_COMBRELOC) is not detected, leading to link failure on SPARC.

While there, replace fgrep with 'grep -F', as fgrep is non-POSIX.

	* configure.ac: Avoid empty subexpression in grep.

Signed-off-by: Alexey Neyman <stilor@att.net>
---
 ChangeLog    |  5 +++++
 configure    |  8 ++++----
 configure.ac | 10 +++++-----
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e0acd7d..bcf90e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@ 
+2017-03-12  Alexey Neyman <stilor@att.net>
+
+	* configure.ac: Avoid empty subexpression in grep.
+	* configure: Regenerate.
+
 2017-03-10  Stefan Liebler  <stli@linux.vnet.ibm.com>
 
 	* math/auto-libm-test-out-catan: Regenerated.
diff --git a/configure.ac b/configure.ac
index 4a77411..4981bf9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1390,8 +1390,8 @@  dnl The following test is a bit weak.  We must use a tool which can test
 dnl cross-platform since the gcc used can be a cross compiler.  Without
 dnl introducing new options this is not easily doable.  Instead use a tool
 dnl which always is cross-platform: readelf.  To detect whether -z combreloc
-dnl look for a section named .rel.dyn.
-  if $READELF -S conftest.so | grep '\.rel\(a\|\)\.dyn' > /dev/null; then
+dnl look for a section named .rel.dyn or .rela.dyn.
+  if $READELF -S conftest.so | grep -E '.rela?.dyn' > /dev/null; then
     libc_cv_z_combreloc=yes
   else
     libc_cv_z_combreloc=no
@@ -1586,7 +1586,7 @@  void zero (void *x)
 }
 EOF
 dnl
-if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | fgrep "memset" > /dev/null]);
+if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "memset" > /dev/null]);
 then
   libc_cv_gcc_builtin_memset=no
 else
@@ -1606,7 +1606,7 @@  char *foo (const char *a, const char *b)
 }
 EOF
 dnl
-if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | fgrep "my_strstr" > /dev/null]);
+if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "my_strstr" > /dev/null]);
 then
   libc_cv_gcc_builtin_redirection=yes
 else
@@ -1747,7 +1747,7 @@  typedef struct {
 extern const Ehdr __ehdr_start __attribute__ ((visibility ("hidden")));
 long ehdr (void) { return __ehdr_start.val; }
 ])],
-	       [if $READELF -r conftest | fgrep __ehdr_start >/dev/null; then
+	       [if $READELF -r conftest | grep -F __ehdr_start >/dev/null; then
 		  libc_cv_ehdr_start=broken
 		else
 		  libc_cv_ehdr_start=yes
-- 
2.9.3