This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Running ldconfig


On Mon, 3 Nov 2008, Phil Blundell wrote:
> I used to have some patches to build a dynamically linked ldconfig for 
> glibc 2.3 or so, and the resulting binary always seemed to work just 
> fine.  Those patches have become somewhat bit-rotten since and don't 
> apply to newer versions but I don't think there is any reason why you 
> couldn't do the same thing with a modern glibc.

Seems like it might be an interesting option to add.  Maybe we could be 
clever and build two separate ldconfigs, ldconfig (statically linked) & 
ldconfig.dynamic?  Up to now I've not actually opened the "building glibc" 
box, just relied on crosstool-ng to do its magic for me.

> However, as you say, it is not strictly necessary to have ldconfig at
> all and more recently this is what I have been doing for embedded cases.
> You can cut down the number of directories that ld.so needs to search by
> turning off hwcap support, removing all extraneous entries from
> ld.so.conf, and coalescing your libraries into fewer directories (for
> example, if you still have /usr/X11R6/lib, move those libraries
> into /usr/lib and eliminate the search in /usr/X11R6).  For most systems
> it should be straightforward to just search /lib and /usr/lib, and with
> a bit of extra effort I think you could get down to just searching /lib
> for all libraries.

The problem seems to be that glibc goes straight to ld.so.cache, and if 
it's not there starts hunting like mad.  Heres a simple illustration of 
this:

First, with the cache present:

# strace /bin/true 2>&1 |grep open
open("/etc/ld.so.cache", O_RDONLY)      = 3
open("/lib/libm.so.6", O_RDONLY)        = 3
open("/lib/libc.so.6", O_RDONLY)        = 3
#

Mostly straight to the point (such a lot of work to set the return code ;)
Now with the cache deleted:

# strace /bin/true 2>&1 |grep open
open("/etc/ld.so.cache", O_RDONLY)      = -1 ENOENT (No such file or directory)
open("/lib/tls/v5l/fast-mult/half/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/tls/v5l/fast-mult/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/tls/v5l/half/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/tls/v5l/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/tls/fast-mult/half/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/tls/fast-mult/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/tls/half/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/tls/libm.so.6", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/lib/v5l/fast-mult/half/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/v5l/fast-mult/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/v5l/half/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/v5l/libm.so.6", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/lib/fast-mult/half/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/fast-mult/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/half/libm.so.6", O_RDONLY)   = -1 ENOENT (No such file or directory)
open("/lib/libm.so.6", O_RDONLY)        = 3
open("/lib/libc.so.6", O_RDONLY)        = 3
#

Wow!  I don't know what all those mystery libraries are, but it's 
determined to hunt them out.

--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]