Created attachment 166113 [details]
Fix lame's configure script to correctly detect SSE support
During the exp-run in bug 206074, it was found that audio/lame gives errors with a recent clang 3.8.0 snapshot, but only on i386 :
xmm_quantize_sub.c:65:34: error: always_inline function '_mm_loadu_ps' requires target feature 'mmx', but would be inlined into function 'init_xrpow_core_sse' that is compiled without support for 'mmx'
const __m128 vec_fabs_mask = _mm_loadu_ps(&fabs_mask._float);
And many more of such errors, in lame's SSE (vector) support routines. The actual message is a little misleading, as it is really SSE support that is missing. E.g., the program is compiled on i386-freebsd, which has i486 as default target CPU, but there is no -msse flag on the command line. (Note that these messages go away if you set CPUTYPE to a CPU which does support SSE.)
When you compile with recent versions of gcc (4.9 and higher), you get similar errors:
In file included from xmm_quantize_sub.c:37:0:
/usr/local/lib/gcc49/gcc/i386-portbld-freebsd11.0/4.9.4/include/xmmintrin.h:929:1: error: inlining failed in call to always_inline '_mm_loadu_ps': target specific option mismatch
_mm_loadu_ps (float const *__P)
The cause is that lame's configure script simply checks for the existence of <xmmintrin.h>, and if it exists, and can be compiled, it assumes SSE intrinsics are available. This is not generally true anymore, because recent versions of gcc and clang removed the #ifdef __SSE__ checks from their xmmintrin.h files, and therefore a test program which only does "#include <xmmintrin.h>" will always compile, even if SSE support is turned off.
I have attempted to fix lame's configure.in and configure scripts, by letting them compile a function which actually calls an SSE intrinsic. It works correctly for me, but my knowledge of autoconf is limited, so a double-check by an expert would be nice.
This should probably be upstreamed too.
A commit references this bug:
Date: Fri Jan 29 22:16:08 UTC 2016
New revision: 407500
Fix build with clang 3.8.0 (and gcc >= 4.9.0).
This changes the XMM intrinsincs detection logic.
Submitted by: dim