From f2151025401d345a9ce1c2ee0860dc69d1c6d9c0 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 20 Jan 2015 16:29:06 -0800 Subject: Handle CFLAGS disabling SSE 4.2. When checking whether nmmintrin.h works, add -msse4.2 at the *beginning* of CFLAGS, so that user (or Gentoo build process) settings with -mno-sse4.2 override it. Bug: 10792 Change-Id: I1b77c2a092360a86bc7012d29642ff3303b60812 Reviewed-on: https://code.wireshark.org/review/6696 Reviewed-by: Guy Harris --- configure.ac | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index bbc02208a9..fccd9b0fbd 100644 --- a/configure.ac +++ b/configure.ac @@ -1080,8 +1080,30 @@ CFLAGS_before_simd="$CFLAGS" AC_WIRESHARK_COMPILER_FLAGS_CHECK(-msse4.2, C) if test "x$CFLAGS" != "x$CFLAGS_before_simd" then - AC_MSG_CHECKING([whether there is nmmintrin.h header]) + # + # Restore CFLAGS. We only want to apply -msse4.2 to + # wsutil/ws_mempbrk_sse42.c, as the SSE4.2 code there + # is run only if the hardware supports it, but other + # code would do no such checks. + # + CFLAGS="$CFLAGS_before_simd" + + # + # Make sure we have the necessary header for the SSE4.2 intrinsics + # and that we can use it. + # + AC_MSG_CHECKING([whether there is nmmintrin.h header and we can use it]) + # + # Add the SSE4.2 flags to the beginning of CFLAGS, in case the + # user explicitly specified -mno-sse4.2 (or in case Gentoo's build + # tools did so); if they did so, we only want this to work if + # we can use the #pragma to override that for ws_mempbrk_sse42.c, + # and putting it at the beginning means that the CFLAGS setting + # in the environment will come later and override it. + # + saved_CFLAGS="$CFLAGS" + CFLAGS="-msse4.2 $CFLAGS" AC_TRY_COMPILE( [#include ], [return 0;], @@ -1096,9 +1118,7 @@ then AC_MSG_RESULT([no]) ] ) - - # Restore CFLAGS - CFLAGS="$CFLAGS_before_simd" + CFLAGS="$saved_CFLAGS" else have_sse42=no fi -- cgit v1.2.3