[x264-devel] Failure to build x264 with ASM on i386

Loren Merritt lorenm at u.washington.edu
Mon Feb 3 18:39:58 CET 2014


On Sun, 2 Feb 2014, Brad Smith wrote:
> On 02/02/14 8:22 AM, Dimitry Andric wrote:
>> On 02 Feb 2014, at 11:24, Brad Smith <brad at comstyle.com> wrote:
>>> I am trying to build x264 with ASM on i386 but running into an issue with
>>> two functions within common/x86/util.h not building, the two
>>> functions in question are x264_predictor_clip_mmx2() and
>>> x264_predictor_roundclip_mmx2(). This code builds fine on amd64.
>>> I tried without and with -fomit-frame-pointer but that did not
>>> help. The rest of x264 builds just fine.
>>>
>>> Looking for any assistance with trying to fix the build.
>>>
>>> $ clang -Wshadow -ffast-math -O2 -pipe -fomit-frame-pointer -Wall -I. -I.
>>> -std=gnu99 -fno-tree-vectorize -fPIC -c -o encoder/me.so encoder/me.c
>>> In file included from encoder/me.c:28:
>>> In file included from ./common/common.h:1014:
>>> ./common/x86/util.h:131:9: error: inline assembly requires more registers
>>> than available
>>>         "movq       (%2), %%mm5 \n"
>>>         ^
>>> ./common/x86/util.h:194:9: error: inline assembly requires more registers
>>> than available
>>>         "movq       (%2), %%mm5 \n"
>>>         ^
>>> 2 errors generated.
>>
>> If this is on OpenBSD or equivalent, you are running out of registers,
>> due to PIC, and possibly stack realignment.  If you try to compile this
>> without PIC, it will most likely work.  This is what is used for the
>> FreeBSD port on i386.
>
> The OS isn't a factor in this issue. It's the architecture and the way
> the ASM code is written. You can't build a shared library without PIC.
> I can quite clearly see this is not the case for FreeBSD/i386.

You can build a shared library without PIC on x86_32. In fact, x264
doesn't support PIC on x86_32; you can pass -fPIC to the C compiler, but
our yasm code will still be non-PIC. Just live with the textrels.

Otoh, gcc works with -fPIC. I can confirm that 5 registers is enough for
the inline asm blocks in question. If clang thinks they need more than 5
registers, that's a bug in clang's register allocator.

--Loren Merritt


More information about the x264-devel mailing list