Richard W.M. Jones
2020-Apr-23 19:13 UTC
[Libguestfs] [PATCH nbdkit v3 0/2] golang: Compile against the local nbdkit build.
Version 2: https://www.redhat.com/archives/libguestfs/2020-April/thread.html#00166 Version 3 contains all changes discussed in the previous review. Rich.
Richard W.M. Jones
2020-Apr-23 19:13 UTC
[Libguestfs] [PATCH nbdkit v3 1/2] server: Add pkg-config file for compiling against locally compiled nbdkit.
If you want to compile against a locally compiled (but not installed) nbdkit, you can now set PKG_CONFIG_PATH=/path/to/nbdkit/server/local Since it's not clear how useful this will be (we only want it for internal reasons) this is not documented. Thanks: Dan Berrangé, Eric Blake --- .gitignore | 1 + configure.ac | 1 + server/local/nbdkit.pc.in | 43 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/.gitignore b/.gitignore index 4f6fcf1b..8c701295 100644 --- a/.gitignore +++ b/.gitignore @@ -83,6 +83,7 @@ plugins/*/*.3 /plugins/tar/nbdkit-tar-plugin /plugins/tmpdisk/default-command.c /podwrapper.pl +/server/local/nbdkit.pc /server/nbdkit /server/nbdkit.pc /server/synopsis.c diff --git a/configure.ac b/configure.ac index b71d9d8c..17d8d676 100644 --- a/configure.ac +++ b/configure.ac @@ -1088,6 +1088,7 @@ AC_CONFIG_FILES([Makefile filters/truncate/Makefile filters/xz/Makefile fuzzing/Makefile + server/local/nbdkit.pc server/Makefile server/nbdkit.pc tests/functions.sh diff --git a/server/local/nbdkit.pc.in b/server/local/nbdkit.pc.in new file mode 100644 index 00000000..1d8b6bee --- /dev/null +++ b/server/local/nbdkit.pc.in @@ -0,0 +1,43 @@ +# nbdkit +# Copyright (C) 2013-2020 Red Hat Inc. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Red Hat nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +# This alternate pkg-config file may be used to compile plugins +# against a locally compiled (but not installed) nbdkit. + +prefix=@abs_top_builddir@ +exec_prefix=@abs_top_builddir@ + +Name: @PACKAGE_NAME@ +Version: @PACKAGE_VERSION@ +Description: A toolkit for creating NBD servers +Requires: +Cflags: -I@abs_top_srcdir@/include -I@abs_top_builddir@/include +Libs: -- 2.18.2
Richard W.M. Jones
2020-Apr-23 19:13 UTC
[Libguestfs] [PATCH nbdkit v3 2/2] golang: Compile against the local nbdkit build, not installed.
Compiling nbdkit from source when an older nbdkit is installed would fail because certain symbols such as .get_ready are not defined in the (installed) <nbdkit-plugin.h>: ../../src/libguestfs.org/nbdkit/nbdkit.go:541:8: plugin.get_ready undefined (type _Ctype_struct_nbdkit_plugin has no field or method get_ready) Of course we should be compiling against the local include/nbdkit-plugin.h file. We don't want to modify the *.go files themselves as they might be copied into other projects. Instead we can set PKG_CONFIG_PATH to point to server/local/nbdkit.pc which will return the correct CFLAGS. Fixes: commit 1ff44288ae1cf95428283e252edd9474c3fe3b55 Thanks: Dan Berrangé, Eric Blake --- plugins/golang/Makefile.am | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/golang/Makefile.am b/plugins/golang/Makefile.am index f189184c..10ccea18 100644 --- a/plugins/golang/Makefile.am +++ b/plugins/golang/Makefile.am @@ -66,18 +66,21 @@ noinst_DATA = \ examples/dump-plugin/nbdkit-godump-plugin.so: \ $(plugin_sources) examples/dump-plugin/dumpplugin.go cd examples/dump-plugin && \ + PKG_CONFIG_PATH="$(abs_builddir)/server/local$${PKG_CONFIG_PATH:-:$$PKG_CONFIG_PATH}" \ GOPATH="$(abs_builddir)" \ $(GOLANG) build -o nbdkit-godump-plugin.so -buildmode=c-shared examples/minimal/nbdkit-gominimal-plugin.so: \ $(plugin_sources) examples/minimal/minimal.go cd examples/minimal && \ + PKG_CONFIG_PATH="$(abs_builddir)/server/local$${PKG_CONFIG_PATH:-:$$PKG_CONFIG_PATH}" \ GOPATH="$(abs_builddir)" \ $(GOLANG) build -o nbdkit-gominimal-plugin.so -buildmode=c-shared examples/ramdisk/nbdkit-goramdisk-plugin.so: \ $(plugin_sources) examples/ramdisk/ramdisk.go cd examples/ramdisk && \ + PKG_CONFIG_PATH="$(abs_builddir)/server/local$${PKG_CONFIG_PATH:-:$$PKG_CONFIG_PATH}" \ GOPATH="$(abs_builddir)" \ $(GOLANG) build -o nbdkit-goramdisk-plugin.so -buildmode=c-shared @@ -87,6 +90,7 @@ check_DATA = test/nbdkit-gotest-plugin.so test/nbdkit-gotest-plugin.so: $(plugin_sources) test/test.go cd test && \ + PKG_CONFIG_PATH="$(abs_builddir)/server/local$${PKG_CONFIG_PATH:-:$$PKG_CONFIG_PATH}" \ GOPATH="$(abs_builddir)" \ $(GOLANG) build -o nbdkit-gotest-plugin.so -buildmode=c-shared -- 2.18.2
Eric Blake
2020-Apr-23 19:41 UTC
Re: [Libguestfs] [PATCH nbdkit v3 0/2] golang: Compile against the local nbdkit build.
On 4/23/20 2:13 PM, Richard W.M. Jones wrote:> Version 2: > https://www.redhat.com/archives/libguestfs/2020-April/thread.html#00166 > > Version 3 contains all changes discussed in the previous review.Looks good now. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Eric Blake
2020-Apr-23 19:50 UTC
Re: [Libguestfs] [PATCH nbdkit v3 2/2] golang: Compile against the local nbdkit build, not installed.
On 4/23/20 2:13 PM, Richard W.M. Jones wrote:> Compiling nbdkit from source when an older nbdkit is installed would > fail because certain symbols such as .get_ready are not defined in the > (installed) <nbdkit-plugin.h>: > > ../../src/libguestfs.org/nbdkit/nbdkit.go:541:8: plugin.get_ready undefined (type _Ctype_struct_nbdkit_plugin has no field or method get_ready) > > Of course we should be compiling against the local > include/nbdkit-plugin.h file. > > We don't want to modify the *.go files themselves as they might be > copied into other projects. Instead we can set PKG_CONFIG_PATH to > point to server/local/nbdkit.pc which will return the correct CFLAGS. > > Fixes: commit 1ff44288ae1cf95428283e252edd9474c3fe3b55 > Thanks: Dan Berrangé, Eric Blake > ---> +++ b/plugins/golang/Makefile.am > @@ -66,18 +66,21 @@ noinst_DATA = \ > examples/dump-plugin/nbdkit-godump-plugin.so: \ > $(plugin_sources) examples/dump-plugin/dumpplugin.go > cd examples/dump-plugin && \ > + PKG_CONFIG_PATH="$(abs_builddir)/server/local$${PKG_CONFIG_PATH:-:$$PKG_CONFIG_PATH}" \Ooops, I typod this one. unset foo barblah=set echo "pre${foo:-:$foo}" echo "pre${bar:-:$bar}" echo "pre${bar:-:$blah}" shows that :- was the wrong operator. Better is :+. All four sites need it. But even then, I'm still getting build failures; and make V=1 shows that PKG_CONFIG_PATH is getting set correctly :( -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Seemingly Similar Threads
- Re: [PATCH nbdkit v3 2/2] golang: Compile against the local nbdkit build, not installed.
- [PATCH nbdkit 0/2 v2] golang: Compile against the local nbdkit build.
- [PATCH nbdkit v3 2/2] golang: Compile against the local nbdkit build, not installed.
- [PATCH nbdkit 2/2] golang: Compile against the local nbdkit build, not installed.
- [PATCH nbdkit] golang: Compile against the local nbdkit build, not installed.