[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ocaml compiled binaries and rpath



On Wed, Apr 16, 2003 at 12:27:59AM +0200, Denis Barbier wrote:
> This was for the libc migration.
> 
> AFAICT OCaml situation is very different:
>  * library location is not well established

Yes and no. We standardized the dll.so location in the stublibs
directory, and most of the time this is enough. Users or rogue packages
can still install stuff all over the place.

But i have the feeling that that the rpath is not really there to find
the stublibs, which are found by the ocaml ld.conf file, but to find the
C libraries these stublibs wrap, and this is why directories like
/usr/lib and /usr/X11R6/lib are used. And especially you are not
supposed to link a stublib from another.

So, my impression is that the rpath are usefull for homemade stublibs,
but can be safely ignored for debian packages.

>  * there are no sonames (is it true?), and this makes a huge difference

No, there are not.

> >  Instead he hard-coded the stublibs directory in the produced code,
> >  so that the loader does not complain.
> >  One trick is for the linker, the other one for the loader.
> >  The second trick works only for the stublibs directory. The first one
> >  always work (but makes lintian complain). Moreover there is also the
> >  symbolic link trick from dllname.so to libname.so that should be done
> >  by hand.
> 
> Now back to your example.  When packaging programs, we usually
>   a. build libraries
>   b. build binaries against these libraries
>   c. test binaries
>   d. install libraries and binaries if everything worked fine
> 
> You showed how to use -rpath to perform these operations, but remember
> that as package managers we do not install files to their definitive
> location, but to a staging area.
> So let's try something else; imagine that your staging area is /tmp,
> then you compile with -rpath=/rpath/installed.  In order to prevent
> linkage and execution failures, you set LD_LIBRARY_PATH to
> /tmp/rpath/installed, and it works!  Great.
> 
> But there is one major problem, imagine that you installed everything,
> and 3 months later there is a new release.  You compile as usual,
> and it seems to work, but in fact you run test binaries against
> *old* installed libraries, because rpath is searched before LD_LIBRARY_PATH
> and it contains the requested files.  It is really painful, because
> those errors are very hard to diagnose.
> 
> I do not know of any viable solution to build packages because of
> this problem, old libraries must be removed before building.
> One might propose to Build-Conflicts against previous library versions,
> but is it really what we want? ;)

No need, for debian package we currently have only one version of the
packages installed, one version for a given ocaml version that is.

I am not convinced we need more, or more exactly that it is sane to do
more when not having a good soname scheme.

> >  What happens if you remove the -rpath from a debian package? You may
> >  break the compilation processes of other people that are expecting
> >  your library to have the -rpath and that do not have the LD_LIBRARY_PATH
> >  set to stublibs (or other strange directories).
> 
> I do not follow you.  OCaml is configured so that libraries are found in
> the stublibs directory, so there is no need for LD_LIBRARY_PATH, and this
> is good.
> The -rpath is useful if you have 2 incompatible versions of the same
> library in different locations, and you want to link against a specific
> one.
> AFAICT this does only make sense with 3rd party softwares, I cannot find
> any example where -rpath is useful for Debian packages.

Yes, that is also my supposition.

> As stated above it is harmful because you cannot test programs when
> building them.  Moving libraries is also a bit tricky, you have to
> set LD_LIBRARY_PATH if you want your programs to run.

We don't really care about that, there is only one installed version of
the library, and we don't move them around.

> >  Final note: of course the problem solved by rpath was much more critical
> >  _before_ the introduction of the single stublib directory (those times
> >  when my LD_LIBRARY_PATH used to be several lines long).
> > 
> >  I hope that all this could be useful to somebody: my wirst is aching!
> 
> Sure, your example was really great, it helped me a lot to understand
> how to compile OCaml libraries.

Friendly,

Sven Luther



Reply to: