[libvirt] [PATCH] fix compilation failure under tests/

Without this, I get errors like /usr/bin/ld: virnettlscontexttest.o: undefined reference to symbol 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' /usr/bin/ld: note: 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' is defined in DSO /usr/lib/x86_64-linux-gnu/libgnutls.so.26 so try adding it to the linker command line /usr/lib/x86_64-linux-gnu/libgnutls.so.26: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status (and onward in sequence) - since at least 1.0.2 on Ubuntu systems. (Oddly, only if gnutls is installed - uninstalling it allows the compilation to complete, so it hasn't been crucial on our builders, just annoying when building by hand). Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> --- tests/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 3abd698..99d70d2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -36,7 +36,8 @@ PROBES_O += ../src/libvirt_probes.lo endif LDADDS = \ - $(WARN_CFLAGS) \ + $(GNUTLS_LIBS) $(LIBXML_LIBS) $(DBUS_LIBS) \ + $(WARN_CFLAGS) \ $(PROBES_O) \ ../src/libvirt.la \ ../gnulib/lib/libgnu.la -- 1.8.1.2

On 04/05/2013 08:44 PM, Serge Hallyn wrote:
Without this, I get errors like
/usr/bin/ld: virnettlscontexttest.o: undefined reference to symbol 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' /usr/bin/ld: note: 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' is defined in DSO /usr/lib/x86_64-linux-gnu/libgnutls.so.26 so try adding it to the linker command line /usr/lib/x86_64-linux-gnu/libgnutls.so.26: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status
(and onward in sequence) - since at least 1.0.2 on Ubuntu systems. (Oddly, only if gnutls is installed - uninstalling it allows the compilation to complete, so it hasn't been crucial on our builders, just annoying when building by hand).
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> --- tests/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am index 3abd698..99d70d2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -36,7 +36,8 @@ PROBES_O += ../src/libvirt_probes.lo endif
LDADDS = \ - $(WARN_CFLAGS) \ + $(GNUTLS_LIBS) $(LIBXML_LIBS) $(DBUS_LIBS) \ + $(WARN_CFLAGS) \
Do we really want this linked into ALL test executables, or should you be limiting it to just virnettlscontexttest_LDADD? I'd at least like to try the latter, as I'm a fan of not linking in unused libraries. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Sat, Apr 06, 2013 at 07:17:30AM -0600, Eric Blake wrote:
On 04/05/2013 08:44 PM, Serge Hallyn wrote:
Without this, I get errors like
/usr/bin/ld: virnettlscontexttest.o: undefined reference to symbol 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' /usr/bin/ld: note: 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' is defined in DSO /usr/lib/x86_64-linux-gnu/libgnutls.so.26 so try adding it to the linker command line /usr/lib/x86_64-linux-gnu/libgnutls.so.26: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status
(and onward in sequence) - since at least 1.0.2 on Ubuntu systems. (Oddly, only if gnutls is installed - uninstalling it allows the compilation to complete, so it hasn't been crucial on our builders, just annoying when building by hand).
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> --- tests/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am index 3abd698..99d70d2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -36,7 +36,8 @@ PROBES_O += ../src/libvirt_probes.lo endif
LDADDS = \ - $(WARN_CFLAGS) \ + $(GNUTLS_LIBS) $(LIBXML_LIBS) $(DBUS_LIBS) \ + $(WARN_CFLAGS) \
Do we really want this linked into ALL test executables, or should you be limiting it to just virnettlscontexttest_LDADD? I'd at least like to try the latter, as I'm a fan of not linking in unused libraries.
Yep, we should only link libraries to the tests which actually need them. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

Some tests fail to build without libxml2 or libdbus specified, add them where needed. Without this, I get errors like /usr/bin/ld: virnettlscontexttest.o: undefined reference to symbol 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' /usr/bin/ld: note: 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' is defined in DSO /usr/lib/x86_64-linux-gnu/libgnutls.so.26 so try adding it to the linker command line /usr/lib/x86_64-linux-gnu/libgnutls.so.26: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> --- tests/Makefile.am | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 3abd698..51782a1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -351,40 +351,40 @@ qemu_LDADDS += $(LDADDS) qemuxml2argvtest_SOURCES = \ qemuxml2argvtest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h -qemuxml2argvtest_LDADD = $(qemu_LDADDS) +qemuxml2argvtest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) qemuxml2xmltest_SOURCES = \ qemuxml2xmltest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h -qemuxml2xmltest_LDADD = $(qemu_LDADDS) +qemuxml2xmltest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) qemuxmlnstest_SOURCES = \ qemuxmlnstest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h -qemuxmlnstest_LDADD = $(qemu_LDADDS) +qemuxmlnstest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) qemuargv2xmltest_SOURCES = \ qemuargv2xmltest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h -qemuargv2xmltest_LDADD = $(qemu_LDADDS) +qemuargv2xmltest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) qemuhelptest_SOURCES = qemuhelptest.c testutils.c testutils.h -qemuhelptest_LDADD = $(qemu_LDADDS) +qemuhelptest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) qemumonitortest_SOURCES = qemumonitortest.c testutils.c testutils.h -qemumonitortest_LDADD = $(qemu_LDADDS) +qemumonitortest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) qemumonitorjsontest_SOURCES = \ qemumonitorjsontest.c \ testutils.c testutils.h \ testutilsqemu.c testutilsqemu.h \ $(NULL) -qemumonitorjsontest_LDADD = $(qemu_LDADDS) libqemumonitortestutils.la +qemumonitorjsontest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) libqemumonitortestutils.la domainsnapshotxml2xmltest_SOURCES = \ domainsnapshotxml2xmltest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h -domainsnapshotxml2xmltest_LDADD = $(qemu_LDADDS) +domainsnapshotxml2xmltest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) else EXTRA_DIST += qemuxml2argvtest.c qemuxml2xmltest.c qemuargv2xmltest.c \ qemuxmlnstest.c qemuhelptest.c domainsnapshotxml2xmltest.c \ @@ -451,7 +451,7 @@ if WITH_NETWORK networkxml2conftest_SOURCES = \ networkxml2conftest.c \ testutils.c testutils.h -networkxml2conftest_LDADD = ../src/libvirt_driver_network_impl.la $(LDADDS) +networkxml2conftest_LDADD = ../src/libvirt_driver_network_impl.la $(LDADDS) $(XML_LIBS) $(DBUS_LIBS) else EXTRA_DIST += networkxml2conftest.c endif @@ -500,7 +500,7 @@ interfacexml2xmltest_LDADD = $(LDADDS) cputest_SOURCES = \ cputest.c \ testutils.c testutils.h -cputest_LDADD = $(LDADDS) +cputest_LDADD = $(LDADDS) $(LIBXML_LIBS) virshtest_SOURCES = \ virshtest.c \ @@ -548,7 +548,7 @@ virnettlscontexttest_SOURCES = \ virnettlscontexttest_LDADD = $(LDADDS) if HAVE_LIBTASN1 virnettlscontexttest_SOURCES += pkix_asn1_tab.c -virnettlscontexttest_LDADD += -ltasn1 +virnettlscontexttest_LDADD += -ltasn1 $(GNUTLS_LIBS) else EXTRA_DIST += pkix_asn1_tab.c endif -- 1.8.1.2

