rtld or lang/gcc cannot find libgcc_s.so.1

Steve Kargl sgk at troutmask.apl.washington.edu
Tue Feb 21 22:32:53 UTC 2012

On Tue, Feb 21, 2012 at 05:00:53PM -0500, Diane Bruce wrote:
> On Tue, Feb 21, 2012 at 10:37:15PM +0100, Dimitry Andric wrote:
> > On 2012-02-21 20:42, Steve Kargl wrote:
> > ...
> > > Yes, /lib comes before /usr/local/lib/gcc46.  I suppose
> > > that this is a heads up for gerald at . lang/gcc is used by
> > > the ports collections to build a large number of other
> > > ports, so others are likely to hit this issue.
> Does -rpath not help ?

I already mentioned that I can add '-rpath /usr/local/lib/gcc46'
to my various projects.  I can also build with -static to avoid
rtld.  One can also use LD_LIBRARY_PATH.  

The issue seems to be that lang/gcc will be installed after
system start, and 'ldconfig -m' appends new shared libraries
to the hints file.  This means that libraries with the same
name but different locations will be found via the order of the
search path in the hints file, and one gets the wrong library.
That is, with the following

troutmask:root[256] ldconfig -r | grep libgcc_s
        29:-lgcc_s.1 => /lib/libgcc_s.so.1
        723:-lgcc_s.1 => /usr/local/lib/gcc46/libgcc_s.so.1

29 will be found before 723.  While I can work around the
issue, lang/gcc is used by a rather large boatload of ports
during the building process and I suspect that a large 
number of FreeBSD users use lang/gcc for their everyday
compiler.  The question is how do we, the FreeBSD project,
deal with this issue, so that the general user base does not
get hit with it. 

There are a few solutions:
1) Set ldconfig_paths in /etc/rc.conf to cause ${PORTSDIR}/lib to
   be scanned before /lib and /usr/lib.
2) Use /etc/ld.so.conf to cause ${PORTSDIR}/lib to be scanned
   for /lib and /usr/lib.
3) Add a new option to ldconfig to prepend new libraries to
   the hints files and fix the ports to use this option instead
   of -m.
4) Suggestions from people that are brighter than I.


More information about the freebsd-ports mailing list