From patchwork Sun Mar 12 17:30:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Neyman X-Patchwork-Id: 19539 Received: (qmail 58593 invoked by alias); 12 Mar 2017 17:30:36 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 58464 invoked by uid 89); 12 Mar 2017 17:30:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=complains X-HELO: nm5-vm6.access.bullet.mail.bf1.yahoo.com X-Yahoo-SMTP: 0h0Q7euswBD_g.kcEqbzJWRFfrba801gq1M1 Subject: [PATCH v3] configure.ac: Avoid empty subexpression in grep To: Paul Eggert , libc-alpha@sourceware.org References: <8370e47b-8475-a19d-def9-2cac565eb48c@att.net> <12572e7c-59f0-7c00-640a-b84c9f488491@cs.ucla.edu> <20170312015319.GI31094@vapier> From: Alexey Neyman Message-ID: <5453c291-2f66-2158-0ee5-d04929dd3820@att.net> Date: Sun, 12 Mar 2017 10:30:25 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: 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 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 --- 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 + + * configure.ac: Avoid empty subexpression in grep. + * configure: Regenerate. + 2017-03-10 Stefan Liebler * 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