Difference between revisions of "Cross Compiling"

From CSCWiki
Jump to navigation Jump to search
Line 31: Line 31:
 
There are a few tools that are useful for building cross-packages:
 
There are a few tools that are useful for building cross-packages:
  
* Emdebuild: an architecture aware version of debuild.
+
* emdebuild: an architecture aware version of debuild.
* Dpkg-cross: a version of dpkg that allows you to install architecture-specific libraries in an isolated way. For example, dpkg-cross will build a package called libc6-mips-cross from the mips libc6 package. This cross package can then be installed alongside the mips cross-compiler.  
+
* dpkg-cross: a version of dpkg that allows you to install architecture-specific libraries in an isolated way. For example, dpkg-cross will build a package called libc6-mips-cross from the mips libc6 package. This cross package can then be installed alongside the mips cross-compiler.  
* Apt-cross: a front-end to dpkg-cross. It will automatically fetch and build cross packages.
+
* apt-cross: a front-end to dpkg-cross. It will automatically fetch and build cross packages.
  
 
= Sun4u =  
 
= Sun4u =  

Revision as of 16:53, 25 December 2007

Builder

Builder is a vserver that is used to build cross-compilers and cross-packages that that have --host=amd64. The current list of installed cross-compilers includes alpha, arm, hppa (binutils only), i486, ia64, m68k, mips, mipsel, powerpc, sparc and x86_64. www.emdebian.org builds a number of cross-compilers, which can be installed by adding the following lines to /etc/apt/sources.list:

deb http://mirror.csclub.uwaterloo.ca/emdebian/ stable main
deb-src http://mirror.csclub.uwaterloo.ca/emdebian/ stable main

Building a cross-compiler

  • export ARCH=architecture (arm, i386, etc...)
  • sudo apt-get install apt-cross dpkg-cross autoconf automake gawk flex bison debhelper devscripts cdbs fakeroot
  • apt-cross -a $ARCH -i linux-kernel-headers libc6 libc6-dev
  • apt-get source binutils gcc-4.1
  • cd binutils and run:
    • TARGET=$ARCH-linux-gnu fakeroot debian/rules binary-cross
  • sudo dpkg -i binutils-$ARCH-linux-gnu_*.deb
  • cd gcc-4.1 and run:
    • export GCC_TARGET=$ARCH
    • export DEB_CROSS_INDEPENDENT=yes
    • export WITHOUT_LANG=java,fortran,pascal,obj,obj-c++,ada,treelang
    • export DEB_CROSS_NO_BIARCH=yes
    • debian/rules control
    • dpkg-buildpackage -b -rfakeroot
  • sudo dpkg -i gcc-4.1-*.deb

It's generally useful to upload these built packages to the CSC debian repository. To do this you need to scp the .deb's over to debian.csclub and run 'rrr-includedeb deb-files...'.

Building a cross-package

There are a few tools that are useful for building cross-packages:

  • emdebuild: an architecture aware version of debuild.
  • dpkg-cross: a version of dpkg that allows you to install architecture-specific libraries in an isolated way. For example, dpkg-cross will build a package called libc6-mips-cross from the mips libc6 package. This cross package can then be installed alongside the mips cross-compiler.
  • apt-cross: a front-end to dpkg-cross. It will automatically fetch and build cross packages.

Sun4u

  • DEB_TARGET_GNU_TYPE=sparc-sun-solaris2.8
  • DEB_TARGET_ALIAS=sparc-sun-solaris2.8
  • DEB_TARGET_ARCH=sparc-sun-solaris2.8