emdebian logo
 

About Emdebian
 Emdebian & Debian
 Purpose
 Customisations
 Tdeb support

Cross toolchains
 Toolchain packages

Packages
 Root Filesystem
 Build Tools
 Target packages
 Autobuild Report
 Repository Key  Crossbuild bugs

Documentation
 Introductory Guide
 Emdebian Wiki
 Emdebian FAQ
 Packaging rules
 Packaging infrastructure
 Packaging guideline
 DebConf paper

Support
 Contact Us
 Mailing List Archives

Help Emdebian
 Developers' Info
 Subversion
 ToDo list

News

History
 Slind
 Stag
 Emdebsys

Links
 Emdebian Bootldr
 Emdebian Kernel
 Emdebian JTAG
 Scratchbox
 QEmu
 CELF

Valid HTML 4.01!

 
   

Embedded Debian Cross Development Environments


Emdebian toolchain building Howto

Below is documented the build process for building cross-toolchains the 'Debian Way'. You only need to do this if the pre-built binary toolchains do not satisfy your needs for some reason.

We use the buildcross script to build the toolchains but this is probably overkill for most individual users. (buildcross replaces the old compbuildscript.)

To build your own toolchains, please consider using emchain from the emdebian-tools package. This takes care of downloading the sources, installing the necessary arch-specific packages (glibc, kernel headers) and building the compilers. It is essentially a script implementing what is described below.


Notation and exactly what things are called is important otherwise there can be much confusion, so we will clarify:

When building toolchains:

build == host

Build     machine installing the cross compiler       build
Host      machine running the cross compiler          host
Target    machine for which the compiler builds code  target

When building packages:

build != host

build     machine running the cross compiler           build
host      machine running the built package            handheld device
there is no particular meaning for 'target'.

Building your own toolchain is not a trivial matter, although this method is actually quite strightforward.

  • gcc-4.2 and later

    First get all the necessary build dependencies:

    $ apt-get install dpkg-cross apt-cross fakeroot dpatch gawk flex realpath automake1.7 debhelper cdbs

    This is not a complete list, of course you need gcc, but these are the most often forgotten ones.

    Get the necessary sources :

    $ apt-get source gcc-4.2 binutils glibc

    $ cd binutils-2.x
    $ TARGET=arch-linux fakeroot debian/rules binary-cross (replace arch by arm, alpha,...)

    Once the build is finished you have to install the package that was created with dpkg -i

    For the next step you can use the existing Debian packages for your target architecture, after converting them with dpkg-cross, for the kernel-headers, and the related architectures

    Download, convert and install the packages for libdb1-compat, libc6, libc6-dev and linux-libc-dev for your target architecture.

    $ apt-cross -a arch -v -i package

    When this process was succesful, we start with the last steps. We have to build the actual compiler.

    $ export GCC_TARGET=arch (replace arch trough arm, alpha,...)
    $ cd gcc-4.2-x
    $ debian/rules control
    $ dpkg-buildpackage -b -rfakeroot

    After a succesful build, install the newly created gcc packages with dpkg -i package-name. These are (for arm):

    • libstdc++6-0-arm-cross_4.2.x_all.deb
    • libstdc++6-0-dev-arm-cross_4.2.x_all.deb
    • libstdc++6-0-pic-arm-cross_4.2.x_all.deb
    • g++-4.2-arm-linux_4.2.x_i386.deb
    • gcc-4.2-arm-linux_4.2.x_i386.deb
    • cpp-4.2-arm-linux_4.2.x_i386.deb
    • libgcc1-arm-cross_4.2.x_all.deb
    • gcc-4.2-arm-linux-gnu-base_4.2.x_i386.deb

    Now you should have a brand new cross-compiler at your disposal.

  • gcc-3.x

    This one is valid for gcc-3.4 and should work with the following releases too, because the patches have been accepted in mainstream Debian.

    First get all the necessary build dependencies:

    $ apt-get install dpkg-cross fakeroot dpatch autoconf2.13 gawk flex realpath automake1.7 debhelper cdbs

    This is not a complete list, of course you need gcc, but these are the most often forgotten ones.

    Get the necessary sources :

    $ apt-get source gcc-3.4 binutils libc

    If you have binutils < 2.16.1cvs20060413-1, you have to get the patch for binutils at bugs.debian.org. It can also be found here and it is called binutils-cross-2.15-6.patch. Apply it before building binutils prior to version 2.16.1cvs20060413-1.

    $ patch -p0 < binutils-cross-2.15-6.patch
    $ cd binutils-2.15
    $ TARGET=arch-linux fakeroot debian/rules binary-cross (replace arch by arm, alpha,...)

    Once the build is finished you have to install the package that was created with dpkg -i

    For the next step you can use the existing Debian packages for your target architecture, after converting them with dpkg-cross, for the kernel-headers, and the related architectures

    Find the packages for libdb1-compat, libc6, libc6-dev and linux-kernel-headers for your target architecture. Either through packages.debian.org or a Debian mirror. Then convert and install them.

    $ dpkg-cross -b -a arch package
    $ dpkg -i converted-package

    When this process was succesful, we start with the last steps. We have to build the actual compiler. (note: gcc-3.3 needs an older flex than gcc-3.4)

    $ export DEB_CROSS_INDEPENDENT=yes (for gcc >= 4.1 and possibly earlier)
    $ cd gcc-3.4-3.4.2
    $ debian/rules control
    $ dpkg-buildpackage -b -rfakeroot

    After a succesful build, install the newly created gcc packages with dpkg -i package-name. These are (for arm):

    • libstdc++6-0-arm-cross_3.4.2-3_all.deb
    • libstdc++6-0-dev-arm-cross_3.4.2-3_all.deb
    • libstdc++6-0-dbg-arm-cross_3.4.2-3_all.deb
    • libstdc++6-0-pic-arm-cross_3.4.2-3_all.deb
    • g++-3.4-arm-linux_3.4.2-3_i386.deb
    • gcc-3.4-arm-linux_3.4.2-3_i386.deb
    • cpp-3.4-arm-linux_3.4.2-3_i386.deb
    • libgcc1-arm-cross_3.4.2-3_all.deb
    • If using DEB_CROSS_INDEPENDENT with gcc-4.1, an extra package is created:
      • gcc-4.1-arm-linux-gnu-base_4.1.1-19_i386.deb
  • gcc-2.95

    The 2.95 toolchains do not have debian cross-building support, but emdebian did build some cross-tools of this vintage, which are still available here.

    Now you should have a brand new cross-compiler at your disposal.


See the emdebian contact page for information on contacting us.

Last Modified: Thu, Nov 29 02:00:35 UTC 2007
Copyright © 2000-2007 The Embedded Debian Project;
Emdebian is an offical subproject of Debian.