When gcc-4.2.2 is built with the '--with-sysroot=$path' configure option,
gcc does correctly prepend $path to the default include and library search
dirs,
but the default linux dynamic linker, /lib/ld-linux.so.2, is still used, even
though $path/lib/ld-linux.so.2 exists. 
Thus to link programs with a new glibc under $path, one must still supply the
'-Wl,-dynamic-linker,$path/lib/ld-linux.so.2' argument to the resulting gcc 
in order to use the glibc under $path .
It seems strange and unlikely to work that gcc then by default attempts to 
link to a glibc under $path, but still uses the dynamic linker from the
system glibc under /lib.

A very simple patch will fix this for linux :

--- diff -u gcc/config/linux.h~ gcc/config/linux.h :
--- gcc/config/linux.h~ 2007-09-01 11:28:30.000000000 -0400
+++ gcc/config/linux.h  2007-09-01 11:28:30.000000000 -0400
@@ -104,7 +104,11 @@
 #if UCLIBC_DEFAULT
 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc
used together}" G ";:" U "}"
 #else
+#ifndef TARGET_SYSTEM_ROOT
 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc
used together}" U ";:" G "}"
+#else
+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc
used together}" U ";:" TARGET_SYSTEM_ROOT G "}"
+#endif
 #endif

 /* For most targets the following definitions suffice;
---

Since TARGET_SYSTEM_ROOT is only defined by configure when --with-sysroot
is specfied, this works OK; the dynamic linker under $path/lib/ is used
by default, unless the -Wl,-dynamic-linker ld option is supplied for a build.

Perhaps when the '--sysroot=$path' gcc option is supplied, a dynamic linker at
the $path/lib/ld-linux.so.2 location should also be the default.

Using the default system /lib/ld-linux.so.2 when a user has built gcc with the
--with-sysroot configure option makes it impossible to install a new gcc
and glibc under a non-default location under $path without having to add the 
'-Wl,-dynamic-linker,$path/lib/ld-linux.so.2' option to every build, thus 
defeating the purpose of --with-sysroot IMHO - one could simply append 
the '-I$path/include -L$path/lib -B$path/lib
-Wl,-dynamic-linker,$path/lib/ld-linux.so.2' options to every build,
and get the same effect without building gcc with --with-sysroot.
But when one wants to test software against a new gcc+glibc combination
installed in a non-default location, not having to change the options used 
to compile the software under test is a major advantage, and is only made
possible by gcc supplying the correct dynamic linker argument by default.

So, please, consider fixing this issue. Thanks!


-- 
           Summary: --with-sysroot does not change default linux glibc
                    dynamic-linker path
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: bootstrap
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jason dot vas dot dias at gmail dot com
 GCC build triplet: i386-linux-gnu
  GCC host triplet: i386-linux-gnu
GCC target triplet: i386-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34257

Reply via email to