为arm64 iOS构建C库(GMP) [英] Building a C library (GMP) for arm64 iOS

查看:1482
本文介绍了为arm64 iOS构建C库(GMP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图构建一个C库(GMP 6.0.0)for arm64在iOS上使用。我运行configure脚本与下面的调用(编译器是找到使用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)失败:

 code>检查编译器/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可靠性测试1 
configure:错误:找不到工作编译器,详细信息请参阅config.log

完整config.log可用此处。它显示长期可靠性测试编译的多个警告和错误,包括以下内容:

  conftest.c:9:警告:缺少类型说明符,默认为'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:C99中函数'h'的隐含声明无效[-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] ,got,d [i] .want,9); if(d [i] .n)h();}}
^
conftest.c:10:48:函数'g'在C99中是无效的[-Werror,-Wimplicit-function-declaration]
for(i = 0; i <1; i ++){if(e,got, .n)== 0)h(); g(i,d [i] .src,d [i] .n,got,d [i] .want,9) h();}}
^
conftest.c:10:100:warning:控制到达非空函数的结束[-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] ,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),早期的'11 Core i7 MBP运行操作系统X v10.9.2。我使用Xcode 5.1(5B130a)。



任何帮助。



/ strong>



编译ARMv7传递配置,但在make上失败(完全配置/ make输出 here ),显然在编译一些程序集时:

  tmp-dive_1.s: 18:错误:'.section'指令中的意外标记
.section .rodata
^


$ b b

EDIT 2



@MarcGlisse:强制clang忽略建议的错误(-Wno-...)arm64 configure,but then fail on make(full output here ):

  tmp-mul_1.s:59:2:错误:无法识别的指令助记符
bcc Lfi1
^
tmp-mul_1.s: 2:错误:无法识别的指令助记符
beq Lfi2
^

作为旁注:这些提交,我假设意在消除抑制错误的需要



对于armv7,使用这些提交建议修复.section错误,但使以下失败(完整输出 here ):

  tmp-mode1o.s :64:2:错误:未知指令
.protected ___gmp_binvert_limb_table
^

EDIT 3



使用建议的编辑,armv7,armv7s,i386和x86_64现在全部使用汇编编译!



对于arm64,编辑会得到它以前的错误,但现在给出几个错误有关无效的输入约束'rZ',所有在同一个文件(完整输出 here ):

  divrem_1.c:237:错误:无效的输入约束'rZ'在asm 
udiv_qrnnd_preinv(* qp,r,r,nshift,d,dinv);
^
../gmp-impl.h:3062:2:注意:从宏'udiv_qrnnd_preinv'扩展
add_ssaaaa(_qh,_ql,_qh,_ql,(nh) (nl)); \
^
../longlong.h:551:7:注意:从宏'add_ssaaaa'扩展
:rZ(ah),rZ(bh) %r(al),rI(bl)__CLOBBER_CC)





注释掉 add_ssaaaa sub_ddmmss 并在gcd_1.asm( blo b.lo 等)中编辑一些更多的汇编指令,它现在失败,并出现以下错误(完整输出此处):

  tmp-invert_limb.s:75:22:error:移位器操作数的预期立即值
add x1,x1,x2,lsr 1
^
tmp-invert_limb.s:75:22:error:指令的操作数无效
add x1,x1,x2,lsr 1
^

稍后我会发布总差异。



EDIT 5



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

  tmp-invert_limb.s:52:2:error:ADR / ADRP relocations必须是GOT相对
adrp x1,approx_tab
^

解决方案

版权问题除外...



GMP可能与Apple的专有CPU不兼容,并且可能与Clang / LLVM不兼容。作为一个GNU项目,它可能在非专有芯片组上使用GCC进行更彻底的测试。



一个快速搜索显示历史上至少出现了使用clang编译GMP的问题。 / p>

您应该通过电子邮件联系GMP社区并请求帮助。


I'm trying to build a C library (GMP 6.0.0) for arm64 for use on iOS. I'm running the configure script with the invocation below (compiler is as found using 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

However this fails at the following line ("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

Full config.log available here. It shows multiple warning and errors for the long long reliability test compile, including the following:

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 it works fine, but I'd really like to figure out how to build it with assembly optimized for arm64.

My system is x86_64-apple-darwin13.1.0 (or coreisbr-apple-darwin13.1.0 according to config.guess), an early '11 Core i7 MBP running OS X v10.9.2. I'm using Xcode 5.1 (5B130a).

Any help appreciated.

EDIT 1

Compiling for ARMv7 passes configure, but fails on make (full configure/make output here), apparently while compiling some assembly:

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

EDIT 2

@MarcGlisse: By forcing clang to ignore the errors as suggested (-Wno-...) arm64 passes configure, but then fails on make (full output 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
 ^

As a side note: these commits, I assume intended to remove the need for suppressing the error, don't seem to work i.e. I get the same error when removing the supression.

For armv7, using these commits as suggested fixes the .section error, but make fails later on with the following (full output here):

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

EDIT 3

Using the suggested edits, armv7, armv7s, i386 and x86_64 now all compile with assembly!

For arm64 the edits get it past the previous error, but now gives several errors about an invalid input constraint 'rZ', all in the same file (full output 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)

EDIT 4

After commenting out add_ssaaaa and sub_ddmmss in longlong.h and editing some more assembly instructions in gcd_1.asm (blo to b.lo etc.), it now fails with several of the following errors (full output 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
                     ^

I'll post a total diff later.

EDIT 5

Ok, that gets us another step further, but it now hits into (full output here):

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

If this keeps going it might be better to continue this via email.

解决方案

Copyright issues aside...

GMP may not be compatible with Apple's proprietary CPU, and may not be compatible with Clang/LLVM. Being a GNU project it is probably more thoroughly tested with GCC on non-proprietary chipsets.

A quick search shows historically at least there have been issues compiling GMP with clang.

You really should email the GMP community and ask for help on this one.

这篇关于为arm64 iOS构建C库(GMP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