gpt4 book ai didi

ios - 为 arm64 iOS 构建 C 库 (GMP)

转载 作者:可可西里 更新时间:2023-11-01 04:02:09 25 4
gpt4 key购买 nike

我正在尝试为 arm64 构建一个用于 iOS 的 C 库 (GMP 6.0.0)。我正在使用下面的调用运行配置脚本(编译器是使用 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

然而,这在以下行(“long long reliability test 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 . long long long reliability test compile显示多个warning和error,包括:

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();}}
^

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

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

感谢任何帮助。

编辑 1

针对 ARMv7 的编译通过配置,但在 make 上失败(完整配置/make 输出 here ),显然是在编译某些程序集时:

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

编辑 2

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

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

作为旁注:these commits ,我假设旨在消除抑制错误的需要,但似乎不起作用,即在去除抑制时我得到了同样的错误。

对于 armv7,使用 these commits按照建议修复 .section 错误,但稍后 make 失败并显示以下内容(完整输出 here ):

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

编辑 3

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

对于 arm64,编辑使其克服了先前的错误,但现在给出了几个关于无效输入约束“rZ”的错误,所有错误都在同一个文件中(完整输出 here):

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)

编辑 4

在 longlong.h 中注释掉 add_ssaaaasub_ddmmss 并在 gcd_1.asm 中编辑更多汇编指令(blo b.lo 等),它现在失败并出现以下几个错误(完整输出 here ):

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
^

稍后我会发布一个总差异。

编辑 5

好的,这让我们更进一步,但它现在进入(完整输出 here):

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

关于ios - 为 arm64 iOS 构建 C 库 (GMP),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22754077/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com