configure: Make AVX2 test robust to non-ELF systems
authorPeter Maydell <peter.maydell@linaro.org>
Sat, 18 Jun 2016 22:05:02 +0000 (23:05 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 28 Jun 2016 14:40:40 +0000 (15:40 +0100)
The AVX2 optimization test assumes that the object format
is ELF and the system has the readelf utility. If this isn't
true then configure might fail or emit a warning (since in
a pipe "foo | bar >/dev/null 2>&1" does not redirect the
stderr of foo, only of bar). Adjust the check so that if
we don't have readelf or don't have an ELF object then we
just don't enable the AVX2 optimization.

Reported-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Message-id: 1466287502-18730-3-git-send-email-pmaydell@chiark.greenend.org.uk

configure

index 395057bff8f579f0d82353830c7283154859407c..8ead9754e9c7a9ccd9a50c2e73c795e9a69f1d1e 100755 (executable)
--- a/configure
+++ b/configure
@@ -1792,8 +1792,10 @@ int foo(void *a) __attribute__((ifunc("bar_ifunc")));
 int main(int argc, char *argv[]) { return foo(argv[0]);}
 EOF
 if compile_object "" ; then
-    if readelf --syms $TMPO |grep "IFUNC.*foo" >/dev/null 2>&1; then
-        avx2_opt="yes"
+    if has readelf; then
+        if readelf --syms $TMPO 2>/dev/null |grep -q "IFUNC.*foo"; then
+            avx2_opt="yes"
+        fi
     fi
 fi