This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v3] configure.ac: Avoid empty subexpression in grep
On 03/12/2017 12:50 AM, Paul Eggert wrote:
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.
Version 3 of the patch attached.
Regards,
Alexey.
>From 898e5c86795cf6f35c705dcfaba1d1f5c4d62486 Mon Sep 17 00:00:00 2001
From: Alexey Neyman <stilor@att.net>
Date: Wed, 8 Mar 2017 14:31:10 -0800
Subject: [PATCH v3] 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, use other POSIX-mandated features of grep: -q instead
of redirecting to /dev/null; -F instead of fgrep (since fgrep is not
in POSIX).
* configure.ac: Avoid empty subexpression in grep.
Signed-off-by: Alexey Neyman <stilor@att.net>
---
ChangeLog | 5 +++++
configure | 26 +++++++++++++-------------
configure.ac | 28 ++++++++++++++--------------
3 files changed, 32 insertions(+), 27 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..0ecb2a4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -718,7 +718,7 @@ if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
-o conftest conftest.S 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
# Do a link to see if the backend supports IFUNC relocs.
$READELF -r conftest 1>&AS_MESSAGE_LOG_FD
- LC_ALL=C $READELF -r conftest | grep 'no relocations' >/dev/null || {
+ LC_ALL=C $READELF -r conftest | grep -q 'no relocations' || {
libc_cv_ld_gnu_indirect_function=yes
}
fi
@@ -742,7 +742,7 @@ EOF
libc_cv_gcc_indirect_function=no
if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
2>&AS_MESSAGE_LOG_FD ; then
- if $READELF -s conftest.o | grep IFUNC >/dev/null 2>&AS_MESSAGE_LOG_FD; then
+ if $READELF -s conftest.o | grep -q IFUNC 2>&AS_MESSAGE_LOG_FD; then
libc_cv_gcc_indirect_function=yes
fi
fi
@@ -1280,8 +1280,8 @@ AC_CACHE_CHECK(for broken __attribute__((alias())),
EOF
libc_cv_broken_alias_attribute=yes
if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
- if grep 'xyzzy' conftest.s >/dev/null &&
- grep 'abccb' conftest.s >/dev/null; then
+ if grep -q 'xyzzy' conftest.s &&
+ grep -q 'abccb' conftest.s; then
libc_cv_broken_alias_attribute=no
fi
fi
@@ -1296,7 +1296,7 @@ AC_CACHE_CHECK(whether to put _rtld_local into .sdata section,
[echo "int i;" > conftest.c
libc_cv_have_sdata_section=no
if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \
- | grep '\.sdata' >/dev/null; then
+ | grep -q '\.sdata'; then
libc_cv_have_sdata_section=yes
fi
rm -f conftest.c conftest.so
@@ -1341,7 +1341,7 @@ AC_CACHE_CHECK(for libunwind-support in compiler,
int main (void) { return 0; }
EOF
if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static -o conftest \
- conftest.c -v 2>&1 >/dev/null | grep ' -lunwind ' >/dev/null; then
+ conftest.c -v 2>&1 >/dev/null | grep -q ' -lunwind '; then
libc_cv_cc_with_libunwind=yes
else
libc_cv_cc_with_libunwind=no
@@ -1360,7 +1360,7 @@ void foo (void) { }
EOF
if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
-S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
- && grep .note.GNU-stack conftest.s >/dev/null \
+ && grep -q '\.note\.GNU-stack' conftest.s \
&& AC_TRY_COMMAND([${CC-cc} $ASFLAGS -Wa,--noexecstack
-c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
then
@@ -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 -q -E '\.rela?\.dyn'; then
libc_cv_z_combreloc=yes
else
libc_cv_z_combreloc=no
@@ -1496,7 +1496,7 @@ if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
1>&AS_MESSAGE_LOG_FD])
then
dnl look for GLOB_DAT relocation.
- if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
+ if $READELF -rW conftest.so | grep -q '_GLOB_DAT'; then
libc_cv_has_glob_dat=yes
else
libc_cv_has_glob_dat=no
@@ -1564,7 +1564,7 @@ AC_CACHE_CHECK(whether cc puts quotes around section names,
__attribute__ ((section ("bar"))) = 1;
EOF
if ${CC-cc} -S conftest.c -o conftest.s; then
- if grep '\.section.*"bar"' conftest.s >/dev/null; then
+ if grep -q '\.section.*"bar"' conftest.s; then
libc_cv_have_section_quotes=yes
else
libc_cv_have_section_quotes=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 -q "memset"]);
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 -q "my_strstr"]);
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 -q __ehdr_start; then
libc_cv_ehdr_start=broken
else
libc_cv_ehdr_start=yes
--
2.9.3