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

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

问题描述

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

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

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

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

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

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

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

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

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

感谢任何帮助.

编辑 1

ARMv7 编译通过配置,但在 make 上失败(完整配置/make 输出 此处),显然是在编译时一些组装:

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
                 ^

编辑 2

@MarcGlisse:通过强制 clang 按照建议忽略错误 (-Wno-...) arm64 通过配置,但在 make 时失败(完整输出 此处):

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

对于 armv7,使用 这些提交作为建议修复了 .section 错误,但使稍后失败并显示以下内容(完整输出 此处):

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
 ^

编辑 3

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

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

对于 arm64 的编辑使其超过了之前的错误,但现在给出了几个关于无效输入约束 'rZ' 的错误,所有错误都在同一个文件中(完整输出 此处):

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)

编辑 4

在 longlong.h 中注释掉 add_ssaaaasub_ddmmss 并在 gcd_1.asm(blob.lo 等),它现在失败并出现以下几个错误(完整输出 here):

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.

编辑 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.

推荐答案

版权问题不谈...

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

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.

快速搜索显示,至少从历史上看,使用 clang 编译 GMP 存在问题.

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

您真的应该给 GMP 社区发送电子邮件,并就此寻求帮助.

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

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

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