cross-compiled native compiler: ld can't find crt1.o
Ryan.Oliver@pha.com.au
Ryan.Oliver@pha.com.au
Mon Aug 16 13:52:00 GMT 2004
Dan Kegel wrote:
>Martin Schaffner wrote:
>> I'm trying to compile LFS starting from Mac OS X for my
>lfs-from-osx hint.
>>
>> I used crosstool (http://kegel.com/crosstool) to create a
>cross-compiler
>> on Mac OS X for powerpc-750-linux-gnu, whose specs file I modify to
>use
>> /tools/lib/ld.so.1 instead of /lib/ld.so.1.
>> With this cross-compiler, I compiled glibc-2.3.2 (as patched for
>> crosstool), gcc-3.3.3 and binutils-2.14 (patched and compiled as in
>the
>> sections "Pass 2" of LFS-5.1.1 plus the host and build configure
>flags).
>>
>> After starting Linux with init=/tools/bin/bash, the compiler in
>/tools/
>> can compile a hello world program fine, but it can't link it.
>>
>> The first problem is that in the arguments to ld, gcc passes
>crt0.o,
>> crt1.o, and crtn.o directly, without any path prefixed, so ld can't
>find
>> them.
>
>Heh. I've run into that. It means your toolchain is not installed
>quite right.
>The -print-file-name option to gcc can be used to check whether gcc
>can find
>a particular file. e.g.
>$ gcc -print-file-name=crt1.o
>/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crt1.o
>If it can't find it, it'll print it out with just a bare filename,
>just as you're seeing.
>
>The way to solve this is to look at the gcc source code to
>understand
>what the -print-file-name= option does, and work backwards from
>there.
>It's not fun, but hey, at least you get to see how things work.
>- Dan
>
In the specs file set
startfile_prefix_spec:
/tools/lib/
ie: point to wherever crt[i1n].o you require exists.
Dont forget the trailing slash.
It should then search for your startfiles in the correct spot.
Not too sure if you have to actually define STARTFILE_PREFIX_SPEC
in gcc/config/${ARCH}/{linux.h,linux64.h} during your target native
build thoughfor this to work
(I always manually define it during the build, saves editing the specs
later)
This trick is also dead handy for building bi-arch/multi-lib cross-
toolchains when components are installed into non-standard places...
Regards
Ryan
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com
More information about the crossgcc
mailing list