[Libvir] [PATCH] Avoid link errors with "configure --disable-shared".

I tried to build static binaries in the usual libtool way, via "configure --disable-shared" and got some link errors due to the tests linking only with shared-lib-related files. Here's the fix: Avoid link errors with "configure --disable-shared". * tests/Makefile.am (LDADDS): Add ../src/libvirt.la, so that "configure --disable-shared" no longer provokes link errors. --- tests/Makefile.am | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index dfd9e34..1b5f287 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -33,6 +33,7 @@ LDADDS = \ $(SASL_LIBS) \ $(WARN_CFLAGS) \ $(LIBVIRT) \ + ../src/libvirt.la \ ../gnulib/lib/libgnu.la \ $(COVERAGE_LDFLAGS) -- 1.5.4.rc5.1.g0fa73

On Tue, Jan 29, 2008 at 11:44:30AM +0100, Jim Meyering wrote:
I tried to build static binaries in the usual libtool way, via "configure --disable-shared" and got some link errors due to the tests linking only with shared-lib-related files. Here's the fix:
Avoid link errors with "configure --disable-shared". * tests/Makefile.am (LDADDS): Add ../src/libvirt.la, so that "configure --disable-shared" no longer provokes link errors.
Hmm, we used todo this, but it screwed up the code coverage reports for the tests which ran virsh. eg, 1/2 the data got stuffed into src/libvirt_la-nodeinfo.gcno files and the other 1/2 got stuff into src/.libs/libvirt_la-nodeinfo.gcno and there didn't appear to be any way to merge them. Any thoughts on that Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

Jim Meyering wrote:
I tried to build static binaries in the usual libtool way, via "configure --disable-shared" and got some link errors due to the tests linking only with shared-lib-related files. Here's the fix:
Avoid link errors with "configure --disable-shared". * tests/Makefile.am (LDADDS): Add ../src/libvirt.la, so that "configure --disable-shared" no longer provokes link errors.
--- tests/Makefile.am | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am index dfd9e34..1b5f287 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -33,6 +33,7 @@ LDADDS = \ $(SASL_LIBS) \ $(WARN_CFLAGS) \ $(LIBVIRT) \ + ../src/libvirt.la \ ../gnulib/lib/libgnu.la \ $(COVERAGE_LDFLAGS)
Not sure I understand this one. LIBVIRT is defined as: LIBVIRT = $(wildcard $(top_builddir)/src/.libs/libvirt_la-*.o) Doesn't that work in the static case too? Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

"Richard W.M. Jones" <rjones@redhat.com> wrote:
Jim Meyering wrote:
I tried to build static binaries in the usual libtool way, via "configure --disable-shared" and got some link errors due to the tests linking only with shared-lib-related files. Here's the fix:
Avoid link errors with "configure --disable-shared". * tests/Makefile.am (LDADDS): Add ../src/libvirt.la, so that "configure --disable-shared" no longer provokes link errors.
--- tests/Makefile.am | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am index dfd9e34..1b5f287 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -33,6 +33,7 @@ LDADDS = \ $(SASL_LIBS) \ $(WARN_CFLAGS) \ $(LIBVIRT) \ + ../src/libvirt.la \ ../gnulib/lib/libgnu.la \ $(COVERAGE_LDFLAGS)
Not sure I understand this one.
LIBVIRT is defined as:
LIBVIRT = $(wildcard $(top_builddir)/src/.libs/libvirt_la-*.o)
Doesn't that work in the static case too?
Unfortunately not, since the wildcard doesn't match anything: $ ls -1 ../src/.libs/libvirt* ../src/.libs/libvirt.a ../src/.libs/libvirt.la@ ../src/.libs/libvirt.lai If you want to try to reproduce it yourself, do this: ./configure --disable-shared && make Without my patch, I get results like this on rawhide: ... xmlrpc.o: In function `xmlRpcValueMarshal': /home/meyering/w/co/libvirt/tests/../src/xmlrpc.c:363: undefined reference to `virBufferStrcat' collect2: ld returned 1 exit status make[2]: *** [xmlrpctest] Error 1 xml2sexprtest.o: In function `testCompareFiles': /home/meyering/w/co/libvirt/tests/xml2sexprtest.c:42: undefined reference to `virDomainParseXMLDesc' collect2: ld returned 1 exit status make[2]: *** [xml2sexprtest] Error 1 reconnect.o: In function `main': /home/meyering/w/co/libvirt/tests/reconnect.c:20: undefined reference to `virSetErrorFunc' /home/meyering/w/co/libvirt/tests/reconnect.c:22: undefined reference to `virConnectOpen' /home/meyering/w/co/libvirt/tests/reconnect.c:31: undefined reference to `virDomainLookupByID' /home/meyering/w/co/libvirt/tests/reconnect.c:36: undefined reference to `virDomainFree' /home/meyering/w/co/libvirt/tests/reconnect.c:37: undefined reference to `virConnectClose' /home/meyering/w/co/libvirt/tests/reconnect.c:41: undefined reference to `virConnectOpen' /home/meyering/w/co/libvirt/tests/reconnect.c:46: undefined reference to `virDomainLookupByID' /home/meyering/w/co/libvirt/tests/reconnect.c:39: undefined reference to `virConnectOpenReadOnly' /home/meyering/w/co/libvirt/tests/reconnect.c:25: undefined reference to `virConnectOpenReadOnly' /home/meyering/w/co/libvirt/tests/reconnect.c:51: undefined reference to `virDomainFree' /home/meyering/w/co/libvirt/tests/reconnect.c:52: undefined reference to `virConnectClose' collect2: ld returned 1 exit status make[2]: *** [reconnect] Error 1 make[2]: Leaving directory `/home/meyering/w/co/libvirt/tests' make[1]: *** [check-recursive] Error 1 make[1]: Leaving directory `/home/meyering/w/co/libvirt/tests' make: *** [check-recursive] Error 1 I'll see what happens with profiling.

On Tue, Jan 29, 2008 at 05:01:17PM +0100, Jim Meyering wrote:
"Richard W.M. Jones" <rjones@redhat.com> wrote:
Jim Meyering wrote:
I tried to build static binaries in the usual libtool way, via "configure --disable-shared" and got some link errors due to the tests linking only with shared-lib-related files. Here's the fix:
Avoid link errors with "configure --disable-shared". * tests/Makefile.am (LDADDS): Add ../src/libvirt.la, so that "configure --disable-shared" no longer provokes link errors.
--- tests/Makefile.am | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am index dfd9e34..1b5f287 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -33,6 +33,7 @@ LDADDS = \ $(SASL_LIBS) \ $(WARN_CFLAGS) \ $(LIBVIRT) \ + ../src/libvirt.la \ ../gnulib/lib/libgnu.la \ $(COVERAGE_LDFLAGS)
Not sure I understand this one.
LIBVIRT is defined as:
LIBVIRT = $(wildcard $(top_builddir)/src/.libs/libvirt_la-*.o)
Doesn't that work in the static case too?
Unfortunately not, since the wildcard doesn't match anything:
$ ls -1 ../src/.libs/libvirt* ../src/.libs/libvirt.a ../src/.libs/libvirt.la@ ../src/.libs/libvirt.lai
Even in the shared case, it doesn't really work too well - if you make clean you can often end up with this pulling in too many files. I don't particuarly like this bit of the tests Makefile, but I could not find any other way to getting the coverage data to work correctly at the time. The problem is only wrt to the test case which invokes virsh - all the others work fine. Its just that virsh gets linked & invoked in a differnet context to the other scripts. The possible way around it is to not invoke virsh binary from the test suite - instead just compile virsh.c straight into the virsh test case & call its main() method. I never got around to testing this idea. If it works, then we could remove the wildcard and just link to libvirt.la as normal Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
participants (3)
-
Daniel P. Berrange
-
Jim Meyering
-
Richard W.M. Jones