While trying to compile gcc (HEAD of 2007-08-27) for a sysrooted environment in /tmp/gc where glibc 2.6.1 is already installed there, ld complains: /usr/i686-pc-linux-gnulibc2/lib/gcc-lib/i686-pc-linux-gnulibc2/3.3.3/../../../../i686-pc-linux-gnulibc2/bin/ld: cannot find /tmp/gc/lib/libc.so.6 inside /tmp/gc. The file /tmp/gc/lib/libc.so.6 is perfectly there. This is what I did exactly: - use linux kernel source 2.6.22.5, configure and make INSTALL_HDR_PATH=/tmp/gc headers_install - configure glibc-2.6.1 with CFLAGS=-march=i486 ../configure --prefix=/tmp/gc \ --disable-nls --enable-add-ons and install - configure gcc (from svn 2007-08-27) with configure --prefix=/tmp/gc --disable-nls --enable-shared \ --with-sysroot=/tmp/gc --enable-languages=c i686-pc-linux-gnulibc2 The version of ld used was 2.17.50.0.18.20070731 from kernel.org. However, in all versions of ld between 2.17 and 2.18.50.20070828 that I looked at, the code mentioned below is the same. The following patch fixes the problem for us: commit 0f7df4f0f32312588d77f3e8dc26193cf8db2d81 Author: Stephan Springl <springl@bfw-online.de> Date: Mon Aug 27 23:43:27 2007 +0200 ld: do not prepend ld_sysroot to absolute paths diff --git a/ld/ldfile.c b/ld/ldfile.c index c9414ff..800c60e 100644 --- a/ld/ldfile.c +++ b/ld/ldfile.c @@ -308,7 +308,7 @@ ldfile_open_file_search (const char *arch, directory first. */ if (! entry->is_archive) { - if (entry->sysrooted && IS_ABSOLUTE_PATH (entry->filename)) + if (entry->sysrooted && !IS_ABSOLUTE_PATH (entry->filename)) { char *name = concat (ld_sysroot, entry->filename, (const char *) NULL);
You did not configure glibc correctly. You should use --prefix=/usr and install it with install_root=${sysroot}. The whole point of the sysroot feature is that it establishes a chroot style environment.
(In reply to comment #1) > You did not configure glibc correctly. You should use --prefix=/usr and > install it with install_root=${sysroot}. The whole point of the sysroot > feature is that it establishes a chroot style environment. I think this needs to be revisited in response to gcc 4.3 changes that have removed the possibility of building a non root toolchain without using sysroot. Apparently the new philosophy of gcc is to use sysroot for all non root installs which forces it to be used in possibly non chroot environments. The gcc bug with references is: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35804
Subject: Re: linker incorrectly prepends sysroot to absolute path Thank you for your message. I am away from my email from 3 to 7 April. Messages sent before 3 April will be read before I go away; messages sent during that period will be read after I return. If you need a response before my return, please contact Nathan Sidwell <nathan@codesourcery.com>.
No, this bug is RESOLVED/INVALID. In the configuration described in the initial report, glibc is configured incorrectly for the way it is being used; and the patch is incorrect. If you have a different problem, please report it in a new bug.