On Mon, Apr 08, 2013 at 07:54:55AM -0500, Serge Hallyn wrote:
Some tests fail to build without libxml2 or libdbus specified, add them where needed.
Without this, I get errors like
/usr/bin/ld: virnettlscontexttest.o: undefined reference to symbol 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' /usr/bin/ld: note: 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' is defined in DSO /usr/lib/x86_64-linux-gnu/libgnutls.so.26 so try adding it to the linker command line /usr/lib/x86_64-linux-gnu/libgnutls.so.26: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status
So this makes sense because virnettlscontexttest.c directly calls various TLS APIs, and so needs to link to gnutls. I'm not seeing why you need to add dbus + libxml to all these other tests though. What errors are you getting from them ? Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

Quoting Daniel P. Berrange (berrange@redhat.com):
On Mon, Apr 08, 2013 at 07:54:55AM -0500, Serge Hallyn wrote:
Some tests fail to build without libxml2 or libdbus specified, add them where needed.
Without this, I get errors like
/usr/bin/ld: virnettlscontexttest.o: undefined reference to symbol 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' /usr/bin/ld: note: 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' is defined in DSO /usr/lib/x86_64-linux-gnu/libgnutls.so.26 so try adding it to the linker command line /usr/lib/x86_64-linux-gnu/libgnutls.so.26: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status
So this makes sense because virnettlscontexttest.c directly calls various TLS APIs, and so needs to link to gnutls.
I'm not seeing why you need to add dbus + libxml to all these other tests though. What errors are you getting from them ?
I incrementally added them one by one, as I got DSO errors about libxml2 and dbus as below, in sequence: CCLD qemuxml2argvtest /usr/bin/ld: ../src/.libs/libvirt_driver_qemu_impl.a(libvirt_driver_qemu_impl_la-qemu_domain.o): undefined reference to symbol 'xmlXPathRegisterNs@@LIBXML2_2.4.30' /usr/bin/ld: note: 'xmlXPathRegisterNs@@LIBXML2_2.4.30' is defined in DSO /usr/lib/x86_64-linux-gnu/libxml2.so.2 so try adding it to the linker command line /usr/lib/x86_64-linux-gnu/libxml2.so.2: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status [ and ] /usr/bin/ld: ../src/.libs/libvirt_driver_network_impl.a(libvirt_driver_network_impl_la-bridge_driver.o): undefined reference to symbol 'dbus_bus_add_match' /usr/bin/ld: note: 'dbus_bus_add_match' is defined in DSO /lib/x86_64-linux-gnu/libdbus-1.so.3 so try adding it to the linker command line /lib/x86_64-linux-gnu/libdbus-1.so.3: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status Looking back now at the patch, I see that the virnettlscontexttest hunk is bad - it shouldn't be under the ifdefs. New patch below:
From 07d4ce365c19727d450729a51e868ebbe5d6231a Mon Sep 17 00:00:00 2001 From: Serge Hallyn <serge.hallyn@ubuntu.com> Date: Mon, 8 Apr 2013 12:52:05 +0000 Subject: [PATCH 1/1] Link libxml2 and libdbus in tests which need it (v3)
Some tests fail to build without libxml2 or libdbus specified, add them where needed. Without this, I get errors like /usr/bin/ld: virnettlscontexttest.o: undefined reference to symbol 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' /usr/bin/ld: note: 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' is defined in DSO /usr/lib/x86_64-linux-gnu/libgnutls.so.26 so try adding it to the linker command line /usr/lib/x86_64-linux-gnu/libgnutls.so.26: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status Changelog: move the virnettlscontexttest GNUTLS_LIBS include out of tasn1 ifdef. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> --- tests/Makefile.am | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 3abd698..4b5cf6d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -351,40 +351,40 @@ qemu_LDADDS += $(LDADDS) qemuxml2argvtest_SOURCES = \ qemuxml2argvtest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h -qemuxml2argvtest_LDADD = $(qemu_LDADDS) +qemuxml2argvtest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) qemuxml2xmltest_SOURCES = \ qemuxml2xmltest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h -qemuxml2xmltest_LDADD = $(qemu_LDADDS) +qemuxml2xmltest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) qemuxmlnstest_SOURCES = \ qemuxmlnstest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h -qemuxmlnstest_LDADD = $(qemu_LDADDS) +qemuxmlnstest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) qemuargv2xmltest_SOURCES = \ qemuargv2xmltest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h -qemuargv2xmltest_LDADD = $(qemu_LDADDS) +qemuargv2xmltest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) qemuhelptest_SOURCES = qemuhelptest.c testutils.c testutils.h -qemuhelptest_LDADD = $(qemu_LDADDS) +qemuhelptest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) qemumonitortest_SOURCES = qemumonitortest.c testutils.c testutils.h -qemumonitortest_LDADD = $(qemu_LDADDS) +qemumonitortest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) qemumonitorjsontest_SOURCES = \ qemumonitorjsontest.c \ testutils.c testutils.h \ testutilsqemu.c testutilsqemu.h \ $(NULL) -qemumonitorjsontest_LDADD = $(qemu_LDADDS) libqemumonitortestutils.la +qemumonitorjsontest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) libqemumonitortestutils.la domainsnapshotxml2xmltest_SOURCES = \ domainsnapshotxml2xmltest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h -domainsnapshotxml2xmltest_LDADD = $(qemu_LDADDS) +domainsnapshotxml2xmltest_LDADD = $(qemu_LDADDS) $(LIBXML_LIBS) $(DBUS_LIBS) else EXTRA_DIST += qemuxml2argvtest.c qemuxml2xmltest.c qemuargv2xmltest.c \ qemuxmlnstest.c qemuhelptest.c domainsnapshotxml2xmltest.c \ @@ -451,7 +451,7 @@ if WITH_NETWORK networkxml2conftest_SOURCES = \ networkxml2conftest.c \ testutils.c testutils.h -networkxml2conftest_LDADD = ../src/libvirt_driver_network_impl.la $(LDADDS) +networkxml2conftest_LDADD = ../src/libvirt_driver_network_impl.la $(LDADDS) $(XML_LIBS) $(DBUS_LIBS) else EXTRA_DIST += networkxml2conftest.c endif @@ -500,7 +500,7 @@ interfacexml2xmltest_LDADD = $(LDADDS) cputest_SOURCES = \ cputest.c \ testutils.c testutils.h -cputest_LDADD = $(LDADDS) +cputest_LDADD = $(LDADDS) $(LIBXML_LIBS) virshtest_SOURCES = \ virshtest.c \ @@ -545,7 +545,7 @@ virnetsockettest_LDADD = $(LDADDS) if WITH_GNUTLS virnettlscontexttest_SOURCES = \ virnettlscontexttest.c testutils.h testutils.c -virnettlscontexttest_LDADD = $(LDADDS) +virnettlscontexttest_LDADD = $(LDADDS) $(GNUTLS_LIBS) if HAVE_LIBTASN1 virnettlscontexttest_SOURCES += pkix_asn1_tab.c virnettlscontexttest_LDADD += -ltasn1 -- 1.8.1.2

