This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Behaviour of toolchain "cannot find /lib/libc.so.0"


Hello,

I have a question regarding the behaviour of a cross-compiling
toolchain. For example, using a Crosstool-NG toolchain :

1. A hello-world like program compiles

../toolchains/ctng-arm-unknown-linux-uclibcgnueabi/bin/arm-unknown-linux-uclibcgnueabi-gcc -o toto toto.c

   so far, so good.

2. Now, let's copy the toolchain sysroot

cp -a ../toolchains/ctng-arm-unknown-linux-uclibcgnueabi/arm-unknown-linux-uclibcgnueabi/sys-root/ ctng

3. And compile the program by telling the compiler where the sysroot is

../toolchains/ctng-arm-unknown-linux-uclibcgnueabi/bin/arm-unknown-linux-uclibcgnueabi-gcc --sysroot=/home/test/tmp/ctng/ -o toto toto.c

   Good, still works.

4. Now, let's specify the full path to /usr/lib/libc.so in the new
   sysroot (yeah, doesn't make sense, but please keep reading)

../toolchains/ctng-arm-unknown-linux-uclibcgnueabi/bin/arm-unknown-linux-uclibcgnueabi-gcc --sysroot=/home/test/tmp/ctng/ -o toto toto.c /home/test/tmp/ctng/usr/lib/libc.so 
/home/test/toolchains/ctng-arm-unknown-linux-uclibcgnueabi/lib/gcc/arm-unknown-linux-uclibcgnueabi/4.4.3/../../../../arm-unknown-linux-uclibcgnueabi/bin/ld: cannot find /lib/libc.so.0
collect2: ld returned 1 exit status

Ah, ah, it fails. This is because usr/lib/libc.so is a linker script
that references /lib/libc.so.0. However, as this usr/lib/ directory is
inside the toolchain sysroot, I thought "ld" was supposed to interpret
paths in linker script relative to the sysroot. But this doesn't happen
here.

Of course, passing this path to the C library libc.so may sounds
strange and inapropriate, but it's exactly what my configure script is
doing:

configure:6447: checking for GNU gettext in libintl
configure:6474: /home/test/toolchains/ctng-arm-unknown-linux-uclibcgnueabi/bin/arm-unknown-linux-uclibcgnueabi-gcc --sysroot=/home/test/outputs/test-57/staging -o conftest -pipe -Os  -mabi=aapcs-linux -msoft-float -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -I/home/test/outputs/test-57/staging/usr/include -L/home/test/outputs/test-57/staging/lib -L/home/test/outputs/test-57/staging/usr/lib conftest.c  /home/test/outputs/test-57/staging/usr/lib/libintl.so /home/test/outputs/test-57/staging/usr/lib/libc.so -Wl,-rpath -Wl,/home/test/outputs/test-57/staging/usr/lib >&5
/home/test/toolchains/ctng-arm-unknown-linux-uclibcgnueabi/lib/gcc/arm-unknown-linux-uclibcgnueabi/4.4.3/../../../../arm-unknown-linux-uclibcgnueabi/bin/ld: cannot find /lib/libc.so.0
collect2: ld returned 1 exit status

I have tested the same thing with a CodeSourcery toolchain, and it
fails similarly. So it doesn't seem to be a problem of Crosstool-NG
toolchains specifically.

Any clue ?

Thanks,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]