views:

374

answers:

2

I am trying to build a cross-compiler with x86_64 being the host and i386 being the target. I'm getting the (all to common) crti.o: No such file error. Instead of grabbing an already built crti.o and crtn.o from a distro... how might I go about building these files explicitly from glibc (or possibly gcc) sources?

FYI, I am well aware of the -m32 option for x86_64 compilers. I'd prefer to just have a 32bit-only compiler environment. Also, the reason I don't want to use any of the gazillion already build i386 compilers is because I plan on mixing and matching glibc/binutils/gcc versions depending on my testing needs.

Thanks, Chenz

A: 

Here's one possibility (from here)

You need to install your distro's 32 bit libc-dev package, or you need to --disable-multilib which will result in a compiler that doesn't support 32 bit mode.

Jess
I want 32bit only, not the other way around. I do not want to use a distro copy... i want to build from source. Please read the FYI.
Crazy Chenz
A: 

Are you sure you're using configuring the cross-compile correctly? It should be

CBUILD = CHOST = x86_64-pc-linux-gnu
CTARGET = i386-pc-linux-gnu

as you're running a build on an x86_64, for a compiler to run on an x86_64, which generates code for an i386.

If you used CHOST = i386-pc-linux-gnu, you'll be trying to generate 32-bit binaries, which will need to link with a 32-bit libc. Which is fine, if you already have a 32-bit libc, but it sounds like you don't.

i.e.

$ tar xvjf gcc-*.tar.bz2
$ cd gcc-*/
$ mkdir build
$ cd build
$ ../configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=i386-pc-linux-gnu
ephemient