简体   繁体   English

我需要什么工具链来交叉编译Clang for iOS

[英]What toolchain do I need to cross-compile Clang for iOS

OK, so first of all I know that this can be compiled on iOS (armv7) because I read the documentation. 好的,首先我知道这可以在iOS(armv7)上编译,因为我阅读了文档。 However, I can't find the right toolchain. 但是,我找不到合适的工具链。

So, now, what toolchains I've already tried: 那么,现在,我已经尝试过哪些工具链:

i686-apple-darwin10-cpp-4.2.1
i686-apple-darwin10-g++-4.2.1
i686-apple-darwin10-gcc-4.2.1

The above cross-compiles to x86 (I'm on i386). 以上交叉编译为x86(我在i386上)。 Works fine. 工作正常。 But I don't need it 但我不需要它

arm-apple-darwin10-cpp-4.2.1
arm-apple-darwin10-g++-4.2.1
arm-apple-darwin10-gcc-4.2.1

The above compiles fine, but doesn't cross compile to arm as I would have expected, instead, it simply compiles to my current arch. 以上编译很好,但不会像我预期的那样交叉编译到arm,相反,它只是编译到我当前的arch。

I'm a real beginner in this matter, in fact this is my first attempt to cross-compile something. 我是这个问题的真正初学者,事实上这是我第一次尝试交叉编译。

UPDATE: 更新:

Here are the commands that I've tried(this is for armv6; armv7 is similar): 以下是我尝试过的命令(这是针对armv6; armv7类似):

configure: 配置:

../llvm/configure --host=arm-apple-darwin6 --target=arm-apple-darwin6 
--build=i386-apple-darwin --enable-optimized --disable-debug  
--disable-expensive-checks --disable-doxygen  --disable-threads

env vars: env vars:

    export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS$IOS_BASE_SDK.sdk

export CFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min=$IOS_DEPLOY_TGT -I$SDKROOT/usr/include/"

    export CPP="$DEVROOT/usr/bin/arm-apple-darwin10-cpp-4.2.1"
export CXX="$DEVROOT/usr/bin/arm-apple-darwin10-g++-4.2.1"
export CXXCPP="$DEVROOT/usr/bin/arm-apple-darwin10-cpp-4.2.1"
export CC="$DEVROOT/usr/bin/arm-apple-darwin10-gcc-4.2.1"
export LD=$DEVROOT/usr/bin/ld
export AR=$DEVROOT/usr/bin/ar
export AS=$DEVROOT/usr/bin/as
export NM=$DEVROOT/usr/bin/nm
export RANLIB=$DEVROOT/usr/bin/ranlib
export LDFLAGS="-L$SDKROOT/usr/lib/"

export CPPFLAGS=$CFLAGS
export CXXFLAGS=$CFLAGS

UPDATE : The purpose of this cross compile is to make an armv7(armv6) library not a command line tool. 更新:此交叉编译的目的是使armv7(armv6)库不是命令行工具。

YET ANOTHER UPDATE: I used the following: 再来一次更新:我使用了以下内容:

CC="$DEVROOT/usr/bin/clang"
CXX="$DEVROOT/usr/bin/clang++"

./llvm/configure --host=i386-apple-darwin --target=armv7-apple-darwin --build=armv7-apple-darwin --enable-optimized --disable-debug --disable-expensive-checks --disable-doxygen  --disable-threads --enable-targets=arm 

And I managed to get checking whether we are cross compiling... yes out of the configure tool. 我设法checking whether we are cross compiling... yesconfigure工具。 However, make still outputs a x86_64 binary:( 但是, make仍然输出x86_64二进制文件:(

In principle your configure invocation looks good. 原则上,您的配置调用看起来很好。 I'm trying to shoot a few typical mistakes: 我正试图拍摄一些典型的错误:

  1. Did you make clean after every change of architecture? 每次改变建筑后你make clean了吗?
  2. Why are you so sure that the LD, RANLIB etc. of your host system are fine for cross-compilation? 为什么你确定你的主机系统的LD,RANLIB等适合交叉编译? It will overwrite the auto-configured value of LD. 它将覆盖自动配置的LD值。 (The line reading "export LD=ld" would be at fault here.) (读取“export LD = ld”的行将在这里出错。)
  3. Could you check a typical compiler and a typical linker invocation in the output of make for their correct use of the cross-compilation tools? 您是否可以检查make输出中的典型编译器和典型链接器调用,以正确使用交叉编译工具?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM