[libvirt] [PATCH] build: Fix VPATH build with new probes

Note that make check still fails for me in VPATH build because od undefined references in libvirt_test.a which I don't really understand since src/Makefile.am contains libvirt_la_LIBADD += probes.o libvirt_test_la_LIBADD = $(libvirt_la_LIBADD) This is a sample of the erros I get: ../src/.libs/libvirt_test.a(libvirt_net_rpc_client_la-virnetclient.o): In function `virNetClientCallDispatch': /home/jirka/work/libvirt/git/upstream/src/rpc/virnetclient.c:690: undefined reference to `libvirt_rpc_client_msg_rx_semaphore' ../src/.libs/libvirt_test.a(libvirt_net_rpc_client_la-virnetclient.o): In function `virNetClientRef': /home/jirka/work/libvirt/git/upstream/src/rpc/virnetclient.c:234: undefined reference to `libvirt_rpc_client_ref_semaphore' ../src/.libs/libvirt_test.a(libvirt_net_rpc_client_la-virnetclient.o): --- daemon/Makefile.am | 2 +- tests/Makefile.am | 2 +- tools/Makefile.am | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/Makefile.am b/daemon/Makefile.am index e7821b2..e8c47ae 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -6,7 +6,7 @@ INCLUDES = \ -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \ -I$(top_srcdir)/include -I$(top_builddir)/include \ - -I$(top_srcdir)/src \ + -I$(top_srcdir)/src -I../src \ -I$(top_srcdir)/src/util \ -I$(top_srcdir)/src/conf \ -I$(top_srcdir)/src/rpc \ diff --git a/tests/Makefile.am b/tests/Makefile.am index cbbbc6f..7b80d17 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -9,7 +9,7 @@ INCLUDES = \ -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \ -I$(top_builddir)/include \ -I$(top_srcdir)/include \ - -I$(top_srcdir)/src \ + -I$(top_srcdir)/src -I../src \ -I$(top_srcdir)/src/util \ -I$(top_srcdir)/src/conf \ $(GETTEXT_CPPFLAGS) diff --git a/tools/Makefile.am b/tools/Makefile.am index 71131e2..8a8be1a 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -4,7 +4,7 @@ INCLUDES = \ -I../include -I$(top_srcdir)/include \ -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \ - -I$(top_srcdir)/src \ + -I$(top_srcdir)/src -I../src \ -I$(top_srcdir)/src/util \ -I$(top_srcdir) \ $(GETTEXT_CPPFLAGS) -- 1.7.7

