Building crti.o for i386

£可爱£侵袭症+ 提交于 2019-12-13 03:54:55

问题


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


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/595049/building-crti-o-for-i386

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!