Differences between revisions 44 and 45
Revision 44 as of 2014-10-23 02:17:05
Size: 3498
Editor: ?dima
Comment:
Revision 45 as of 2014-11-27 03:58:51
Size: 1974
Editor: wookey
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
#language en
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: none-~
----
<<TableOfContents()>>
Crosstoolchain documentation is now collected on CrossToolchains
Line 6: Line 3:
= Notice = == Building a Cross Compiler ==
Line 8: Line 5:
Please note that most of this page is out-of-date. Emdebian toolchains are no longer supported, and [[MultiarchCrossToolchainBuild|multi-arch]] toolchains are the future. Multi-arch cross-gcc compilers are in Debian/unstable and (soon) in jessie. Very few people need to build a cross-toolchain. It is a complicated business and unless you are doing something really quite obscure you should just install a suitable apt-able toolchain.
Line 10: Line 7:
= Installing a Cross Compiler = We'll say that again: '''MOST PEOPLE SHOULDN'T BE BUILDING THEIR OWN CROSS-TOOLCHAIN - THEY SHOULD JUST INSTALL A PRE-BUILT ONE LIKE ANY OTHER PACKAGE'''.
Line 12: Line 9:
This document will help you obtain Debian packages of a cross-compilation toolchain. It is based on [[http://psas.pdx.edu/DebianCrossCompilerHowto|a HOWTO]] by Josh Triplett, with his kind permission. But there are reasons why you might need to do this.
Line 14: Line 11:
Note that most cross-toolchain combinations you might actually want within Debian are built by the Embedded Debian Project, so you may well just be able to apt-get what you need on their Toolchains page: http://www.emdebian.org/crosstools.html == I really do want to build a Cross Compiler ==
Line 16: Line 13:
We'll say that again: '''MOST PEOPLE SHOULDN'T BE BUILDING THEIR OWN CROSS-TOOLCHAIN - THEY SHOULD JUST INSTALL A PRE-BUILT ONE LIKE ANY OTHER PACKAGE'''. Pick the most relevant heading from the list below
Line 18: Line 15:
== To install a prebuilt cross compiler == === I want a combination of BUILD x HOST not in Debian ===
Line 20: Line 17:
=== What if I have an Ubuntu system or want to do multiarch-style crossbuilding? === If HOST is a debian release architecture then this is fairly straightforward:
 * Check out the cross-gcc git repo
 * generate a cross-gcc-<ver>-<arch> source package
 * Build it
{{{
git clone http://anonscm.debian.org/cgit/crosstoolchain/cross-gcc.git
TARGET_LIST=hostarch cross-gcc/gensources
TARGET_LIST=hostarch cross-gcc/buildall
}}}
Fill in your own hostarch above. You will need sbuild 0.64.3 or later installed, and a suitable chroot or build env for the target suite.
Line 22: Line 28:
If you have an Ubuntu system, cross-toolchains are included (from 10.10/Maverick onwards). From 12.10/Quantal onwards there is a crossbuild-essential-<arch> convenience package to install cross toolchains, cross-pkgconfig and (multiarch) cross-libc. So simply installing crossbuild-essential-armhf, or crossbuild-essential-arm64 will get you all the stuff you need. (multiarch for the architecture you want to build for must be enabled, with dpkg --add-architecture <arch> (e.g. armhf)) A more manual build, probably best done in a chroot, could be
{{{
cd packages/cross-gcc-4.9-hostarch
dpkg --add-architecture hostarch
apt-get update
<install build-deps>
dpkg-buildpackage
}}}
(This essentially automates the procedure described on MultiarchCrossToolchainBuild).
Line 24: Line 38:
Prior to quantal there are just cross-toolchain packages which install the cross-toolchain and default compiler links. apt-get install arm-linux-gnueabi-gcc (for armel) or arm-linux-gnueabihf-gcc (for armhf). These toolchains search multiarch library and header paths by default so are suitable for multiarch crossbuilding.

For other architectures, or if you have a Debian system you should get toolchains from Emdebian. These toolchains search in the 'dpkg-cross' cross-lib/headers paths, not the new multiarch paths, so are not very useful for multiarch cross-building.

Debian multiarch-ready cross-toolchains for armhf and armel are available here: http://emdebian.org/~thibg/repo/pool/main/g/gcc-4.7/ Work is underway to integrate cross-toolchains properly into debian: [[http://wiki.debian.org/MultiarchCrossToolchains|multiarch-ready Debian cross-toolchains]].
If HOST is not a debian release architecture (debian-ports architecture or a new arch), then it may be much harder because you need to do a full bootstrap. cross-toolchain-base packages exist in Ubuntu for this for some architectures, but the procedure is broken in Debian at the time of writing (Nov 2014) so you'll need to fiddle with patches.
Line 31: Line 41:
=== Installing cross-toolchains from Emdebian === === I want the very latest arm support ===
Line 33: Line 43:
Add the Emdebian keyring from Debian before you start.
{{{
apt-get install emdebian-archive-keyring
}}}

Add two apt sources, one for your normal mirror and one for Emdebian:
{{{
deb http://ftp.XX.debian.org/debian squeeze main
deb http://www.emdebian.org/debian squeeze main
}}}

Create a new file in {{{/etc/apt/sources.list.d/}}} with the above lines.

Use whatever is your normal Debian mirror for the first line which brings in some dependencies which are no longer in Wheezy or unstable.

Now just install your toolchain, e.g. for armel:
{{{
apt-get update
apt-get install g++-4.4-arm-linux-gnueabi
}}}

Emdebian also maintain scripts which effectively do what this page describes. Take a look at the DebianPts:buildcross package from Debian experimental, which will build a whole range of toolchains.

'''Most users do not need to build the cross-compiler'''


----
CategoryEmdebian
Linaro's cross-toolchains (tarball install, sadly) are very up to date with patches and support, and may well be useful.

Crosstoolchain documentation is now collected on CrossToolchains

Building a Cross Compiler

Very few people need to build a cross-toolchain. It is a complicated business and unless you are doing something really quite obscure you should just install a suitable apt-able toolchain.

We'll say that again: MOST PEOPLE SHOULDN'T BE BUILDING THEIR OWN CROSS-TOOLCHAIN - THEY SHOULD JUST INSTALL A PRE-BUILT ONE LIKE ANY OTHER PACKAGE.

But there are reasons why you might need to do this.

I really do want to build a Cross Compiler

Pick the most relevant heading from the list below

I want a combination of BUILD x HOST not in Debian

If HOST is a debian release architecture then this is fairly straightforward:

  • Check out the cross-gcc git repo
  • generate a cross-gcc-<ver>-<arch> source package

  • Build it

git clone http://anonscm.debian.org/cgit/crosstoolchain/cross-gcc.git
TARGET_LIST=hostarch cross-gcc/gensources
TARGET_LIST=hostarch cross-gcc/buildall

Fill in your own hostarch above. You will need sbuild 0.64.3 or later installed, and a suitable chroot or build env for the target suite.

A more manual build, probably best done in a chroot, could be

cd packages/cross-gcc-4.9-hostarch
dpkg --add-architecture hostarch
apt-get update
<install build-deps>
dpkg-buildpackage

(This essentially automates the procedure described on MultiarchCrossToolchainBuild).

If HOST is not a debian release architecture (debian-ports architecture or a new arch), then it may be much harder because you need to do a full bootstrap. cross-toolchain-base packages exist in Ubuntu for this for some architectures, but the procedure is broken in Debian at the time of writing (Nov 2014) so you'll need to fiddle with patches.

I want the very latest arm support

Linaro's cross-toolchains (tarball install, sadly) are very up to date with patches and support, and may well be useful.