Richard W.M. Jones
2021-Sep-08 15:48 UTC
[Libguestfs] [hivex PATCH 7/8] build: link hivex statically into C programs compiled against build dir
On Wed, Sep 08, 2021 at 03:27:57PM +0200, Laszlo Ersek wrote:> This static-only linking allows the libguestfs daemon ("guestfsd") to > launch in the appliance, without unresolved hivex symbols, when libguestfs > is built against the hivex build dir. (Libguestfs's automatic *package* > collection for the appliance, based on the shared library requirements of > "guestfsd", cannot cover hivex when hivex is provided by a local build > directory.) > > Linking hivex statically into *host-side* C programs that are compiled > against the hivex build dir is only a small penalty. > > Signed-off-by: Laszlo Ersek <lersek at redhat.com> > --- > lib/local/hivex.pc.in | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/local/hivex.pc.in b/lib/local/hivex.pc.in > index d899cb01a282..6f0b5bb44237 100644 > --- a/lib/local/hivex.pc.in > +++ b/lib/local/hivex.pc.in > @@ -32,4 +32,4 @@ Version: @VERSION@ > Description: Read and write Windows Registry Hive files. > Requires: > Cflags: -I${includedir} > -Libs: -L${libdir} -lhivex > +Libs: -L${libdir} -l:libhivex.aWorth a comment here in the .pc.in file? I was previously not aware this magic was possible. Rich.> 2.19.1.3.g30247aa5d201 > > > _______________________________________________ > Libguestfs mailing list > Libguestfs at redhat.com > https://listman.redhat.com/mailman/listinfo/libguestfs-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Laszlo Ersek
2021-Sep-09 10:39 UTC
[Libguestfs] [hivex PATCH 7/8] build: link hivex statically into C programs compiled against build dir
On 09/08/21 17:48, Richard W.M. Jones wrote:> On Wed, Sep 08, 2021 at 03:27:57PM +0200, Laszlo Ersek wrote: >> This static-only linking allows the libguestfs daemon ("guestfsd") to >> launch in the appliance, without unresolved hivex symbols, when libguestfs >> is built against the hivex build dir. (Libguestfs's automatic *package* >> collection for the appliance, based on the shared library requirements of >> "guestfsd", cannot cover hivex when hivex is provided by a local build >> directory.) >> >> Linking hivex statically into *host-side* C programs that are compiled >> against the hivex build dir is only a small penalty. >> >> Signed-off-by: Laszlo Ersek <lersek at redhat.com> >> --- >> lib/local/hivex.pc.in | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/lib/local/hivex.pc.in b/lib/local/hivex.pc.in >> index d899cb01a282..6f0b5bb44237 100644 >> --- a/lib/local/hivex.pc.in >> +++ b/lib/local/hivex.pc.in >> @@ -32,4 +32,4 @@ Version: @VERSION@ >> Description: Read and write Windows Registry Hive files. >> Requires: >> Cflags: -I${includedir} >> -Libs: -L${libdir} -lhivex >> +Libs: -L${libdir} -l:libhivex.a > > Worth a comment here in the .pc.in file? I was previously not aware > this magic was possible.How about squashing this:> diff --git a/lib/local/hivex.pc.in b/lib/local/hivex.pc.in > index 6f0b5bb44237..941638939fa3 100644 > --- a/lib/local/hivex.pc.in > +++ b/lib/local/hivex.pc.in > @@ -32,4 +32,8 @@ Version: @VERSION@ > Description: Read and write Windows Registry Hive files. > Requires: > Cflags: -I${includedir} > +# The colon notation forces an exact filename search when linking; here > +# effectively disabling shared library lookup. (Refer to "--library" in ld(1).) > +# Statically linking hivex matters mainly for "guestfsd", which runs in the > +# appliance. > Libs: -L${libdir} -l:libhivex.aThanks! Laszlo