From olafs@cs.ru.nl  Tue Dec  9 09:35:20 2008
Return-Path: <olafs@cs.ru.nl>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EFB2A106567D
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  9 Dec 2008 09:35:20 +0000 (UTC)
	(envelope-from olafs@cs.ru.nl)
Received: from tcd.science.ru.nl (tcd.science.ru.nl [131.174.30.56])
	by mx1.freebsd.org (Postfix) with ESMTP id 8D6C58FC25
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  9 Dec 2008 09:35:20 +0000 (UTC)
	(envelope-from olafs@cs.ru.nl)
Received: from twoquid.cs.ru.nl (twoquid.cs.ru.nl [131.174.142.38])
	by tcd.science.ru.nl (8.13.7/5.28) with ESMTP id mB99Z7C8008674;
	Tue, 9 Dec 2008 10:35:07 +0100 (MET)
Received: by twoquid.cs.ru.nl (Postfix, from userid 4100)
	id 10A502E05C; Tue,  9 Dec 2008 10:35:07 +0100 (CET)
Message-Id: <20081209093507.10A502E05C@twoquid.cs.ru.nl>
Date: Tue,  9 Dec 2008 10:35:07 +0100 (CET)
From: Olaf Seibert <olafs@cs.ru.nl>
Reply-To: Olaf Seibert <olafs@cs.ru.nl>
To: FreeBSD-gnats-submit@freebsd.org
Cc: olafs@cs.ru.nl
Subject: g++42 uses wrong libstdc++.so and libgcc_s.so
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         129518
>Category:       ports
>Synopsis:       lang/gcc42 - g++42 uses wrong libstdc++.so and libgcc_s.so
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gerald
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 09 09:40:01 UTC 2008
>Closed-Date:    Fri Oct 08 22:15:50 UTC 2010
>Last-Modified:  Fri Oct 08 22:15:50 UTC 2010
>Originator:     Olaf Seibert
>Release:        FreeBSD 6.1-RELEASE amd64
>Organization:
Radboud University Nijmegen
>Environment:
System: FreeBSD twoquid.cs.ru.nl 6.1-RELEASE FreeBSD 6.1-RELEASE #2: Mon Mar 19 15:05:26 CET 2007 root@twoquid.cs.ru.nl:/usr/src/sys/amd64/compile/TWOQUID amd64


	
>Description:
	If you have both gcc 4.1 and gcc 4.2 installed (gcc-4.1.3_20080630
	and gcc-4.2.5_20080702 in my example), then programs created with 
	g++4.2 will use the wrong libstdc++.so and libgcc_s.so.
>How-To-Repeat:
	
	Script started on Tue Dec  9 10:17:38 2008
	$ cat hello.cc
	#include <iostream>

	int main()
	{
	    std::cout << "Hello, world!\n";
	    return 0;
	}
	$ g++42 hello.cc
	$ ldd ./a.out
	./a.out:
		libstdc++.so.6 => /usr/local/lib/gcc-4.1.3/libstdc++.so.6 (0x80062b000)
		libm.so.4 => /lib/libm.so.4 (0x800825000)
		libgcc_s.so.1 => /usr/local/lib/gcc-4.1.3/libgcc_s.so.1 (0x800941000)
		libc.so.6 => /lib/libc.so.6 (0x800a4d000)
	$ exit

	Script done on Tue Dec  9 10:17:59 2008

	Note the "gcc-4.1.3" in those paths. These files do indeed differ
	significantly between versions:
	
	-rw-r--r--  1 root  wheel  220755 Oct  1 21:37 /usr/local/lib/gcc-4.1.3/libgcc_s.so.1
	-r--r--r--  1 root  wheel  238659 Oct  1 00:00 /usr/local/lib/gcc-4.2.5/libgcc_s.so.1

	-rwxr-xr-x  1 root  wheel  1228873 Oct  1 21:37 /usr/local/lib/gcc-4.1.3/libstdc++.so.6
	-rwxr-xr-x  1 root  wheel  1313164 Oct  1 00:00 /usr/local/lib/gcc-4.2.5/libstdc++.so.6


>Fix:
	Proper RPATH options should be used for all compilations.
	G++ should pass the correct -R (aka --rpath) options to the linker,
	and global library search paths should not be used.

	Global RPATHs (ldconfig!) are evil and cannot work properly.

-Olaf.
-- 


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->gerald 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Tue Dec 9 10:05:01 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=129518 
State-Changed-From-To: feedback->open 
State-Changed-By: gerald 
State-Changed-When: Fri Dec 26 07:24:05 UTC 2008 
State-Changed-Why:  
We won't have a lang/gcc41 port for much longer given that no other port 
has a strict dependency on this and the base system of modern releases of 
FreeBSD features GCC 4.2.  That said, the problem reported is a very real 
one, I'm afraid, related to changes to the GCC run-time infastructure and 
how we handle dynamic library directories with USE_LDCONFIG. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=129518 

From: Peter Jeremy <peterjeremy@acm.org>
To: bug-followup@FreeBSD.org, gerald@FreeBSD.org
Cc: Olaf Seibert <olafs@cs.ru.nl>
Subject: Re: ports/129518: lang/gcc42 - g++42 uses wrong libstdc++.so and
 libgcc_s.so
