Difference between revisions of "Toolchain"

From The iPhone Wiki
Jump to: navigation, search
(New page: The toolchain.)
 
Line 1: Line 1:
  +
iPhone Toolchain
The toolchain.
 
  +
Build iPhone Toolchain on Mac OS X Tiger
  +
  +
'''This is a brief description about how to install iPhone toolchain on Mac OS X Tiger.
  +
Needed Packages
  +
'''
  +
1. llvm source
  +
2. iphone-dev source
  +
3. iphone-filesystem
  +
  +
Put all the packages in your $HOME folder.
  +
How To Build
  +
  +
Make sure you’re running Mac OS X 10.4, and have installed Xcode development environment.
  +
1. Extract packages
  +
  +
$ cd ~
  +
$ tar xjvf llvm-svn.tar.bz2
  +
$ tar xjvf iphone-dev.tar.bz2
  +
$ cd /usr/local
  +
$ sudo tar xjvf ~/iphone-filesystem.tar.bz2
  +
$ sudo mkdir -p /usr/local/arm-apple-darwin
  +
$ LLVMOBJDIR=~/llvm-svn
  +
$ HEAVENLY=/usr/local/iphone-filesystem
  +
  +
2. Build LLVM
  +
  +
$ cd ~/llvm-svn
  +
$ ./configure --enable-optimized
  +
$ make ENABLE_OPTIMIZED=1
  +
$ sudo make install
  +
  +
3. Build odcctools
  +
  +
$ mkdir -p ~/iphone-dev/build/odcctools
  +
$ cd ~/iphone-dev/build/odcctools
  +
$ ../../odcctools/configure --target=arm-apple-darwin --disable-ld64
  +
$ make
  +
$ sudo make install
  +
  +
4. Install headers
  +
  +
$ cd ~/iphone-dev/include
  +
$ ./configure --with-macosx-sdk=/Developer/SDKs/MacOSX10.4u.sdk
  +
$ sudo bash install-headers.sh
  +
  +
5. Install csu (binary)
  +
  +
$ mkdir -p ~/iphone-dev/build/csu
  +
$ cd ~/iphone-dev/build/csu
  +
$ ../../csu/configure --host=arm-apple-darwin
  +
$ sudo make install
  +
  +
6. Build LLVM-GCC
  +
  +
$ mkdir -p ~/iphone-dev/build/llvm-gcc-4.0-iphone
  +
$ cd ~/iphone-dev/build/llvm-gcc-4.0-iphone
  +
$ ../../llvm-gcc-4.0-iphone/configure --enable-llvm=`llvm-config --objc-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
  +
$ make LLVM_VERSION_INFO=2.0-svn-iphone-dev-0.3-svn
  +
$ sudo make install
  +
  +
Done.
  +
Build iPhone Toolchain on Mac OS X Leopard
  +
  +
'''HOWTO build the toolchain for 1.1.1 on Leopard by drudge with pure ownage by lupinglade'''
  +
  +
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
  +
  +
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
  +
  +
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
  +
export INCPRIVEXT="-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
  +
$ 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. I would use the method describled here: http://www.touchdev.net/wiki/Jailbreak_Guide to get the dmg.
  +
  +
To unpack the root filesystem, mount the dmg, open terminal and run
  +
  +
$ sudo mkdir /usr/local/share/iphone-filesystem
  +
$ sudo cp -Rp /Volumes/Snowbird3A110a.N45Bundle/* /usr/local/share/iphone-filesystem/
  +
  +
Now, set the environment variable $HEAVENLY to its path:
  +
  +
$ HEAVENLY=/usr/local/share/iphone-filesystem
  +
  +
Patch the system headers
  +
  +
$ 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
  +
  +
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"
  +
../../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
  +
$ make LLVM_VERSION_INFO=2.0-svn-iphone-dev-0.3-svn
  +
$ sudo make install
  +
$ popd
  +
$ popd
  +
  +
You’re done. Have fun!
  +
  +
'''Build iPhone Toolchain on Windows XP'''
  +
  +
This guide and binary installation server is provided by David Supuran .
  +
If you have any questions, comments, or suggestions please visit irc.osx86.hu #iphone or email me at Darken@iPhoneGameover.com
  +
Requirements
  +
  +
/Developer/SDKs/MacOSX10.4u.sdk
  +
  +
To obtain this directory it is recommended that you download Xcode 2.5 Developer Tools (Disk Image) (902.9 MB as of 30 Oct 2007).
  +
  +
Once you have downloaded the disk image, you will need additional software to open and extract it such as '''PowerISO''', then extract the following file:
  +
  +
\Packages\Packages\MacOSX10.4.Universal.pkg\Contents\Archive.pax.gz
  +
  +
'''Note: It has been reported that UltraISO and MacDrive do not work for extracting this package.
  +
This archive provides the necessary header files which will later be installed for the compiler to use.'''
  +
  +
Note: Due to Apple’s strict redistribution license the files required from this archive could not be included in the installer, so you are required to agree to the terms and licenses under your ADC account and download the full disk image.
  +
  +
iPhone/iTouch root filesystem
  +
  +
The easiest way to obtain the root filesystem is to have a wireless network and OpenSSH installed. If you have this please skip this part as the post-installation will walk you through obtaining the files automatically. You may alternatively decrypt a firmware ipsw manually and place the extracted filesystem in /usr/local/arm-apple-darwin/filesystem after Cygwin is installed.
  +
Installation
  +
  +
Download and run the Cygwin Setup. It is recommended you use the default settings and click Next until you get to the following window:
  +
Cygwin Setup Step 6
  +
Type in the User URL: http://www.iphonegameover.com/cygwin, then click Add.
  +
  +
Once you see the URL added and highlighted in the Available Download Sites list click Next.
  +
Cygwin Setup Step 7
  +
All the software is selected for you; it is recommended you use the default settings and click Next, then follow the on-screen instructions to finish the setup.
  +
Cygwin Setup Step 8
  +
Click the Start button and select All Programs -> Cygwin -> Cygwin Bash Shell and you will see the following window:
  +
Cygwin Setup Step 9
  +
Place the Archive.pax.gz file in your Cygwin home directory that you obtained earlier from the Xcode 2.5 Developer Tools (Disk Image). Example home directory: C:\cygwin\home\Administrator
  +
  +
When asked ‘Do you wish to connect to your device and download the required files?‘ Press y for Yes.
  +
  +
Type in the IP address of your iPhone / iTouch device on the next prompt that says ‘Please enter the remote IP address of your device:‘.
  +
  +
*Note: If you do not know the IP address of your device go to Settings -> Wi-Fi and Click the blue arrow to the right of your wireless network you are currently connected to which is marked with a check on the left.
  +
  +
If SSH asks you ‘Are you sure you want to continue connecting (yes/no)?‘ Type yes.
  +
Cygwin Setup Step 10
  +
NOTE: SSH will now create an archive of your root file system once you type in your password which takes approximately 5 minutes, so please be patient.
  +
  +
If you are asked ‘Do you wish to install the XCode header files now?‘ Press y for Yes.
  +
If you have been following the instructions so far, you will see the following:
  +
  +
Found Archive.pax.gz in current directory.
  +
Extracting /home/David/Archive.pax.gz…
  +
  +
If everything goes well you will see:
  +
  +
Your toolchain installation is now complete!

Revision as of 12:43, 28 July 2008

iPhone Toolchain Build iPhone Toolchain on Mac OS X Tiger

This is a brief description about how to install iPhone toolchain on Mac OS X Tiger. Needed Packages

   1. llvm source
   2. iphone-dev source
   3. iphone-filesystem

Put all the packages in your $HOME folder. How To Build

Make sure you’re running Mac OS X 10.4, and have installed Xcode development environment. 1. Extract packages

   $ cd ~
   $ tar xjvf llvm-svn.tar.bz2
   $ tar xjvf iphone-dev.tar.bz2
   $ cd /usr/local
   $ sudo tar xjvf ~/iphone-filesystem.tar.bz2
   $ sudo mkdir -p /usr/local/arm-apple-darwin
   $ LLVMOBJDIR=~/llvm-svn
   $ HEAVENLY=/usr/local/iphone-filesystem

2. Build LLVM

   $ cd ~/llvm-svn
   $ ./configure --enable-optimized
   $ make ENABLE_OPTIMIZED=1
   $ sudo make install

3. Build odcctools

   $ mkdir -p ~/iphone-dev/build/odcctools
   $ cd ~/iphone-dev/build/odcctools
   $ ../../odcctools/configure --target=arm-apple-darwin --disable-ld64
   $ make
   $ sudo make install

4. Install headers

   $ cd ~/iphone-dev/include
   $ ./configure --with-macosx-sdk=/Developer/SDKs/MacOSX10.4u.sdk
   $ sudo bash install-headers.sh

5. Install csu (binary)

   $ mkdir -p ~/iphone-dev/build/csu
   $ cd ~/iphone-dev/build/csu
   $ ../../csu/configure --host=arm-apple-darwin
   $ sudo make install

6. Build LLVM-GCC

   $ mkdir -p ~/iphone-dev/build/llvm-gcc-4.0-iphone
   $ cd ~/iphone-dev/build/llvm-gcc-4.0-iphone
   $ ../../llvm-gcc-4.0-iphone/configure --enable-llvm=`llvm-config --objc-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
   $ make LLVM_VERSION_INFO=2.0-svn-iphone-dev-0.3-svn
   $ sudo make install

Done. Build iPhone Toolchain on Mac OS X Leopard

HOWTO build the toolchain for 1.1.1 on Leopard by drudge with pure ownage by lupinglade

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

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

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
   export INCPRIVEXT="-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
   $ 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. I would use the method describled here: http://www.touchdev.net/wiki/Jailbreak_Guide to get the dmg.

To unpack the root filesystem, mount the dmg, open terminal and run

   $ sudo mkdir /usr/local/share/iphone-filesystem
   $ sudo cp -Rp /Volumes/Snowbird3A110a.N45Bundle/* /usr/local/share/iphone-filesystem/

Now, set the environment variable $HEAVENLY to its path:

   $ HEAVENLY=/usr/local/share/iphone-filesystem

Patch the system headers

   $ 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

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"
    ../../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
   $ make LLVM_VERSION_INFO=2.0-svn-iphone-dev-0.3-svn
   $ sudo make install
   $ popd
   $ popd

You’re done. Have fun!

Build iPhone Toolchain on Windows XP

This guide and binary installation server is provided by David Supuran . If you have any questions, comments, or suggestions please visit irc.osx86.hu #iphone or email me at Darken@iPhoneGameover.com Requirements

/Developer/SDKs/MacOSX10.4u.sdk

To obtain this directory it is recommended that you download Xcode 2.5 Developer Tools (Disk Image) (902.9 MB as of 30 Oct 2007).

Once you have downloaded the disk image, you will need additional software to open and extract it such as PowerISO, then extract the following file:

   \Packages\Packages\MacOSX10.4.Universal.pkg\Contents\Archive.pax.gz

Note: It has been reported that UltraISO and MacDrive do not work for extracting this package. This archive provides the necessary header files which will later be installed for the compiler to use.

Note: Due to Apple’s strict redistribution license the files required from this archive could not be included in the installer, so you are required to agree to the terms and licenses under your ADC account and download the full disk image.

iPhone/iTouch root filesystem

The easiest way to obtain the root filesystem is to have a wireless network and OpenSSH installed. If you have this please skip this part as the post-installation will walk you through obtaining the files automatically. You may alternatively decrypt a firmware ipsw manually and place the extracted filesystem in /usr/local/arm-apple-darwin/filesystem after Cygwin is installed. Installation

Download and run the Cygwin Setup. It is recommended you use the default settings and click Next until you get to the following window: Cygwin Setup Step 6 Type in the User URL: http://www.iphonegameover.com/cygwin, then click Add.

Once you see the URL added and highlighted in the Available Download Sites list click Next. Cygwin Setup Step 7 All the software is selected for you; it is recommended you use the default settings and click Next, then follow the on-screen instructions to finish the setup. Cygwin Setup Step 8 Click the Start button and select All Programs -> Cygwin -> Cygwin Bash Shell and you will see the following window: Cygwin Setup Step 9 Place the Archive.pax.gz file in your Cygwin home directory that you obtained earlier from the Xcode 2.5 Developer Tools (Disk Image). Example home directory: C:\cygwin\home\Administrator

When asked ‘Do you wish to connect to your device and download the required files?‘ Press y for Yes.

Type in the IP address of your iPhone / iTouch device on the next prompt that says ‘Please enter the remote IP address of your device:‘.

  • Note: If you do not know the IP address of your device go to Settings -> Wi-Fi and Click the blue arrow to the right of your wireless network you are currently connected to which is marked with a check on the left.

If SSH asks you ‘Are you sure you want to continue connecting (yes/no)?‘ Type yes. Cygwin Setup Step 10 NOTE: SSH will now create an archive of your root file system once you type in your password which takes approximately 5 minutes, so please be patient.

If you are asked ‘Do you wish to install the XCode header files now?‘ Press y for Yes. If you have been following the instructions so far, you will see the following:

   Found Archive.pax.gz in current directory.
   Extracting /home/David/Archive.pax.gz…

If everything goes well you will see:

   Your toolchain installation is now complete!