sil2100//vx developer log

Welcome to my personal web page

Ubuntu - toolchains, switching-the-hard-way and packaging

Sometimes, for whatever reasons, you might want/need to use an older cross-compilation toolchain for a given architecture, especially when you notice something wrong with the more recent versions. Ubuntu usually provides in its repository at least the two most recent toolchain versions. But switching to an older one is not that trivial, since another 'meta-package' handles creating of all the useful symlinks. Here's a hacky and blunt way of switching from one version to another.

2012-05-21 19:56


Let's take into consideration precise (12.04) and gcc for ARM. The most recent linaro toolchain is gcc-4.6-arm-linux-gnueabi - this is also the one installed when gcc-arm-linux-gnueabi is selected. In all cases, the gcc-[version]-arm-linux-gnueabi package installs all the binaries, while the gcc-arm-linux-gnueabi 'meta-package' creates all symlinks, essentially binding it as the default.
But since gcc-arm-linux-gnueabi is fixed to depend only on the latest toolchain, there is no real way of creating the symlinks for earlier versions. But we can always do it the hard way - rebuilding the package.

It's quite easy. Just perform the following steps:

 mkdir pkg
 cd pkg
 apt-get source gcc-arm-linux-gnueabi
 cd gcc-defaults-armel-cross-1.8 # Or any other name of the extracted sources
 vim debian/rules # Here, modify the rules file and change GCC_VER to the version you want
 dch -i # This is an additional step, if you wish to change the version of the package

We can then install the package and make use of the older cross-compiling gcc through the standard arm-linux-gnueabi-gcc command.

This shows actually how easy it is to rebuild a Debian package (and, therefore, any Ubuntu package). The debuild command will inform you of any missing build dependencies. If something is missing, we can install those packages with apt-get and re-run the command again.
Of course, cross-building packages for different architectures than ours is a bit more tricky. But we'll get back to this once, I hope.

As a side note - since this is also related to cross-compiling. Some of you might be using qemu-arm for cross-compiling as well (for instance, in a chroot with qemu-arm-static). I noticed that the precise qemu-arm emulator probably is 'bugged' - certain native code results in a segfault. I noticed it while trying to run the lupdate-qt4 binary - it crashes with a segmentation fault. The problem seems to be somewhere in the qemu-arm package from precise. From what I know some people are already looking into this problem. Just be advised.