Supposedly building a cross compiler on Debian is a rather simple process.
Thus when I started out, wishing to build myself a cross compiler to easily build i386 kernel packages for a semi-embedded x86 system, I thought the most significant problem I’d encounter would be the time it usually takes for building (cross) compilers.
The build system:
$ lsb_release -dc
Description: Ubuntu 9.10
Codename: karmic
$ uname -smo
Linux x86_64 GNU/Linux
The target system:
$ lsb_release -dc
Description: Ubuntu 8.04.4 LTS
Codename: hardy
$ uname -smo
Linux i686 GNU/Linux
Following these instructions creating a cross compilation package for binutils is easy enough and seems to work without a hitch. After fetching the source package and installing build dependencies these commands got me a nice binutils-i486-linux-gnu package.
$ export TARGET=$(dpkg-architecture -ai386 -qDEB_HOST_GNU_TYPE 2>/dev/null)
$ fakeroot debian/rules binary-cross > ../binutils.log 2>&1 || echo "Build error: $?"
It is then, during the conversion and installation of cross compilation library packages, that the first problems began. The instructions mention having to convert and install these packages (version and architecture of the target system):
- libc6
- libc6-dev
- linux-kernel-headers
- provided by linux-libc-dev
As it turns out, the libc6
package depends on the libgcc1
package. Thus
you’ll also have to install that package. Then it turns out that libgcc1
also depends on gcc-4.2-base
, and that poses a problem, as dpkg-cross
simply refuses to convert that package with this error message:
$ dpkg-cross -a i386 -b gcc-4.2-base_4.2.4-1ubuntu3_i386.deb
dpkg-cross: package gcc-4.2-base doesn't provide any useful files. Skipping.
Going from there I just had to make sure that libgcc1-i386-cross
(the
cross compilation package produced from libgcc1
) doesn’t depend on
gcc-4.2-base
‘s hypothetical i386 cross compilation package. This was
easily enough accomplished by reconverting libgcc1
and telling
dpkg-cross
to ignore gcc-4.2-base
:
$ dpkg-cross -a i386 -b -X gcc-4.2-base libgcc1_4.2.4-1ubuntu4_i386.deb
Then, after installing that new version of libgcc1-i386-cross
and our just
built version of binutils-i486-linux-gnu
, we can continue with building
GCC itself. These are the series of commands specified on the Debian wiki
(make sure to unset TARGET
beforehand):
$ export GCC_TARGET=$ARCH
$ debian/rules control
$ dpkg-buildpackage -us -uc -rfakeroot -b > ../gcc.log 2>&1 || echo "Build error: $?"
After quite some troubleshooting time, however, I discovered that the
commands mentioned proved insufficient. Linker errors occurred when the
build scripts got the stupendous idea of building an amd64 version of
libgcc – first of all, I already have one, I’m running an amd64
system, secondly my target architecture is i386
and not amd64. Setting DEB_CROSS_NO_BIARCH
solved this problem by simply disabling of including amd64 in the target architectures:
$ export GCC_TARGET=i386
$ export DEB_CROSS_NO_BIARCH=yes
$ debian/rules control
$ dpkg-buildpackage -us -uc -rfakeroot -b > ../gcc.log 2>&1 || echo "Build error: $?"
When the build process finally finished I thought to just install the packages and start the cross compiler. Unfortunately life rarely is as easy as you hope it is.
Apparently the built versions of libgcc1-i386-cross
of
libobjc2-i386-cross
had a rather curious dependency:
libc6-i386-i386-cross
.1
Yes? You get it? We need some kind of double i386 architecture as cross
compile target? – Well I didn’t, so I fell back to manually editing the
packages, by extracting, editing and repackaging by means of dpkg-deb
and
altering the libc6-i386-i386-cross
dependency and changing it to
libc6-i386-cross
.
That proved to be enough and now I’m able to easily cross compile a kernel
(more easily than by means of -m32
).
-
When performing the same process to build a cross compiler on Debian (instead of Ubuntu) this double architecture dependency problem didn’t occur. ↩
Comments
There are no comments yet.
Comment Atom Feed