Add configure test to verify SSE2 code compiles.

Make sure that emmintrin.h can be #include'd without causing a
compilation error, rather than blindly defining HAVE_SSE2 based on
architecture.  Attempts to force SSE2 compilation on a 32-bit Ubuntu
13.10 system running as a VMware guest resulted in a no-win choice
without any obvious explanation besides toolchain misconfiguration/bug:
- Suffer compilation failure due to __MMX__, __SSE__, and __SSE2__ not
  being defined, even if -mmmx, -msse, and -msse2 are manually
  specified (note that they appear to be enabled by default).
- Manually define __MMX__, __SSE__, and __SSE2__, and suffer compiler
  warnings that they are already automatically defined.  This results in
  successful compilation and execution, but the noise is intolerable.
This commit is contained in:
Jason Evans 2014-02-25 11:21:41 -08:00
parent ad47e8996e
commit cb657e3170

View File

@ -198,21 +198,21 @@ CPU_SPINWAIT=""
case "${host_cpu}" in case "${host_cpu}" in
i[[345]]86) i[[345]]86)
;; ;;
i686) i686|x86_64)
JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]], JE_COMPILABLE([pause instruction], [],
[je_cv_asm]) [[__asm__ volatile("pause"); return 0;]],
if test "x${je_cv_asm}" = "xyes" ; then [je_cv_pause])
if test "x${je_cv_pause}" = "xyes" ; then
CPU_SPINWAIT='__asm__ volatile("pause")' CPU_SPINWAIT='__asm__ volatile("pause")'
fi fi
dnl emmintrin.h fails to compile unless MMX, SSE, and SSE2 are
dnl supported.
JE_COMPILABLE([SSE2 intrinsics], [
#include <emmintrin.h>
], [], [je_cv_sse2])
if test "x${je_cv_sse2}" = "xyes" ; then
AC_DEFINE_UNQUOTED([HAVE_SSE2], [ ]) AC_DEFINE_UNQUOTED([HAVE_SSE2], [ ])
;;
x86_64)
JE_COMPILABLE([__asm__ syntax], [],
[[__asm__ volatile("pause"); return 0;]], [je_cv_asm])
if test "x${je_cv_asm}" = "xyes" ; then
CPU_SPINWAIT='__asm__ volatile("pause")'
fi fi
AC_DEFINE_UNQUOTED([HAVE_SSE2], [ ])
;; ;;
powerpc) powerpc)
AC_DEFINE_UNQUOTED([HAVE_ALTIVEC], [ ]) AC_DEFINE_UNQUOTED([HAVE_ALTIVEC], [ ])