Bug 206620 - audio/lame: fix build with clang 3.8.0 (and gcc >= 4.9.0)
Summary: audio/lame: fix build with clang 3.8.0 (and gcc >= 4.9.0)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Alexander Leidinger
Depends on:
Blocks: 206074
  Show dependency treegraph
Reported: 2016-01-25 19:39 UTC by Dimitry Andric
Modified: 2016-01-29 22:17 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (netchild)

Fix lame's configure script to correctly detect SSE support (2.46 KB, patch)
2016-01-25 19:39 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer 2016-01-25 19:39:09 UTC
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 [1]:

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[0]);

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.

[1] http://package18.nyi.freebsd.org/data/headi386PR206074-default/2016-01-17_07h20m29s/logs/errors/lame-3.99.5_2.log
Comment 1 commit-hook freebsd_committer 2016-01-29 22:16:29 UTC
A commit references this bug:

Author: netchild
Date: Fri Jan 29 22:16:08 UTC 2016
New revision: 407500
URL: https://svnweb.freebsd.org/changeset/ports/407500

  Fix build with clang 3.8.0 (and gcc >= 4.9.0).
  This changes the XMM intrinsincs detection logic.

  Submitted by:	dim
  PR:		206620