On Mon, Apr 08, 2013 at 08:41:27AM -0500, Serge Hallyn wrote:
Quoting Daniel P. Berrange (berrange@redhat.com):
On Mon, Apr 08, 2013 at 07:54:55AM -0500, Serge Hallyn wrote:
Some tests fail to build without libxml2 or libdbus specified, add them where needed.
Without this, I get errors like
/usr/bin/ld: virnettlscontexttest.o: undefined reference to symbol 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' /usr/bin/ld: note: 'gnutls_x509_crt_set_activation_time@@GNUTLS_1_4' is defined in DSO /usr/lib/x86_64-linux-gnu/libgnutls.so.26 so try adding it to the linker command line /usr/lib/x86_64-linux-gnu/libgnutls.so.26: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status
So this makes sense because virnettlscontexttest.c directly calls various TLS APIs, and so needs to link to gnutls.
I'm not seeing why you need to add dbus + libxml to all these other tests though. What errors are you getting from them ?
I incrementally added them one by one, as I got DSO errors about libxml2 and dbus as below, in sequence:
CCLD qemuxml2argvtest /usr/bin/ld: ../src/.libs/libvirt_driver_qemu_impl.a(libvirt_driver_qemu_impl_la-qemu_domain.o): undefined reference to symbol 'xmlXPathRegisterNs@@LIBXML2_2.4.30' /usr/bin/ld: note: 'xmlXPathRegisterNs@@LIBXML2_2.4.30' is defined in DSO /usr/lib/x86_64-linux-gnu/libxml2.so.2 so try adding it to the linker command line /usr/lib/x86_64-linux-gnu/libxml2.so.2: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status
[ and ]
/usr/bin/ld: ../src/.libs/libvirt_driver_network_impl.a(libvirt_driver_network_impl_la-bridge_driver.o): undefined reference to symbol 'dbus_bus_add_match' /usr/bin/ld: note: 'dbus_bus_add_match' is defined in DSO /lib/x86_64-linux-gnu/libdbus-1.so.3 so try adding it to the linker command line /lib/x86_64-linux-gnu/libdbus-1.so.3: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status
Ok, so those messages indicate that the libvirt_driver_qemu_impl.la and libvirt_driver_network_impl.la libraries need to have their linkage fixed, not the test suite(s). Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Serge Hallyn