This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


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: [PATCH] Append system library paths to environment for testprograms


On Mon, 2 Apr 2012 20:43:43 -0400
"Carlos O'Donell" <carlos@systemhalted.org> wrote:
> > There is no real difference (on the 'separation from native
> > libraries' front) between appending library search paths from the
> > compiler to test case search paths, and working with a prefix that
> > is a pre-built sysroot because the search order is what matters in
> > the end and both cases have the same search order.
>
> This doesn't make sense to me, could you please clarify and include
> an exmaple?
> 
> If you build with --prefix, then the *only* trusted directory is the
> prefix and it's an absolute path. Therefore running with a
> non-standard --prefix, and using --library-path only within the prefix
> isolates the testing from *any* system libraries. Which is the type of
> isolation you want for runtime library testing.
> 

The missing link here is the ld.so.cache. With the current
implementation, a test case is executed as:

BUNCH_OF_ENV_VARIABLES /path/to/my/ld.so \
--library-path=MY:BUILT:LIBS \
testcase {test case args} > testcase.out

My suggestion is:

BUNCH_OF_ENV_VARIABLES /path/to/my/ld.so \
--library-path=MY:BUILT:LIBS:gcc:libs \
testcase {test case args} > testcase.out

Assuming that we built with --prefix=/usr, in the first case, the
library search sequence is:

1) Look in built libraries directory
2) Look up {prefix}/etc/ld.so.cache

In the second case, the library search sequence is:

1) Look in build libraries directory
2) Look in gcc search paths
3) Look in {prefix}/etc/ld.so.cache

In case 1, we are completely isolated from native libraries as long as
we're in (1). Once we don't find the library in our built libraries
directory, we  look up /etc/ld.so.cache, which was generated by the
natively installed ldconfig and is hence subject to the native setup.

In case 2, we are again isolated from native libraries as long as we're
in (1). If we don't find the libraries in (1), we let the compiler tell
us what search path it used to find the libraries it linked into our
test case. If even that doesn't work, we use {prefix}/etc/ld.so.cache
to see if the ldconfig that *we* built generated a cache that had this
library. But at no stage do we use the ld.so.cache that was generated
by the ldconfig that is natively installed.

> (a) You configure with --prefix, and thus your only trusted directory
> is the prefix.

which, with /usr, is the entire system and hence the entire point of
isolation is lost.

--
Siddhesh


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