On 10/11/2011 08:49 AM, Jiri Denemark wrote:
Note that make check still fails for me in VPATH build because od undefined references in libvirt_test.a which I don't really understand since src/Makefile.am contains libvirt_la_LIBADD += probes.o libvirt_test_la_LIBADD = $(libvirt_la_LIBADD)
This is a sample of the erros I get:
../src/.libs/libvirt_test.a(libvirt_net_rpc_client_la-virnetclient.o): In function `virNetClientCallDispatch': /home/jirka/work/libvirt/git/upstream/src/rpc/virnetclient.c:690: undefined reference to `libvirt_rpc_client_msg_rx_semaphore' ../src/.libs/libvirt_test.a(libvirt_net_rpc_client_la-virnetclient.o): In function `virNetClientRef': /home/jirka/work/libvirt/git/upstream/src/rpc/virnetclient.c:234: undefined reference to `libvirt_rpc_client_ref_semaphore' ../src/.libs/libvirt_test.a(libvirt_net_rpc_client_la-virnetclient.o): --- daemon/Makefile.am | 2 +- tests/Makefile.am | 2 +- tools/Makefile.am | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/daemon/Makefile.am b/daemon/Makefile.am index e7821b2..e8c47ae 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -6,7 +6,7 @@ INCLUDES = \ -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \ -I$(top_srcdir)/include -I$(top_builddir)/include \ - -I$(top_srcdir)/src \ + -I$(top_srcdir)/src -I../src \
ACK - this says to pick up .h files from both srcdir and builddir, with a preference for srcdir. It makes no difference on in-tree builds, but helps VPATH builds where we now generate a .h file, and matches the gnulib pattern several lines above (since gnulib also has both srcdir and generated builddir .h files). -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 10/11/2011 08:49 AM, Jiri Denemark wrote:
Note that make check still fails for me in VPATH build because od undefined references in libvirt_test.a which I don't really understand since src/Makefile.am contains libvirt_la_LIBADD += probes.o libvirt_test_la_LIBADD = $(libvirt_la_LIBADD)
This is a sample of the erros I get:
../src/.libs/libvirt_test.a(libvirt_net_rpc_client_la-virnetclient.o): In function `virNetClientCallDispatch': /home/jirka/work/libvirt/git/upstream/src/rpc/virnetclient.c:690: undefined reference to `libvirt_rpc_client_msg_rx_semaphore' ../src/.libs/libvirt_test.a(libvirt_net_rpc_client_la-virnetclient.o): In function `virNetClientRef': /home/jirka/work/libvirt/git/upstream/src/rpc/virnetclient.c:234: undefined reference to `libvirt_rpc_client_ref_semaphore' ../src/.libs/libvirt_test.a(libvirt_net_rpc_client_la-virnetclient.o):
In looking at this further, it looks like the libtool warnings are relevant: *** Warning: Linking the shared library libvirt.la against the non-libtool *** objects probes.o is not portable! When creating libvirt.la (the libtool driver for the eventual installed libvirt.so), the warning is issued, but libtool still compiles probe.o into the overall library for any platform that can handle it (Linux can, and we don't build probe.o anywhere else, so we are okay). This compilation is done via $CC. But libvirt_test.la is a different beast - since it is never installed, but just a convenience library, libtool creates the library using raw invocations of '$AR cru' from the piecemeal list of .o files extracted from each other convenience library, and omits probe.o. Perhaps we could argue that this is a libtool bug for not putting .o files into convenience libraries, even though it does so for installed libraries. But getting that fixed in libtool, then requiring the newer libtool before we can build libvirt in the future, seems time-consuming. On the other hand, looking further, src/Makefile.am ends up building the libvirt_lxc executable, and explicitly adds probes.o to libvirt_lxc_LDADD, which then gets compiled in without any warnings. So it looks like instead of trying to jam probes.o into libvirt_test.la, we should instead tweak tests/Makefile.am so that every executable that links against libvirt_test.la also links against probes.o, similar to how libvirt_lxc_LDADD worked for that executable. I'm still playing with the issue, but hope to have 'make check' working again sometime today. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Building on Linux with dtrace enabled was failing 'make check': CCLD nodeinfotest ../src/.libs/libvirt_test.a(libvirt_net_rpc_client_la-virnetclient.o): In function `virNetClientNew': /home/remote/eblake/libvirt/src/rpc/virnetclient.c:162: undefined reference to `libvirt_rpc_client_new_semaphore' On looking further, I see some earlier warnings emitted from libtool: *** Warning: Linking the shared library libvirt.la against the non-libtool *** objects probes.o is not portable! Since src/probes.o is only built on Linux, and even then, only when dtrace is enabled, this failure does not affect other platforms, and despite libtool warning that it is not generally portable, it is not a problem for our use-case in libvirt.la. But it turns out that while libtool is willing to jam raw .o files into an installed shared library (libvirt.la becomes libvirt.so), it is NOT willing to jam the same .o file into the convenience library libvirt_test.la. Perhaps this is a bug in libtool, but even if we get libtool fixed, libvirt must continue to build on platforms with older libtool. So, the fix is the same as we are already using for the libvirt_lxc executable - don't rely on the .o file being in the convenience library, but instead use LDADD to pull it in directly. * tests/Makefile.am (PROBES_O): New macro. (LDADDS): Use it to fix link errors. --- I'm still in the middle of running ./autobuild.sh, but if that fixes the VPATH build there, then I will push this under the build-breaker rule. tests/Makefile.am | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index cbbbc6f..8202fa0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -29,6 +29,11 @@ INCLUDES += \ -DTEST_DRIVER_DIR=\"$(top_builddir)/src/.libs\" endif +PROBES_O = +if WITH_DTRACE +PROBES_O += ../src/probes.o +endif + LDADDS = \ $(STATIC_BINARIES) \ $(LIBXML_LIBS) \ @@ -39,6 +44,7 @@ LDADDS = \ $(YAJL_LIBS) \ $(WARN_CFLAGS) \ ../src/libvirt_test.la \ + $(PROBES_O) \ ../gnulib/lib/libgnu.la \ $(LIBSOCKET) \ $(COVERAGE_LDFLAGS) -- 1.7.4.4

On Tue, Oct 11, 2011 at 13:54:40 -0600, Eric Blake wrote:
Building on Linux with dtrace enabled was failing 'make check':
CCLD nodeinfotest ../src/.libs/libvirt_test.a(libvirt_net_rpc_client_la-virnetclient.o): In function `virNetClientNew': /home/remote/eblake/libvirt/src/rpc/virnetclient.c:162: undefined reference to `libvirt_rpc_client_new_semaphore'
On looking further, I see some earlier warnings emitted from libtool:
*** Warning: Linking the shared library libvirt.la against the non-libtool *** objects probes.o is not portable!
Since src/probes.o is only built on Linux, and even then, only when dtrace is enabled, this failure does not affect other platforms, and despite libtool warning that it is not generally portable, it is not a problem for our use-case in libvirt.la. But it turns out that while libtool is willing to jam raw .o files into an installed shared library (libvirt.la becomes libvirt.so), it is NOT willing to jam the same .o file into the convenience library libvirt_test.la. Perhaps this is a bug in libtool, but even if we get libtool fixed, libvirt must continue to build on platforms with older libtool. So, the fix is the same as we are already using for the libvirt_lxc executable - don't rely on the .o file being in the convenience library, but instead use LDADD to pull it in directly.
* tests/Makefile.am (PROBES_O): New macro. (LDADDS): Use it to fix link errors. ---
I'm still in the middle of running ./autobuild.sh, but if that fixes the VPATH build there, then I will push this under the build-breaker rule.
tests/Makefile.am | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
I pushed my patch and checked that your patch fixes the make check errors in VPATH build. ACK Jirka

On 10/11/2011 01:59 PM, Jiri Denemark wrote:
On Tue, Oct 11, 2011 at 13:54:40 -0600, Eric Blake wrote:
Building on Linux with dtrace enabled was failing 'make check':
CCLD nodeinfotest ../src/.libs/libvirt_test.a(libvirt_net_rpc_client_la-virnetclient.o): In function `virNetClientNew': /home/remote/eblake/libvirt/src/rpc/virnetclient.c:162: undefined reference to `libvirt_rpc_client_new_semaphore'
I'm still in the middle of running ./autobuild.sh, but if that fixes the VPATH build there, then I will push this under the build-breaker rule.
tests/Makefile.am | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
I pushed my patch and checked that your patch fixes the make check errors in VPATH build.
ACK
My testing passed as well. Now pushed. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Jiri Denemark