There are other compilers than $(CC)

I do a lot of cross compilations. With different software elements. But sometimes I want to kick their authors into ass…

There is a good sign when you see $(CC) in Makefiles as it shows that author of code learnt that “gcc” is not the only compiler. But this is not the only compiler you should know about.

Recently I was adding one component (will save a name) into OpenEmbedded as this is one of dependencies for some bigger project (which I do not want to blog about). Argh… I managed to cross built it but patches are UGLY (will get better).

Using $(CC) to build everything is just broken. Especially when you need to compile a tool which will generate some code to get everything built. There is $(BUILD_CC) for it but you have to use it wisely. If there are common parts then compile them with $(BUILD_CC) if you need to run it and with $(CC) if you not. This way we, cross compilation guys, can just do “./configure;make;make install;package” is it native or cross build. Autotools (die, die, die) are able to handle that — so is your code if you write Makefiles properly.

But do not reuse same object files for target and native binaries — let it be “common.o” and “native/common.o” for example. OK, if you do only native builds then it will take a bit more disk space but we have 2012 not 1995… Storage is cheap.

There is also $(HOST_CC) but that’s for other post…

Ubuntu cross compilers situation for 13.04 ‘raring’

As you know I am responsible for building cross compilers for Ubuntu. They targeted “armel” and “armhf”. But this will change.

During last few weeks I was slowly updating cross compiler source packages for ‘raring’ (current Ubuntu development version). Most of time was taken by conferences so it had to wait until previous week when I got first two parts (binutils/cross and arm{el,hf,64}-cross-toolchain-base) working. I found some issues in binutils, eglibc, linux, gcc-4.7 but make workarounds for them — will report bugs and work on fixes of course.

But situation is not nice. Armel was dropped from ‘raring’ which made building a bit harder (had to find a way to get “linux-libc-dev” package from “linux-source-3.7.0”). But I am more and more convinced that I should just drop “armel” cross compiler. It will make my life easier but of course patches are welcome.

Multilib support will get dropped as well. “armhf” cross compiler will not build for “armel” cause there will be no eglibc packages.

But there will be a bonus — I work also on “arm64” cross compiler.

Ubuntu 12.04 ‘precise’ and cross compilation of ARM kernels

Over year ago I wrote How to cross compile ARM kernel under Ubuntu 10.10 and this became one of most popular posts on my website. It may work still but it is terribly outdated so I decided that it is a time for update.

Users of Ubuntu 12.04 ‘precise’ have much simpler situation when it comes to cross compilation of Linux kernels than ones who use older releases. Everything is now in distribution, we have a lot of packages converted to multiarch so instruction is much shorter.

There are few steps to cross compile Linux kernel under Ubuntu 12.04 ‘precise’ (for “armhf” which is officially supported now):

  • Install cross compiler:

apt-get install gcc-arm-linux-gnueabihf

  • Fetch kernel source:

apt-get source linux-source-3.2.0

  • Install packages required to build kernel:

apt-get build-dep linux-source-3.2.0

  • Build kernel:

cd linux-3.2.0; dpkg-buildpackage -b -aarmhf

And that’s all. Linaro kernels will be as easy to build as Ubuntu one on next days as we have to update packaging to recent Ubuntu version.

Updated cross toolchain for Ubuntu

During last two weeks I was working on updating PPA with cross toolchain for Ubuntu. Current development branch (12.04 ‘precise’) got gcc 4.6.2 and 4.5.3, binutils 2.22, eglibc 2.15 and linux 3.2 headers.

Then I started work on getting those updates also for previous LTS (10.04 ‘lucid’) and for previous stable release (11.10 ‘oneiric’). Versions between those two (10.10 ‘maverick’ and 11.04 ‘natty’) are not supported but binaries built for ‘lucid’ should work just fine on them.

It is time-consuming cause I had to run many builds to make sure that everything is properly patched etc. I listed all required tasks in “Toolchain update for Linaro Toolchain Backports PPA for 12.03” blueprint on Launchpad. Most time-consuming is waiting for PPA builders but at that phase I was just checking did they finished already due to working on other projects.

So if you are stuck on one of released versions of Ubuntu and need fresh cross compiler targetting “armel” (there is no “armhf” for this PPA) consider using PPA with cross toolchain for Ubuntu.

And do not forget to report any bugs found to armel-cross-toolchain-base and gcc-4.6-armel-cross (or gcc-4.5-armel-cross if you use older one).

Generic Linux cross toolchain for tests

Some time ago we agreed that not everyone here uses Ubuntu distribution and decided to provide so called ‘generic linux’ cross toolchain. Recently I managed to get it done and now need brave testers to tell is it working or not.

Get it here: (64bit only)

