[prev in list] [next in list] [prev in thread] [next in thread] 

List:       libguestfs
Subject:    Re: [Libguestfs] [PATCH nbdkit] golang: Compile against the local nbdkit build, not installed.
From:       Eric Blake <eblake () redhat ! com>
Date:       2020-04-23 17:24:48
Message-ID: 1dfbbf27-ae8d-e1a9-ed3b-76552f72d0d5 () redhat ! com
[Download RAW message or body]

On 4/23/20 11:58 AM, Daniel P. Berrangé wrote:
> On Thu, Apr 23, 2020 at 05:55:14PM +0100, Richard W.M. Jones wrote:
> > When compiling when an older nbdkit is installed, the build would fail
> > because certain symbols such as .get_ready were not defined:
> > 
> > ../../src/libguestfs.org/nbdkit/nbdkit.go:541:8: plugin.get_ready undefined (type \
> > _Ctype_struct_nbdkit_plugin has no field or method get_ready) 
> > This happens because we were using the installed <nbdkit-plugin.h>
> > rather than the local copy.
> > 
> > We don't want to modify the *.go files themselves as they might be
> > copied into other projects.  Instead we can set PKG_CONFIG to point to
> > a fake pkg-config binary which will return the correct CFLAGS.
> > 
> > Fixes: commit 1ff44288ae1cf95428283e252edd9474c3fe3b55
> > Thanks: Dan Berrangé, Eric Blake
> 
> > +# This fake pkg-config program is used to trick cgo so that
> > +# "#cgo pkg-config nbdkit" lines are processed relative to the local
> > +# directory and not the installed nbdkit.
> > +
> > +case "$1" in
> > +    --cflags*) echo "-I@abs_top_builddir@/include" ;;
> > +    *) ;;
> > +esac
> 
> Don't you need something like this too:
> 
> --libs)  echo "-L@abs_top_builddir@/lib -lnbdkit"

Also, if you're installing this in PATH prior to the real pkg-config, 
shouldn't you start by checking whether 'nbdkit' is one of the 
arguments?  If so, fall through to the 'case "$1"' code, if not, 
short-circuit into 'exec /path/to/pkg-config "$@"', so that whatever 
_other_ pkg-config queries cgo makes will be answered as usual?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic