【问题标题】:Compiling x264 for iOS 7为 iOS 7 编译 x264
【发布时间】:2013-10-02 08:35:09
【问题描述】:

我在为 iOS 编译 x264 时遇到错误。

我有 Xcode 版本 5.0 (5A1413) 和 Apple LLVM 版本 5.0 (clang-500.2.75)(基于 LLVM 3.3svn)。我正在编译 x264-snapshot-20130925-2245。

配置:

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

得到错误:

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
    ^

【问题讨论】:

    标签: ios compiler-errors ffmpeg clang x264


    【解决方案1】:

    到目前为止,唯一的解决方案似乎是--disable-asm

    【讨论】:

      【解决方案2】:

      Xcode 5 工具链的相关变化是 LLVM 编译器现在默认使用内置汇编器,而内置汇编器需要更严格地遵守 ARM 统一汇编语言。

      有两种方法可以让它使用 Xcode 5 工具链进行编译:

      1. 给 clang 标志 -no-integrated-as。将其添加到 --extra-cflags 应该可以工作。 (该标志对我编译单个文件有用,但我从未将其用于配置。)考虑这是一种解决方法。

      2. 修复 x264 的 common/arm 子目录中的汇编源代码。这实际上很容易,这就是我所做的。这是正确的解决方法。顺便说一句,我即将提交一个包含这些更改的 x264 补丁。

      汇编程序发出许多错误,它们分为四类:

      • 在 cpu-a.S 中,“.align”指令应该是“.align 2”。 (显然它曾经默认为 2,现在 2 必须是显式的。)

      • 多个文件中的多个 subles 和 sublts 指令。这些是“sub”(减法)的变体,后跟一个条件(2 个字符)和“s”后缀。现在“s”必须在条件之前。因此 "subles" => "subsle" 和 "sublts" => "subslt"。

      • 各种文件中有相当数量的 ldrd 指令。该指令的意思是“加载寄存器,双倍(从内存)”。它将 2 个 32 位字从内存加载到寄存器中。以前只命名第一个寄存器是可以的;现在两者都需要命名。它们总是相邻的。所以“ldrd r2,whatever”需要变成“ldrd r2,r3,whatever”。 “ldrd r6, something”变成了“ldrd r6, r7, something”。等等。

      • 在 pixel-a.S 中,有一条指令“vmov.32 r0, r1, d0”。这是不正确的。 vmov.32 表示移动 32 位量,但参数说将 d0(64 位)移动到 r0 和 r1。显然,旧编译器将“.32”部分作为提示。我相信它应该是“vmov r0, r1, d0”并且这种改变对我有用 - 但我没有绝对的证据表明这是正确的指令。

      非常感谢 Apple 开发者论坛上的 gparker!没有他/她的帮助,我无法弄清楚这一点。 Link to forum discussion, Apple ID required.

      【讨论】:

        【解决方案3】:

        我认为禁用汇编程序优化是一个糟糕的解决方案。

        经过长时间的研究,我找到了问题的根源:汇编程序编译期间的clang使用ASFLAGS而不是CFLAGS,因此添加--extra-asflags="-arch armv7" 解决了问题

        ./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
        

        注意:对于位码支持,只需将-fembed-bitcode 添加到所有额外的标志参数中

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-12-06
          • 1970-01-01
          相关资源
          最近更新 更多