如何交叉编译GCC以生成iOS设备的libgfortran(arm,armv7)?

tim*_*nen 6 gcc fortran llvm cross-compiling ios

我需要编译Fortran-77子程序才能在iOS上访问.我正在使用GCC和DragonEgg插件,因此我可以将gfortran与LLVM后端一起使用.我按照这个答案但是在为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
Run Code Online (Sandbox Code Playgroud)

使用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
Run Code Online (Sandbox Code Playgroud)

配置脚本说明了这一点

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.
Run Code Online (Sandbox Code Playgroud)
  • 如果检测到交叉编译器是什么意思?如何正确定义目标平台?
  • LLVM使用-arch armv7等作为目标定义.使用GCC时什么是结合?

ale*_*ius 2

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

如果检测到交叉编译器是什么意思?如何正确定义目标平台?

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

make[2]: arm-apple-darwin-ar: No such file or directory
Run Code Online (Sandbox Code Playgroud)

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

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

因此,请尝试执行上面链接中的所有步骤。