iphone app 开发:HOWTO build the toolchain for Iphone-dev

http://code.google.com/p/iphone-dev/wiki/Building

 

Building
How to build the toolchain.

Please note that these instructions are subject to change. Before updating your toolchain installation, you should always check the newest version of this page. You should also check Portability to see whether there are any special instructions for your particular platform.

FILE BUG REPORTS TO REPORT BUGS INSTEAD OF LEAVING BUGS AS COMMENTS ON THIS PAGE! THIS MEANS THAT IF THE TOOLCHAIN DOES NOT BUILD FOR YOU, DO NOT LEAVE A COMMENT HERE!

HOWTO build the toolchain

  • Check out a copy of LLVM SVN, and build a release build (as opposed to a debug one). Currently, due to Issue 70, we are limited to revision 42498.
    $ svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm-svn -r 42498
    $ pushd llvm
    -svn
    $
    ./configure --enable-optimized
    $ make ENABLE_OPTIMIZED
    =1
    $ sudo make install
    $ LLVMOBJDIR
    =`pwd`
    $ popd

    ubuntu 8.10下需要大这个patch
    Hi,

    If you still have this problem, here's a patch file that adds the includes and fixes
    the Pred1 duplicate param names.
    My system is 64-bit ubuntu 8.10 with g++ 4.2.3.

    Put this file in your home directory, switch to your svn working copy directory and run:

    patch -p0 -i ~/llvm_patch.diff

    Then run the make command again.
  • Check out a copy of the iphone-dev SVN repository.
    $ svn checkout http://iphone-dev.googlecode.com/svn/trunk/ iphone-dev
    $ pushd iphone
    -dev
  • Make a directory to hold the toolchain.
    $ sudo mkdir /usr/local/arm-apple-darwin
  • Build odcctools.
    $ mkdir -p build/odcctools
    $ pushd build
    /odcctools
    $
    ../../odcctools/configure --target=arm-apple-darwin --disable-ld64
    $ make
    $ sudo make install
    $ popd
  • Get a copy of the iPhone root filesystem. This is usually obtained by decrypting and extracting the iPhone restore software using these tools, but there are many other methods to obtain this, including simply using scp to download all the files from the iPhone over Wi-Fi. Unpack the root filesystem somewhere, and set the environment variable $HEAVENLY to its path.
    $ HEAVENLY=/usr/local/share/iphone-filesystem
  • Install the iPhone headers to the appropriate place. If you aren't on Mac OS X, replace the /Developer/SDKs/MacOSX10.4u.sdk path with the full path to the unpacked Mac OS X 10.4 Universal SDK. If you don't have a copy of this, see below.
    $ pushd include
    $
    ./configure --with-macosx-sdk=/Developer/SDKs/MacOSX10.4u.sdk
    $ sudo bash install
    -headers.sh
    $ popd
  • Install csu, which includes crt1.o, dylib1.o, and bundle1.o. Don't rebuild them from source, as this requires a working cross-GCC, which you don't have yet (and the build-from-source process for csu is broken right now anyway). Binaries are provided for this reason.
    $ mkdir -p build/csu
    $ pushd build
    /csu
    $
    ../../csu/configure --host=arm-apple-darwin
    $ sudo make install
    $ popd
  • Only if you are compiling on leopard 10.5. This is an ugly workaround and compiling with the resulting toolchain will give you a warning.
    $ mv llvm-gcc-4.0-iphone/configure llvm-gcc-4.0-iphone/configure.old
    $ sed
    's/^FLAGS_FOR_TARGET=$/FLAGS_FOR_TARGET=${FLAGS_FOR_TARGET-}/g' /
    llvm
    -gcc-4.0-iphone/configure.old > llvm-gcc-4.0-iphone/configure
    $
    export FLAGS_FOR_TARGET="-mmacosx-version-min=10.1"
    $ sudo ln
    -s /usr/local/arm-apple-darwin/lib/crt1.o /
    /usr/local/arm-apple-darwin/lib/crt1.10.5.o
  • Configure and make LLVM-GCC. Make sure that $LLVMOBJDIR and $HEAVENLY are set per the instructions above.
    $ mkdir -p build/llvm-gcc-4.0-iphone
    $ pushd build
    /llvm-gcc-4.0-iphone
    $
    ../../llvm-gcc-4.0-iphone/configure --enable-llvm=`llvm-config --obj-root` /
    --enable-languages=c,c++,objc,obj-c++ --target=arm-apple-darwin --enable-sjlj-exceptions /
    --with-heavenly=$HEAVENLY --with-as=/usr/local/bin/arm-apple-darwin-as /
    --with-ld=/usr/local/bin/arm-apple-darwin-ld --enable-wchar_t=no
    $ make LLVM_VERSION_INFO
    =2.0-svn-iphone-dev-0.3-svn
    $ sudo make install
    $ popd
    $ popd


    switch to gcc4.2 that help to get rid of buffer flow error.

    /usr/include/bits/fcntl2.h:51: error: call to '__open_missing_mode'
    declared with attribute error: open with O_CREAT in second argument
    needs 3 arguments

        这纯属软件bug,因为使用open函数的时候,如果在第二个参数中使用了
    O_CREAT,就必须添加第三个参数:创建文件时赋予的初始权限。而在gcc-3.3.6/gcc/的collect2.c文件中有漏掉第三个参数的错
    误,而gcc-4.3对语法错误的检查严格是出了名的(4.1就不会因此错误退出),所以就退出了。

        这也是可以解决的,就是在gcc-3.3.6/gcc/collect2.c中的第1575行改为:

    redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT, 0777);

        我还发现glibc-2.3.2/login/tst-grantpt.c也有一个类似错误,一起改过来,除后患。第44行:

    fd = open (file, O_RDWR | O_CREAT, 0777);
  • You're done. Have fun!

HOWTO obtain the Mac OS X headers on Linux or Windows

Gotchas

http://code.google.com/p/iphone-dev/issues/detail?id=65

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值