CrossToolchains
Contents
Cross Toolchain documentation
About the tools (installing, building, status, design):
ToolChain/Cross : Overview of toolchain build methods
ToolChain/Cross/Roadmap : Proposed Development work around Debian cross-toolchains
alioth cross-toolchain team where team is listed and code resides
MultiarchCrossToolchainBuild : Building cross-toolchains using multiarch dependencies
MultiarchCrossToolchainBootstrap : Doing a cross-toolchain bootstrap using multiarch dependencies
CoinstallableToolchains : Scheme to allow co-installable compilers
toolchain/BootstrapIssues : Breakage found when building debian crosstoolchains (might save you some time!)
Sprints/2014/BootstrapSprint/Results : Crossbuild sprint report discussing various crossbuild/toolchain issues
CrossTranslatableBuildDeps: Mechanisms to allow dependencies on toolchains to work correctly when crossing
Using the tools:
Talks:
Pages of largely historical interest:
Status of cross-toolchains in the Debian archive
In jessie (Debian 8)
- cross-binutils
- cross-gcc-dev package which provides machinery to build simple cross-toolchains for jessie
Pre-built binary cross-toolchains (for amd64 and i386) and supporting packages are available from the Debian Cross-toolchains repository. See 'Installation' below.
gcc, g++ and gfortran, gobj and gccgo front-ends are provided. These toolchains are built for a single target ABI (not multilibbed), so install whichever targets you need, and use triplet- commands everywhere. They target arm64, armel, armhf, mips, mipsel, powerpc, ppc64el.
Also included is a modified pkg-config.
In unstable
Currently (June 2015), the gcc-5 cross-compiler packages are built 'standalone' (depending on *-cross arch:all packages), whilst the gcc-4.9 cross-compiler packages are built with multiarch dependencies (depending on *:hostarch packages).
- cross-binutils
gcc-<ver>-<triplet> packages built from gcc-4.9 only for amd64, targeting the linux architectures supported in Debian: armel, armhf, arm64, mips, mipsel, powerpc, ppc64el gcc, g++ and gfortran cross-compilers are provided (gobjc and gccgo coming soon)
- cross-gcc-dev package which provides machinery to build cross-toolchains
cross-gcc-defaults (gcc-<triplet>) metapackages which provide symlinks to the current version of the compilers (so that 'arm-linux-gnueabi-gcc' works when the compiler binary is actually arm-linux-gnueabi-gcc-4.9
- gcc-5-cross: standalone crosscompiler packages for amd64 and i386, targetting arm64, armel, armhf, powerpc, ppc64el
In experimental
- crossbuild-essential metapackage to pull in gcc, g++, libc-dev:arch and dpkg-cross (for autoconf and cmake cache/toolchain file support)
- cross-gcc-dev (test versions)
Status of cross-toolchains in Ubuntu
Current details are given on https://wiki.ubuntu.com/ToolChain#Cross_development_toolchain
If you have an Ubuntu system, cross-toolchains (i386 & amd64->armel) have been included since 10.10/Maverick. From 12.10/Quantal onwards there are crossbuild-essential-<arch> convenience packages to install cross toolchains, cross-pkgconfig and (multiarch) cross-libc. Armel then armhf were initially supported. Arm64, powerpc and ppc64el were added later.
All these toolchains search multiarch library and header paths by default so are suitable for multiarch crossbuilding.
Installation
For jessie (Debian 8)
Cross-toolchains for jessie are available, only cross-binutils and cross-gcc-dev (crosstoolchain builder package) are in the main archive. Other packages come from an external repository.
The toolchains install on amd64 and i386 machines, targeting the jessie release architectures:
- arm64
- armel
- armhf
- mips
- mipsel
- powerpc
- ppc64el
Currently cpp, gcc, g++, gfortran, gobjc and gccgo are built. It's easy to build more languages so ask if you have a need.
These packages did not make it into Jessie so you need to install them from the Debian Cross-toolchains repository. Create /etc/apt/sources.list.d/crosstools.list containing:
deb http://emdebian.org/tools/debian/ jessie main
You will need the archive key installed.
curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | sudo apt-key add -
The key fingerprint is: 084C 6C6F 3915 9EDB 6796 9AA8 7DE0 8967 1804 772E (you will need to install curl in a bare chroot)
crossbuild-essential-<arch> packages exist to aid in installing the correct cross-packages. For instance to install the armhf cross-toolchain, first enable the foreign architecture (and update), then install crossbuild-essential-armhf :
sudo dpkg --add-architecture armhf sudo apt-get update sudo apt-get install crossbuild-essential-armhf
This will pull in the required packages to cross-build for the target architecture, namely libc6-dev:<arch>, gcc-<triplet>, g++-<triplet> and dpkg-cross. (Note that dpkg-cross was removed from jessie, but remains in the Debian Cross-toolchains repository).
Note that if you also have debian unstable enabled in your apt sources you are likely to hit dependency issues. Either disable it or add an apt-preference to prefer jessie:
echo "APT::Default-Release \"jessie\";" > /etc/apt/apt.conf.d/20defaultrelease
For unstable
You must enable the appropriate (HOST) foreign architecture before installing the cross-compiler.
dpkg --add-architecture armhf apt-get update
It is recommended to install the cross environment like this as that pulls in all the necessary components:
apt-get install crossbuild-essential-<arch>
i.e
apt-get install crossbuild-essential-armhf
But you can install just the compiler with
apt-get install gcc-arm-linux-gnueabihf
Note that gcc-arm-linux-gnueabihf is (like the native 'gcc') just a metapackage, which brings int he current version of the actual compiler gcc-4.9-arm-linux-gnueabihf (c.f. gcc-4.9)
g++-<triplet>, gfortran-<triplet>, gobjc-<triplet> and gccgo-<triplet> packages also exist.
Using a chroot of unstable
For any release older than Jessie, the simplest way is to create a chroot of unstable and install your toolchain & build the package there. This is particularly simple if you are simply building a kernel or a package with only libc build dependencies.
$ sudo debootstrap sid sid $ sudo chroot sid # dpkg --add-architecture armhf # apt-get update # apt install gcc-arm-linux-gnueabihf
For Wheezy
Without a chroot, you are blocked. Emdebian.org did have 'unstable' packages which would work on wheezy but these need to be restored after a server compromise.
For Squeeze
Packaged cross-toolchains are available from emdebian.org. These use classic cross-compiler paths and pre-date multiarch so expect to be used with xapt and/or dpkg-cross supplying build-dependencies.
Older
Emdebian.org keeps some 2.95 vintage packages in case that's useful (people do still ask occaisionally!). Currently awaiting re-uploading.
Removal
This is currently the same on all suites.
You can just use whatever package tools you like to remove crossbuild-essential-<arch> or gcc-<triplet> in the usual way. However if you have installed cross-build-deps then there may well be a lot of foreign-architecture -dev packages installed.
If you want to remove all foreign-arch packages and the corresponding foreign architecture entirely then you need to remove all the :arch packages before you run dpkg --remove-architecture arch. This one-liner should work:
sudo apt-get remove `dpkg-query -f'${Package}:${Architecture}\n' -W '*:arch'`
where 'arch' is the foreign architecture you want to remove.