Build the toolchain on Leopard for Aspen

(iPhone v1.2/2.0 Firmware)

Credits: Saurik (Aspen modifications to compiler, general build flag hackery), NerveGas (some header file maintenance), Drudge (original Leopard-ized instructions)

Verify build tools

Ensure that you have a copy of bison and flex installed on your system. All major systems should have these tools installed or available in package management systems.

$ bison --version
GNU Bison version 1.28
$ flex --version
flex version 2.5.4

Get source for 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 llvm-svn -r 42498
pushd llvm-svn
./configure --enable-optimized
sudo make install

Check out a copy of the iphone-dev SVN repository.

svn checkout iphone-dev
pushd iphone-dev

Switch your odcctools and include directories to use the special Aspen versions:

      pushd include
      svn switch
      pushd odcctools
      svn switch

Make a directory to hold the toolchain.

sudo mkdir -p /usr/local/arm-apple-darwin

Build odcctools

mkdir -p build/odcctools
pushd build/odcctools
../../odcctools/configure --target=arm-apple-darwin --disable-ld64
export INCPRIVEXT="-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
sudo make install

Point your frameworks directory to the Aspen SDK

Set the environment variable $HEAVENLY to point to the Aspen SDK:

      sudo mkdir -p /usr/local/share
      sudo ln -s /Developer/Platforms/Aspen.platform/Developer/SDKs/Aspen1.2.sdk /usr/local/share/iphone-filesystem

Or if you are not so inclined to install the Apple SDK, these files can be copied directly from an iPhone running a firmware version matching your target. You can use SCP to fetch them, and place them in the traditional location:


Patch the system headers

pushd include
./configure --with-macosx-sdk=/Developer/SDKs/MacOSX10.4u.sdk
sudo bash

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

Configure and make LLVM-GCC

Make sure that $LLVMOBJDIR and $HEAVENLY are set per the instructions above.

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
sudo ln -s /usr/local/arm-apple-darwin/lib/crt1.o \/usr/local/arm-apple-darwin/lib/crt1.10.5.o
mkdir -p build/llvm-gcc-4.0-iphone
pushd build/llvm-gcc-4.0-iphone
export FLAGS_FOR_TARGET="-mmacosx-version-min=10.1"
sh ../../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 \
make LLVM_VERSION_INFO=2.0-svn-iphone-dev-0.3-svn
sudo make install

You're done. Be sure to use these extra CFLAGS when building:

      CFLAGS =  -F/Developer/Platforms/Aspen.platform/Developer/SDKs/Aspen1.2.sdk/System/Library/Frameworks \
         -F/Developer/Platforms/Aspen.platform/Developer/SDKs/Aspen1.2.sdk/System/Library/PrivateFrameworks \
         -fobjc-abi-version=2 \


NerveGas (based on Drudge's original docs)

howto/toolchain_on_leopard_aspen.txt · Last modified: 2008/06/04 00:25 (external edit)
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Part of the iPhone Dev Team Archive