I wanted to give gcc 3.4.0 a try so I installed the gcc 3.4.0-r4 package. I kept gcc 3.3.3 around for good measure. When I use gcc-config to switch back and forth I get a mess. It works fine when it is set as gcc 3.4.0, but when it is set as gcc 3.3.3 I get libraries that link against libstdc++.so.6 still so there are usually unresolved symbols. Even if I switch the order in ld.so.conf (which gcc-config 1.3.5 doesn't appear to do itself) I still get libraries that are linked incorrectly. Reproducible: Always Steps to Reproduce: 1. gcc-switch i686-pc-linux-gnu-3.3.3 2. source /etc/profile (or logout and log back in) 3. compile anything Actual Results: When ld.so.conf was set so the gcc 3.3.3 include line came first I got this: libstdc++.so.6 => /usr/lib/gcc-lib/i686-pc-linux-gnu/3.4.0/libstdc++.so.6 (0x41024000) libgcc_s.so.1 => /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libgcc_s.so.1 (0x410f6000) I also got a broken library. When I switch the order so that gcc 3.4.0 comes first I get the libgcc_s.so library from 3.4.0. Expected Results: using gcc-config i686-pc-linux-gnu-3.3.3 will cause programs to get linked against the gcc 3.3.3 libraries and vis versa with 3.4.0. Portage 2.0.50-r6 (default-x86-1.4, gcc-3.3.3, glibc-2.3.3_pre20040420-r0, 2.6.5) ================================================================= System uname: 2.6.5 i686 Pentium III (Katmai) Gentoo Base System version 1.4.15 ccache version 2.3 [enabled] Autoconf: sys-devel/autoconf-2.59-r3 Automake: sys-devel/automake-1.8.3 ACCEPT_KEYWORDS="x86 ~x86" AUTOCLEAN="yes" CFLAGS="-march=pentium3 -O3 -fomit-frame-pointer -funroll-loops -ffast-math -pipe" CHOST="i686-pc-linux-gnu" COMPILER="gcc3" CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.2/share/config /usr/kde/3/share/config /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/alias /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" CXXFLAGS="-march=pentium3 -O3 -fomit-frame-pointer -funroll-loops -ffast-math -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs buildpkg ccache fixpackages sandbox" GENTOO_MIRRORS="http://gentoo.chem.wisc.edu/gentoo/ http://gentoo.oregonstate.edu http://distro.ibiblio.org/pub/Linux/distributions/gentoo" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="" SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage" USE="X aalib alsa apache2 apm arts avi berkdb bonobo cdr crd crypt cups dga doc dvd encode esd foomaticdb gd gdbm gif gnome gtk gtk2 gtkhtml imagemagick imap imlib java jpeg kde libg++ libwww mad maildir mikmod mmx motif mozilla mpeg mysql ncurses nls oggvorbis opengl oss pam pdflib perl png postgres ppds python qt quicktime readline samba sdl slang spell sse ssl svga tcltk tcpd tetex truetype usb x86 xml2 xmms xv zlib"
the problem is env-update does not correctly re-ordering gcc path in /etc/ld.so.conf # gcc-config -l [1] i686-pc-linux-gnu-3.3.3 [2] i686-pc-linux-gnu-3.4.0 # gcc-config -c i686-pc-linux-gnu-3.4.0 # grep LDPATH /etc/env.d/05 # grep LDPATH /etc/env.d/05gcc LDPATH="/usr/lib/gcc-lib/i686-pc-linux-gnu/3.4.0:/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3" # mv /etc/ld.so.conf /etc/ld.so.conf.bak # env-update >>> Regenerating /etc/ld.so.cache... * Caching service dependencies... # grep gcc /etc/ld.so.conf /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.4.0 # source /etc/profile # gcc --version gcc (GCC) 3.4.0 20040519 (Gentoo Linux 3.4.0-r4, ssp-3.4-1, pie-8.7.6) Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # cat hello.cpp #include <stdio.h> main (int argc, char** argv) { printf ("Hello World!\n"); return 0; } # g++ hello.cpp gentoo testing # ldd a.out linux-gate.so.1 => (0xffffe000) libstdc++.so.6 => /usr/lib/gcc-lib/i686-pc-linux-gnu/3.4.0/libstdc++.so.6 (0x4002e000) libm.so.6 => /lib/libm.so.6 (0x400f9000) libgcc_s.so.1 => /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libgcc_s.so.1 (0x4011b000) libc.so.6 => /lib/libc.so.6 (0x40125000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) now, I re-order gcc path in /etc/ld.so.conf mannually # grep gcc /etc/ld.so.conf /usr/lib/gcc-lib/i686-pc-linux-gnu/3.4.0 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3 # /sbin/ldconfig # g++ hello.cpp # ldd a.out tc/ld.so.conf linux-gate.so.1 => (0xffffe000) libstdc++.so.6 => /usr/lib/gcc-lib/i686-pc-linux-gnu/3.4.0/libstdc++.so.6 (0x4002e000) libm.so.6 => /lib/libm.so.6 (0x400f9000) libgcc_s.so.1 => /usr/lib/gcc-lib/i686-pc-linux-gnu/3.4.0/libgcc_s.so.1 (0x4011b000) libc.so.6 => /lib/libc.so.6 (0x40124000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) looks like that it links correct now. Now, let switch to gcc-3.3.3 # gcc-config 1 * Switching to i686-pc-linux-gnu-3.3.3 compiler... [ ok ] * If you intend to use the gcc from the new profile in an already * running shell, please remember to do: * # source /etc/profile # source /etc/profile # gcc --version gcc (GCC) 3.3.3 20040412 (Gentoo Linux 3.3.3-r5, ssp-3.3-7, pie-8.7.5.3) Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # grep LDPATH /etc/env.d/05gcc LDPATH="/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3:/usr/lib/gcc-lib/i686-pc-linux-gnu/3.4.0" note that the order is correct, but # grep gcc /etc/ld.so.conf /usr/lib/gcc-lib/i686-pc-linux-gnu/3.4.0 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3 stay the same, so I manually re-order it. # grep gcc /etc/ld.so.conf /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.4.0 # ldconfig # source /etc/profile # g++ hello.cpp # ldd a.out linux-gate.so.1 => (0xffffe000) libstdc++.so.5 => /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libstdc++.so.5 (0x4002e000) libm.so.6 => /lib/libm.so.6 (0x400df000) libgcc_s.so.1 => /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libgcc_s.so.1 (0x40101000) libc.so.6 => /lib/libc.so.6 (0x4010b000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) So, do you think it is env-update fault?
It looks like this bug is related with bug #44028
Prob rather is when libtool is involved - the path's in libtool linker scripts (.la files) is hardcoded for 3.4.0 or your setup if my guess is correct. Especially if you compiled libs with 3.4, and now try to link 3.3 compiled apps to them ... which is a very bad idea btw.
I should note here that I am talking about C++ libs, etc.
See bug 44028... in short, it works now:) *** This bug has been marked as a duplicate of 44028 ***