ios - 如何交叉编译 GCC 以生成适用于 iOS 设备(arm、armv7)的 libgfortran?

标签 ios gcc fortran llvm cross-compiling

我需要编译 Fortran-77 子例程以便在 iOS 上访问。我将 GCC 与 DragonEgg 一起使用插件,因此我可以将 gfortran 与 LLVM 后端一起使用。我关注了this answer但在为 armv7、armv7s 和 arm64 构建 libgfortran 时,我遇到了困难。

  • 我可以单独构建 libgfortran 还是必须完全编译 GCC 套件?
  • 为不同的目标生成这个库的正确方法是什么?是否可以将 GCC 用于此步骤,或者我是否需要 LLVM 用于 arm*-targets?

使用 GCC 构建带有 arm-targets 的 GCC 我得到这些错误:

./configure --prefix=/tmp/out --host=arm-apple-darwin --enable-languages=fortran
make
…
make[2]: arm-apple-darwin-ar: No such file or directory
make[2]: *** [libiberty.a] Error 1
make[1]: *** [all-libiberty] Error 2

使用 LLVM 使用 arm-targets 构建 GCC 我在配置方面遇到问题:

export CC="$(xcrun -sdk iphoneos -find clang)"
export CPP="$CC -E"
export CFLAGS="-arch armv7 -arch armv7s -arch arm64 -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=9.2"
export AR=$(xcrun -sdk iphoneos -find ar)
export RANLIB=$(xcrun -sdk iphoneos -find ranlib)
export CPPFLAGS="-arch armv7 -arch armv7s -arch arm64 -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=9.2"
export LDFLAGS="-arch armv7 -arch armv7s -arch arm64 -isysroot $(xcrun --sdk iphoneos --show-sdk-path)"

./configure --prefix=/tmp/out --enable-languages=fortran --host=arm-apple-darwin --disable-shared
…
checking how to run the C preprocessor... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -E
configure: error: in `/Users/timo/temp/gcc-4.8.5-build/fixincludes':
configure: error: C preprocessor "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -E" fails sanity check
See `config.log' for more details.
make[1]: *** [configure-fixincludes] Error 1

配置脚本指出

configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
  • 如果检测到交叉编译器是什么意思?如何正确定义目标平台?
  • LLVM 使用-arch armv7 等作为目标定义。使用 GCC 时需要注意什么?

最佳答案

您正在尝试在没有交叉 binutils 的情况下构建跨 gcc 库。 Here是一个很好的为 arm 构建跨 gcc 的手册,你可以遵循它。

What is meant by If a cross compiler is detected? How do I define the target platform correctly?

配置时还应设置--target=arm-apple-darwin。 (根据我自己的经验,我根本没有设置 --host)

make[2]: arm-apple-darwin-ar: No such file or directory

在构建 arm 交叉编译器目标库之前,您应该为此目标构建 binutils。

不能说任何关于 llvm 的事情。

所以只需尝试完成上面链接中的所有步骤即可。

关于ios - 如何交叉编译 GCC 以生成适用于 iOS 设备(arm、armv7)的 libgfortran?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34974394/

相关文章:

c - C 中的 "dimension"和 "parameter"等效命令

android - ARM/Android 中的 Fortran 编译器

ios - transitionfromview 和 addsubview 的区别

ios - 在 UIImageView 中显示存储在 Firebase 存储(谷歌云)中的图像?

C - 读取和设置汇编寄存器

java - 发送/接收 MPI-Fortran-Java

ios - 如何在UIButton 的gradientLayer 前面设置图片和文字?

ios - 如何将 AWS 联合 token 与 AWS iOS SDK 2.0 一起使用

c - 如何在 C 中抑制 "unused parameter"警告?

android - 使用预编译 header 时 GCC 失败且没有消息