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

Re: [libvirt PATCH v2 1/1] meson: Drop RPATH usage



On Wed, Aug 19, 2020 at 02:58:07PM +0200, Andrea Bolognani wrote:
> On Wed, 2020-08-19 at 13:16 +0100, Daniel P. Berrangé wrote:
> > On Wed, Aug 19, 2020 at 02:10:53PM +0200, Pavel Hrdina wrote:
> > > So I managed to remember what was the issue. If you run install libvirt
> > > into custom directory like this:
> > > 
> > >     meson build --prefix /my/custom/dir
> > >     ninja -C build install
> > > 
> > > and after that running:
> > > 
> > >     /my/custom/dir/bin/virsh
> > > 
> > > will fail with:
> > > 
> > >     /lib64/libvirt.so.0: version `LIBVIRT_PRIVATE_6.7.0' not found (required by ./bin/bin/virsh)
> > > 
> > > This is what autotools did by default as well and I did not know that
> > > there is an option --disable-rpath as it's not in output of
> > > `./configure --help`.
> 
> I checked again and it looks like that option does indeed not exist.
> The Debian package was using it, but it was just ignored I guess.
> 
> > > If we don't care about the use case of installing libvirt into custom
> > > prefix and breaking it it should be OK to remove this from meson but my
> > > guess is that we should not do it.
> > 
> > So it is only broken if you failed to set LD_LIBRARY_PATH.
> > 
> > rpath is basically hardcoding the association between the virsh
> > binary and the library so that it doesn't need LD_LIBRARY_PATH.
> > 
> > I'm ambivalent on whether that's important or not, though admittedly
> > it can avoid surprises for users not used to LD_LIBRARY_PATH type
> > issues.
> > 
> > IIUC, meson  sets rpath automatically for the binaries so you can
> > run from the non-installed build dir. When you run install, it
> > then strips the rpath for the build dir, optionally replacing it
> > with the "install_rpath" value.
> 
> I tested with v6.6.0 and using
> 
>   $ ../autogen.sh --prefix=/some/dir
> 
> results in RPATH being added to the various binaries, but
> 
>   $ ../autogen.sh --prefix=/usr
> 
> doesn't. So I guess autotools are smart enough to only add RPATH when
> you're actually installing outside of the standard library search
> paths, and skip it otherwise. That's why it never showed up in distro
> packages.
> 
> We could reasonably implement the same logic in Meson ourselves,
> however...
> 
> > > We can add an option like it was proposed in V1 but with the following
> > > changes. In meson.build we would have this:
> > > 
> > >     if get_option('rpath')
> > >       libvirt_rpath = libdir
> > >     else
> > >       libvirt_rpath = ''
> > >     endif
> > > 
> > > and all places with install_rpath would use libvirt_rpath instead of
> > > libdir directly and we would not have to have the craze if-else.
> > 
> > Yeah that would be simpler.
> 
> ... I don't think this would work: using
> 
>   install_rpath: ''
> 
> will result in an empty RPATH being set, not in RPATH being missing.
> So it's a different behavior than the one we want.

I specifically tried this to make sure it works and also this is from
meson code:

    self.install_rpath = kwargs.get('install_rpath', '')

so yes it works.

> Maybe there's a better way to do it, but right now I'm sort of
> inclined to just declare that people who install libvirt under custom
> prefixes will have to take care of adding the corresponding paths to
> /etc/ld.so.conf or use $LD_LIBRARY_PATH.
> 
> -- 
> Andrea Bolognani / Red Hat / Virtualization
> 

Attachment: signature.asc
Description: PGP signature


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