Date: Sat, 2 Jan 2010 18:07:49 +1100

 --G4iJoqBmSsgzjUCe
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 As noted in ports/142226, the same problem still exists with gcc44.
 The port does include /usr/local/lib/gcc44 in ldconfig but this has
 no effect because the system search path comes first:
 server% ldconfig -r|grep c++
         162:-lstdc++.6 =3D> /usr/lib/libstdc++.so.6
         608:-lstdc++.6 =3D> /usr/local/lib/gcc44/libstdc++.so.6
 
 As noted by Olaf, the correct fix is to insert /usr/local/lib/gcc44
 into -rpath.
 
 --=20
 Peter Jeremy
 
 --G4iJoqBmSsgzjUCe
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.14 (FreeBSD)
 
 iEYEARECAAYFAks+8MUACgkQ/opHv/APuIfMnQCfROUpsIRGYdKmDqVjCzMR1ejG
 GrgAn2mNKi5EALnmI7bVyJTJpud/uAns
 =LBho
 -----END PGP SIGNATURE-----
 
 --G4iJoqBmSsgzjUCe--

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/129518: commit references a PR
Date: Sat,  2 Jan 2010 08:11:42 +0000 (UTC)

 gerald      2010-01-02 08:11:28 UTC
 
   FreeBSD ports repository
 
   Modified files:
     Mk                   bsd.gcc.mk 
   Log:
   Add a run-time dependency for all uses of lang/gcc* except for gcc34
   which is subsumbed by later versions.  This is needed for libstdc++
   and other core run-time libraries.
   
   PR:             129518, 142226
   
   Revision  Changes    Path
   1.36      +5 -2      ports/Mk/bsd.gcc.mk
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: Gerald Pfeifer <gerald@pfeifer.com>
To: bug-followup@FreeBSD.org
Cc: Peter Jeremy <peterjeremy@acm.org>, Olaf Seibert <olafs@cs.ru.nl>
Subject: Re: ports/129518: lang/gcc42 - g++42 uses wrong libstdc++.so and
 libgcc_s.so
Date: Sat, 2 Jan 2010 14:49:06 +0100 (CET)

 On Sat, 2 Jan 2010, Peter Jeremy wrote:
 > As noted in ports/142226, the same problem still exists with gcc44.
 > The port does include /usr/local/lib/gcc44 in ldconfig but this has
 > no effect because the system search path comes first:
 > server% ldconfig -r|grep c++
 >         162:-lstdc++.6 => /usr/lib/libstdc++.so.6
 >         608:-lstdc++.6 => /usr/local/lib/gcc44/libstdc++.so.6
 
 Hmm, my original testing and understanding of USE_LDCONFIG in the
 FreeBSD Ports Collection indicated that entries coming from ports
 would get higher priority (via respective sorting) than those from
 the base.  This seems not to be the case in your setup, and also
 not in general, so I will shortly commit a variant of a patch that
 I had prepared but not committed a while ago that will set -rpath
 for ports leveraging USE_GCC, not just those levarging USE_FORTRAN.
 
 > As noted by Olaf, the correct fix is to insert /usr/local/lib/gcc44
 > into -rpath.
 
 Agreed, and that's what I had done originally; not sure why I had
 not committed my follow up patch back then in early October.  Thanks
 in any case for reminding me of this!
 
 My commit today should address this for all ports usering of USE_GCC.
 
 I am aware of the fact that some users will want to use various
 flavors of lang/gcc directly, not going through ports, and in that
 case I do not have a clearly optimal solution.  For many applications,
 specificially all(?) C code and most C++ code not using libstdc++ in
 depth using the system run-time will be sufficient, so setting this
 system-wide does not seem appropriate (given that someone that uses
 gccXY as the compiler already has done some specific setting)?
 
 (I also don't have a good idea on how to set this, to begin with, but
 that is a technical detail that I am sure someone could help address.)
 
 Gerald

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/129518: commit references a PR
Date: Sat,  2 Jan 2010 13:51:54 +0000 (UTC)

 gerald      2010-01-02 13:51:33 UTC
 
   FreeBSD ports repository
 
   Modified files:
     Mk                   bsd.gcc.mk 
   Log:
   Split the logic around USE_GCC in two parts.  The first handles the
   processing of USE_GCC directives, the second then takes a concrete
   selection coming from the previous or the code handling USE_FORTRAN
   via _USE_GCC.
   
   The one user-visible change is that not just users of USE_FORTRAN,
   but now also users of USE_GCC set an rpath via CFLAGS and LDFLAGS. [1]
   
   PR:             129518, 142226 [1]
   
   Revision  Changes    Path
   1.38      +31 -34    ports/Mk/bsd.gcc.mk
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: pgollucci 
State-Changed-When: Fri Oct 8 22:15:49 UTC 2010 
State-Changed-Why:  
Committed, Thanks 

http://www.freebsd.org/cgi/query-pr.cgi?pr=129518 
>Unformatted:
