Cross compile target i386 architecture

I was looking into this problem recently and the answer is more or less this (if you meant cross-bootstrapping) :

Had you simply meant cross-compiling for i686 on x86_64, the problem becomes trivial.

All you need is a gcc for your cross architecture for linking (x86_64 linker is already compatible with i686 so you'll just need the multilib part) and all the rust static rlibs which you can copy from the official i686 distribution (rustc commit hashes must be identical). They need to be put in lib/rustlib in a separate target triple directory, next to the native one.

It should work like this on x86_64:

rustc --target=i686-unknown-linux-gnu hello.rs

whereas for a truly incompatible architecture the linker needs to be specified explicitly:

rustc -C linker=arm-linux-gnueabihf-gcc-5.2 --target=arm-unknown-linux-gnueabihf hello.rs

What if you wanted to actually cross-compile for Pentium Pro and not Pentium4? You'd have to use rlibs built for a compatible CPU architecture and pass an additional -C target-cpu= flag to rustc.

For a quick test that doesn't require gcc/multilib, after copying over the crates (rlibs) for the cross architecture you could do:

cargo build --target=i686-unknown-linux-gnu

inside some project directory on your x86_64 machine.