Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 413661 - media-libs/x264-0.0.20111220 on x86 enables SSE even on non-SSE host
Summary: media-libs/x264-0.0.20111220 on x86 enables SSE even on non-SSE host
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: x86 Linux
: Normal normal (vote)
Assignee: media-video herd
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2012-04-26 18:48 UTC by Petr Pisar
Modified: 2013-08-01 16:59 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Fix (x264-0.0.20111220.ebuild.patch,740 bytes, patch)
2012-04-26 19:16 UTC, Petr Pisar
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Pisar 2012-04-26 18:48:54 UTC
I have AMD Duron processor which does not support SSE:

vendor_id       : AuthenticAMD
cpu family      : 6
model           : 3
model name      : AMD Duron(tm) processor
stepping        : 1
cpu MHz         : 951.632
cache size      : 64 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr syscall mmxext 3dnowext 3dnow
bogomips        : 1903.26
clflush size    : 32
cache_alignment : 32
address sizes   : 36 bits physical, 32 bits virtual
power management:

But compiling media-libs/x264-0.0.20111220 with USE="custom-cflags threads" creates a binary which uses SSE instructions resulting in run-time error:

[libx264 @ 0x92af240] your cpu does not support SSE1, but x264 was compiled with asm support
[libx264 @ 0x92af240] to run x264, recompile without asm support (configure --disable-asm)

This is because x264 configure script injects "-msse" into CFLAGS:

case $host_cpu in
    i*86)
        ARCH="X86"
        AS="yasm"
        ASFLAGS="$ASFLAGS -O2"
        if [ $compiler = GNU ]; then
            if [[ "$asm" == auto && "$CFLAGS" != *-march* ]]; then
                CFLAGS="$CFLAGS -march=i686"
            fi
            if [[ "$asm" == auto && "$CFLAGS" != *-mfpmath* ]]; then
                CFLAGS="$CFLAGS -mfpmath=sse -msse"
            fi
        else
[...]
esac

and encoder/encoder.c code looks like:

static int x264_validate_parameters( x264_t *h, int b_open )
{
#if HAVE_MMX
#ifdef __SSE__
    if( b_open && !(x264_cpu_detect() & X264_CPU_SSE) )
    {
        x264_log( h, X264_LOG_ERROR, "your cpu does not support SSE1, but x264 was compiled with asm support\n");
#else
    if( b_open && !(x264_cpu_detect() & X264_CPU_MMX2) )
    {
        x264_log( h, X264_LOG_ERROR, "your cpu does not support MMXEXT, but x264 was compiled with asm support\n");
#endif
        x264_log( h, X264_LOG_ERROR, "to run x264, recompile without asm support (configure --disable-asm)\n");
        return -1;
    }
#endif

I think ebuilds CLFAGS hack:

    if use custom-cflags; then
        local cflags
        cflags="$(grep "^CFLAGS=" config.mak | sed 's/CFLAGS=//')"

does not catch this occurrence. I think harnessing USE flags "sse" or "mmx" would be more appropriate.
Comment 1 Petr Pisar 2012-04-26 19:16:18 UTC
Created attachment 310215 [details, diff]
Fix

This is yet another CFLAGS hack to remove SSE options if USE="custom-cflags -sse".
Comment 2 Alexis Ballier gentoo-dev 2013-08-01 16:59:25 UTC
+  01 Aug 2013; Alexis Ballier <aballier@gentoo.org> x264-9999.ebuild,
+  +files/x264-cflags.patch:
+  Do not mess too much with CFLAGS. Should fix bug #413661 and bug #351219.
+