为arm64 iOS构建C库(GMP)

2024-02-21

我正在尝试为arm64 构建一个C 库(GMP 6.0.0)以在iOS 上使用。我正在使用下面的调用运行配置脚本(编译器是使用 xcrun --find 找到的)。

./configure \
CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" \
CPP="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -E" \
CPPFLAGS="-target arm64-apple-darwin -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/ -miphoneos-version-min=7.0" \
--host=aarch64-apple-darwin

然而,这在以下行失败(“长长可靠性测试 1”):

checking compiler /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -O2 -pedantic  -target arm64-apple-darwin -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/ -miphoneos-version-min=7.0... no, long long reliability test 1
configure: error: could not find a working compiler, see config.log for details

完整的 config.log 可用here http://pastebin.com/NpPkqv1D。它显示了长时间可靠性测试编译的多个警告和错误,包括以下内容:

conftest.c:9:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
f(){static const struct{t1 n;t1 src[9];t1 want[9];}d[]={{1,{0},{1}},};t1 got[9];int i;
^
conftest.c:10:44: error: implicit declaration of function 'h' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
for(i=0;i<1;i++){if(e(got,got,9,d[i].n)==0)h();g(i,d[i].src,d[i].n,got,d[i].want,9);if(d[i].n)h();}}
                                           ^
conftest.c:10:48: error: implicit declaration of function 'g' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
for(i=0;i<1;i++){if(e(got,got,9,d[i].n)==0)h();g(i,d[i].src,d[i].n,got,d[i].want,9);if(d[i].n)h();}}
                                               ^
conftest.c:10:100: warning: control reaches end of non-void function [-Wreturn-type]
for(i=0;i<1;i++){if(e(got,got,9,d[i].n)==0)h();g(i,d[i].src,d[i].n,got,d[i].want,9);if(d[i].n)h();}}
                                                                                                   ^

Using --host=none它工作正常,但我真的很想弄清楚如何使用针对arm64优化的程序集来构建它。

我的系统是 x86_64-apple-darwin13.1.0(或 coreisbr-apple-darwin13.1.0 根据 config.guess),是运行 OS X v10.9.2 的早期 '11 Core i7 MBP。我正在使用 Xcode 5.1 (5B130a)。

任何帮助表示赞赏。

EDIT 1

ARMv7 编译通过了配置,但 make 失败(完整配置/make 输出here http://pastebin.com/sNt69AUY),显然是在编译一些程序集时:

tmp-dive_1.s:165:18: error: unexpected token in '.section' directive
 .section .rodata
                 ^

EDIT 2

@MarcGlisse:通过强制 clang 忽略建议的错误(-Wno-...)arm64 通过配置,但随后在 make 上失败(完整输出here http://pastebin.com/YexW0XTi):

tmp-mul_1.s:59:2: error: unrecognized instruction mnemonic
 bcc Lfi1
 ^
tmp-mul_1.s:60:2: error: unrecognized instruction mnemonic
 beq Lfi2
 ^

作为旁注:这些提交 https://gmplib.org/repo/gmp/rev/c0353313902c,我假设打算消除抑制错误的需要,但似乎不起作用,即在消除抑制时我遇到了相同的错误。

对于armv7,使用这些提交 https://gmplib.org/repo/gmp/rev/38068aa8e307按照建议修复了 .section 错误,但稍后 make 失败,并显示以下内容(完整输出here http://pastebin.com/AsdjW4St):

tmp-mode1o.s:64:2: error: unknown directive
 .protected ___gmp_binvert_limb_table
 ^

EDIT 3

使用建议的编辑,armv7、armv7s、i386 和 x86_64 现在都使用汇编进行编译!

对于arm64,编辑让它过去了之前的错误,但现在给出了关于无效输入约束“rZ”的几个错误,所有这些错误都在同一个文件中(完整输出here http://pastebin.com/aw80EU9J):

divrem_1.c:237:5: error: invalid input constraint 'rZ' in asm
                  udiv_qrnnd_preinv (*qp, r, r, nshift, d, dinv);
                  ^
../gmp-impl.h:3062:2: note: expanded from macro 'udiv_qrnnd_preinv'
        add_ssaaaa (_qh, _ql, _qh, _ql, (nh) + 1, (nl));                \
        ^
../longlong.h:551:7: note: expanded from macro 'add_ssaaaa'
           : "rZ" (ah), "rZ" (bh), "%r" (al), "rI" (bl) __CLOBBER_CC)

EDIT 4

注释掉后add_ssaaaa and sub_ddmmss在 longlong.h 中并在 gcd_1.asm 中编辑更多汇编指令(blo to b.lo等),它现在失败并出现以下几个错误(完整输出here http://pastebin.com/pC8hB0jW):

tmp-invert_limb.s:75:22: error: immediate value expected for shifter operand
 add x1, x1, x2, lsr 1
                     ^
tmp-invert_limb.s:75:22: error: invalid operand for instruction
 add x1, x1, x2, lsr 1
                     ^

我稍后会发布总差异。

EDIT 5

好吧,这让我们又向前迈进了一步,但现在它进入了(完整输出here http://pastebin.com/0Vn4sYKA):

tmp-invert_limb.s:52:2: error: ADR/ADRP relocations must be GOT relative
 adrp x1, approx_tab
 ^

如果这种情况持续下去,最好通过电子邮件继续。


“支持 ARM64 别名 Aarch64 别名 ARMv8”

https://gmplib.org/gmp6.0 https://gmplib.org/gmp6.0

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为arm64 iOS构建C库(GMP) 的相关文章

随机推荐