Needed files are toolchain-11.07.tar.xz and script. Unpack tarball from / so /opt/linaro/11.07/ will be populated and put anywhere you want (it will be integrated into tarball later).

How to use:

$ source

this will add cross toolchain into PATH and also set LD_LIBRARY_PATH to two directories:

  • one with binutils libraries
  • second with all extra libraries which may be needed

Feel free to experiment with second dir by removing files from there and checking are system provided libs are fine too.

So far I checked this toolchain under few distributions:

  • Ubuntu 10.04 ‘lucid’ LTS
  • Ubuntu 11.04 ‘natty’
  • Fedora 14
  • OpenSUSE 11.4
  • CentOS 5.6

It failed only under CentOS (which was expected due to it’s age).

How did I checked? So far compilation of ‘gpm’ and ‘zlib’ were tested.

How to cross compile ARM kernel under Ubuntu 10.10

So you got ARM device and want to build kernel for it? There are few ways how you can do it under Ubuntu 10.10 (or higher).

First you need proper cross compiler. After “apt-get install gcc-arm-linux-gnueabi” you will get proper one.

Next step is compilation of kernel. I will cover 2 things: Ubuntu kernel packages and own kernel.

So… to cross compile Ubuntu kernel we need to have some libraries installed in ARM versions. Simplest way is to use “xdeb” for it:

# apt-get install xdeb
# xdeb -aarmel --only-explicit --apt-source linux-linaro

This will fetch some libraries and install it in host system. But it will not build kernel for us 🙁 Filled bug to not lose track of it.

NOTE: check “dpkg -l *elf*-armel-cross” after xdeb run. If it does not return anything then you need to edit “/etc/apt/source.list” and add line with “deb-src” so APT will know where to go for sources. Do not forget to run “apt-get update” after edit.

Next step is quite simple — all is needed is:

$ cd linux-linaro-2.6.35
$ CROSS_COMPILE=arm-linux-gnueabi- dpkg-buildpackage -b -aarmel

After some time kernel will be cross compiled and packaged.

If you want official Ubuntu kernel instead of Linaro one then use:

$ apt-get source linux-source-2.6.35
$ cd linux-2.6.35
$ CROSS_COMPILE=arm-linux-gnueabi- dpkg-buildpackage -b -aarmel

Other way (not supported by Ubuntu developers) is to build kernel from source outside of Ubuntu. Once you got sources unpacked and configured you need just one command: “ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make uImage modules” to build kernel (replace uImage with zImage if your device does not use U-Boot).

Ubuntu cross compilers – part 2

Two months ago I wrote about cross compilers for Ubuntu. Lot of things changes since then:

  1. I am able to bootstrap ARM targeting cross compiler using Ubuntu build machines (so no manual steps).
  2. Packages are now available in my Armel cross compilers PPA repository. My repository at is still operational but will not be updated anymore.
  3. Source of my packages with whole history is available in GIT repository.
  4. Bug was filled to get those packages imported into Ubuntu archive. And it got accepted by Ubuntu Release Team! So expect ARM cross compiler packages soon in Maverick 🙂

What next? Improvements of course. Recently Al Viro got Debian/Ubuntu gcc packages working for biarch/triarch architectures (think: powerpc, mips, s390) so in free time I will take a look to make powerpc cross compiler (require some work).

Other thing will be merging my packages into Debian. This will take more time because kernel recipes needs to be changed for it and Debian is not only Linux…

UPDATE: armel cross-compiler packages are available in Ubuntu 10.10 ‘maverick’ and newer. To install them you need to run apt-get install gcc-arm-linux-gnueabi (substitute ‘gcc’ with ‘g++’ or ‘gfortran’ or ‘gobjc’ or ‘gobcj++’ if needed). Other repositories were taken down and will not return.

Ubuntu cross compilers

Some time ago developers from Linaro asked me to provide cross compilers which will target ARM. I did setup two (amd64 and i386) chroots with maverick and started builds.

Result is available at my area of server as normal APT repository. Currently I provide gcc-4.4, gcc-4.5 and binutils there + all ARM libraries which are needed. And this is bare toolchain — you can build kernel with it or hello.c but if you want something more complicated then you will need additional libraries.

Building of those toolchains was easy. Much more time consuming was improving packaging rules. I merged all cross ones into native related so (according to diffstat) over 1600 lines were removed. And that was not all — I am finding new things each day so lot of rebuilds happen. Thanks to Matthias Klose (also known as doko) who is Debian/Ubuntu gcc maintainer all those changes were reviewed, fixed, improved, accepted and released in last versions of “gcc-4.4” and “gcc-4.5” packages in both those distributions.

UPDATE: all those packages are available in Ubuntu 10.10 (and later) repositories.