[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Fake cross-toolchains via multiarch



Hi!

I've been using this locally for some time, and been meaning to publish
it here, but was prompted to do it now, due to some recent bugs filed
against dpkg to support multilib style cross-toolchains.

Mutlilib is IMO a hack that should just disappear in Debian at least at
the packaging level, not necessarily on the gcc support level; it needs
special casing and can confuse the build systems because it's not really
transparent (for example «gcc -m32 -dumpmachin» does not print the
correct triplet). Instead I present a fake cross-toolchain (currently
based on basic gcc multilib support) but “deceiving” gcc to use the
multiarch files instead.

For example to use an amd64 → i486 fake cross-toolchain you do:

  $ dpkg --print-architecture
  amd64
  $ apt-get install libgcc-4.8-dev:i386 libc6-dev:i386
  $ ln -s ../../i486-linux-gnu/4.8 /usr/lib/gcc/x86_64-linux-gnu/4.8/32
  $ ./gen-cross amd64
  $ cp x86_64-linux-gnu-* /usr/local/bin

And then you could, for example, use it like this when building packages:

  $ CC=i486-linux-gnu-gcc dpkg-buildpackage -ai386

(I'm still pondering if dpkg-buildpackage should set the cross-toolchain
environment variables, probably it should.)

Beware that if you have the libmudflap0-4.8-dev packages installed,
they ship the alternative multilib files on the native package, so
you'll need to get the 32 directory out of the way («mv 32 32-old»
will do but dpkg might overwrite files there on upgrade). I've filed
719885 for that.

Here's the git repo for people to play with, I'll happily take patches
for other fake cross-toolchains. And I could even consider turning this
into a package if people demanded it and the aforementioned bug got
fixed.

  <git://git.hadrons.org/git/debian/fakecross.git>

Enjoy,
Guillem


Reply to: