Differences between revisions 46 and 48 (spanning 2 versions)
Revision 46 as of 2015-01-04 14:33:31
Size: 2236
Editor: wookey
Comment:
Revision 48 as of 2015-05-23 20:03:25
Size: 3535
Editor: wookey
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Crosstoolchain documentation is now collected on CrossToolchains (Crosstoolchain documentation is now collected and indexed on CrossToolchains)
Line 3: Line 3:
== Building a Cross Compiler == = Building a Cross Compiler =
Line 5: Line 5:
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. 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. Installation info is on CrossToolchains.
Line 11: Line 11:
== I really do want to build a cross compiler == = I really do want to build a cross compiler =
Line 15: Line 15:
=== I want a combination of BUILD x HOST not in Debian on unstable === == I want a combination of BUILD x HOST not in Debian (on jessie or later) ==

=== HOST is a debian release architect
ure ===
Line 18: Line 20:
Line 19: Line 22:
 * Generate a cross-gcc-<ver>-<arch> source package {{{
apt-get install cross-gcc-dev
}}}
This is available from jessie (Debian 8) onwards

 * Generate a cross-gcc-<gccver>-<arch> source package
{{{
TARGET_LIST=<hostarch> cross-gcc-gensource <gccver>
}}}
Fill in your own <hostarch> and <gccver> above. (e.g. {{{TARGET_LIST="armel armhf" cross-gcc-gensource 4.9}}})
In jessie only '4.9' is supported as a gcc version.

This will generate (in a directory called cross-gcc-packages-<buildarch>) a cross-gcc-<gccver>-<arch> source package for each arch in the TARGET_LIST.

'''Note''': in jessie cross-gcc-gensource will fail if dash is your default shell. (DebianBug:#780583). Either set the /bin/sh link to bash {{{sudo ln -sf bash /bin/sh}}} or add
{{{SHELL := bash}}} near the start of /usr/share/cross-gcc/template/rules.generic
(fixed in cross-gcc 17)
Line 22: Line 42:
apt-get install cross-gcc-dev
TARGET_LIST=<hostarch> gensource
cd cross-gcc-<gccver>-<arch>
sbuild -d jessie
}}}
You will need sbuild 0.64.3 or later installed, and a suitable chroot or build env for the target suite. You will also need a <triplet>-binutils package.
Line 25: Line 47:
If the cross-binutils you need is not available on your arch, build one (or more) like this:
{{{
apt-get source cross-binutils
cd cross-binutils-0.23
sudo apt-get build-dep cross-binutils
TARGET_LIST="arm64" HOST_LIST="armhf" debian/rules control
TARGET_LIST="arm64" HOST_LIST="armhf" dpkg-buildpackage
Line 27: Line 56:
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 34: Line 62:
<install build-deps> [install build-deps]
Line 39: Line 67:
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. === HOST is not a debian release architecture ===

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 kernel/libc/gcc 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 (May 2015) so you'll need to fiddle with patches. We do hope to have this working soon.

(Crosstoolchain documentation is now collected and indexed 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. Installation info is on CrossToolchains.

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 (on jessie or later)

HOST is a debian release architecture

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

  • Install the cross-gcc-dev binary package

apt-get install cross-gcc-dev

This is available from jessie (Debian 8) onwards

  • Generate a cross-gcc-<gccver>-<arch> source package

TARGET_LIST=<hostarch> cross-gcc-gensource <gccver>

Fill in your own <hostarch> and <gccver> above. (e.g. TARGET_LIST="armel armhf" cross-gcc-gensource 4.9) In jessie only '4.9' is supported as a gcc version.

This will generate (in a directory called cross-gcc-packages-<buildarch>) a cross-gcc-<gccver>-<arch> source package for each arch in the TARGET_LIST.

Note: in jessie cross-gcc-gensource will fail if dash is your default shell. (). Either set the /bin/sh link to bash sudo ln -sf bash /bin/sh or add SHELL := bash near the start of /usr/share/cross-gcc/template/rules.generic (fixed in cross-gcc 17)

  • Build it

cd cross-gcc-<gccver>-<arch>
sbuild -d jessie 

You will need sbuild 0.64.3 or later installed, and a suitable chroot or build env for the target suite. You will also need a <triplet>-binutils package.

If the cross-binutils you need is not available on your arch, build one (or more) like this:

apt-get source cross-binutils
cd cross-binutils-0.23
sudo apt-get build-dep cross-binutils
TARGET_LIST="arm64" HOST_LIST="armhf" debian/rules control
TARGET_LIST="arm64" HOST_LIST="armhf" dpkg-buildpackage

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).

HOST is not a debian release architecture

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 kernel/libc/gcc 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 (May 2015) so you'll need to fiddle with patches. We do hope to have this working soon.

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. But they are supplied as a binary tarball, not as debian packages.

I want toolchain packages for wheezy

The packages on emdebian.org aimed at wheezy have been uninstallable for a long time. Install buildcross from experimental and use that to build your own.

<some instructions here would be helpful>