简体   繁体   中英

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

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

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:

    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.

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. However, make still outputs a x86_64 binary:(

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?
  2. Why are you so sure that the LD, RANLIB etc. of your host system are fine for cross-compilation? It will overwrite the auto-configured value of LD. (The line reading "export LD=ld" would be at fault here.)
  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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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