diff mbox

configure.ac: Avoid empty subexpression in grep

Message ID 8370e47b-8475-a19d-def9-2cac565eb48c@att.net
State New
Headers show

Commit Message

Alexey Neyman March 9, 2017, 4:12 p.m. UTC
Hi all,

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.

Trivial patch attached.

Regards,
Alexey.

Comments

Paul Eggert March 9, 2017, 9:50 p.m. UTC | #1
On 03/09/2017 08:12 AM, Alexey Neyman wrote:
> -  if $READELF -S conftest.so | grep '\.rel\(a\|\)\.dyn' > /dev/null; then
> +  if $READELF -S conftest.so | grep '\.\(rel\|rela\)\.dyn' > /dev/null; then

Neither the old nor the new code is portable, as POSIX does not require 
support for '\|'. Instead, how about something like this?

    if $READELF -S conftest.so | grep -F -e '.rel.dyn' -e '.rela.dyn' > 
/dev/null; then
Mike Frysinger March 12, 2017, 1:53 a.m. UTC | #2
On 09 Mar 2017 13:50, Paul Eggert wrote:
> On 03/09/2017 08:12 AM, Alexey Neyman wrote:
> > -  if $READELF -S conftest.so | grep '\.rel\(a\|\)\.dyn' > /dev/null; then
> > +  if $READELF -S conftest.so | grep '\.\(rel\|rela\)\.dyn' > /dev/null; then
> 
> Neither the old nor the new code is portable, as POSIX does not require 
> support for '\|'. Instead, how about something like this?
> 
>     if $READELF -S conftest.so | grep -F -e '.rel.dyn' -e '.rela.dyn' > 
> /dev/null; then

why not just use an ERE then ?
	if $READELF -S conftest.so | grep -E '\.rela?\.dyn' >/dev/null; then

it's not clear what standard glibc is attempting to adhere to, but it
seems like we should just permit whatever is in POSIX.  i.e. replace
all the /dev/null redirects with a -q flag.
-mike
Alexey Neyman March 12, 2017, 3:47 a.m. UTC | #3
On 03/11/2017 05:53 PM, Mike Frysinger wrote:

> On 09 Mar 2017 13:50, Paul Eggert wrote:
>> On 03/09/2017 08:12 AM, Alexey Neyman wrote:
>>> -  if $READELF -S conftest.so | grep '\.rel\(a\|\)\.dyn' > /dev/null; then
>>> +  if $READELF -S conftest.so | grep '\.\(rel\|rela\)\.dyn' > /dev/null; then
>> Neither the old nor the new code is portable, as POSIX does not require
>> support for '\|'. Instead, how about something like this?
>>
>>      if $READELF -S conftest.so | grep -F -e '.rel.dyn' -e '.rela.dyn' >
>> /dev/null; then
> why not just use an ERE then ?
> 	if $READELF -S conftest.so | grep -E '\.rela?\.dyn' >/dev/null; then
>
> it's not clear what standard glibc is attempting to adhere to, but it
> seems like we should just permit whatever is in POSIX.  i.e. replace
> all the /dev/null redirects with a -q flag.
-F is POSIX, too, so either works.

I'll update the patch to use -q once you settle on whether -E or -F is 
preferred :)

Regards,
Alexey.
Paul Eggert March 12, 2017, 8:50 a.m. UTC | #4
Mike Frysinger wrote:
> why not just use an ERE then ?
> 	if $READELF -S conftest.so | grep -E '\.rela?\.dyn' >/dev/null; then

Sure, that works too.

> replace all the /dev/null redirects with a -q flag.

That also works.
diff mbox

Patch

From 61d5f9c09b3157db76bd1a393e248c262a8d9dd4 Mon Sep 17 00:00:00 2001
From: Alexey Neyman <stilor@att.net>
Date: Wed, 8 Mar 2017 14:31:10 -0800
Subject: [PATCH] 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.

	* configure.ac: Avoid empty subexpression in grep.

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

diff --git a/ChangeLog b/ChangeLog
index ba57667..0ed7d3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@ 
+2017-03-08  Alexey Neyman <stilor@att.net>
+
+	* configure.ac: Avoid empty subexpression in grep.
+	* configure: Regenerate.
+
 2017-03-08  Yury Norov <ynorov@caviumnetworks.com>
 	    Zack Weinberg  <zackw@panix.com>
 
diff --git a/configure.ac b/configure.ac
index 4a77411..19f6d87 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1391,7 +1391,7 @@  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
+  if $READELF -S conftest.so | grep '\.\(rel\|rela\)\.dyn' > /dev/null; then
     libc_cv_z_combreloc=yes
   else
     libc_cv_z_combreloc=no
-- 
2.9.3