I'm getting error on compiling x264 for iOS.
I have Xcode Version 5.0 (5A1413) with Apple LLVM version 5.0 (clang-500.2.75) (based on LLVM 3.3svn). I'm compiling x264-snapshot-20130925-2245.
Config:
CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang ./configure \
--host=arm-apple-darwin \
--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk \
--prefix=armv7 \
--extra-cflags='-arch armv7' \
--extra-ldflags="-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/system -arch armv7" \
--enable-pic \
--enable-static
Getting error:
common/arm/cpu-a.S:29:7: error: unknown token in expression
.align
^
common/arm/cpu-a.S:139:5: error: instruction 'suble' can not set flags, but 's' suffix specified
subles ip, ip, #1
^
The relevant change in the Xcode 5 toolchain is that the LLVM compiler now defaults to using the built-in assembler, and the built-in assembler requires more strict adherence to the ARM Unified Assembly Language.
There are two ways to get it to compile with the Xcode 5 toolchain:
Give clang the flag -no-integrated-as. Adding it to --extra-cflags ought to work. (The flag worked for me compiling individual files but I never worked it into configure.) Consider this a workaround.
Fix the assembly source code in x264's common/arm subdirectory. This is pretty easy actually, and it's what I did. This is the right fix. BTW, I'm about to submit a patch to x264 with these changes.
The assembler emits many errors and they fall into four categories:
In cpu-a.S, the ".align" directive should be ".align 2". (Apparently it used to default to 2, now the 2 must be explicit.)
Several subles and sublts instructions in multiple files. These are variants of "sub" (subtract), followed by a condition (2 characters) and the "s" suffix. Now the "s" has to precede the condition. Thus "subles" => "subsle" and "sublts" => "subslt".
A fair number of ldrd instructions in various files. This instruction means "load register, double (from memory)". It loads 2 32-bit words from memory into registers. It used to be OK to name only the first register; now both need to be named. They're always adjacent. So "ldrd r2, whatever" needs to become "ldrd r2, r3, whatever". "ldrd r6, something" becomes "ldrd r6, r7, something". Etc.
In pixel-a.S, there's an instruction "vmov.32 r0, r1, d0". This is incorrect. vmov.32 means move a 32-bit quantity, yet the arguments say to move d0 (64 bits) into r0 and r1. Apparently the old compiler took the ".32" part as a hint. I believe it should be "vmov r0, r1, d0" and that change works for me - but I don't have absolute proof that is the correct instruction.
Many thanks to gparker on the Apple Developer Forum! I could not have figured this out without his/her help. Link to forum discussion, Apple ID required.
So far the only solution seems to be --disable-asm
.
I think disabling assembler optimizations is a bad solution.
After a long research I've found the root of the problem: clang during assembler compilation uses ASFLAGS not CFLAGS, so adding --extra-asflags="-arch armv7" solves the problem
./configure \
--host=arm-apple-darwin \
--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \
--prefix=armv7 \
--extra-cflags="-arch armv7" \
--extra-asflags="-arch armv7" \
--extra-ldflags="-arch armv7" \
--enable-pic \
--enable-static
NOTE: For bitcode support just add -fembed-bitcode
to all extra flags parameters