[libvirt] [PATCHv2] build: fix qemuagenttest build with -O0 in fedora 19.

Eric Blake eblake at redhat.com
Thu Aug 1 20:09:24 UTC 2013


On 08/01/2013 11:05 AM, Jincheng Miao wrote:
> Someone may need to build libvirt with -O0.
> 
> When building libvirt with -O0 flag in fedora 19, it will fail to
> generate qemuagenttest, a link error occurs like:
> 
> ./.libs/libqemumonitortestutils.a(qemumonitortestutils.o): In function `qemuMonitorTestFree':
> libvirt/tests/qemumonitortestutils.c:346: undefined reference to `qemuMonitorClose'
> ./.libs/libqemumonitortestutils.a(qemumonitortestutils.o): In function `qemuMonitorTestNew':
> libvirt/tests/qemumonitortestutils.c:870: undefined reference to `qemuMonitorOpen'
> collect2: error: ld returned 1 exit status
> 
> So put the libvirt driver impl libraries after libqemumonitortestutils.a, 
> make lazy link happy.

Rather, reordering the arguments avoids lazy link in the first place.
But even if I can't reproduce the failure, I concur that the fix is
correct from a technical standpoint.

> ---
>  tests/Makefile.am | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 9c578fa..b36922e 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -424,7 +424,7 @@ qemuagenttest_SOURCES = \
>  	testutils.c testutils.h \
>  	testutilsqemu.c testutilsqemu.h \
>  	$(NULL)
> -qemuagenttest_LDADD = $(qemu_LDADDS) libqemumonitortestutils.la
> +qemuagenttest_LDADD = libqemumonitortestutils.la $(qemu_LDADDS) 

This adds trailing whitespace, and fails 'make syntax-check'.  I'm also
surprised that you didn't hit failure with other clients of
libqemumonitortestutils.la, which were also listing libraries in the
wrong order.

Here's what I'm pushing:

From a320730a8829dfb730ac9cc007d4cf210b2f6280 Mon Sep 17 00:00:00 2001
From: Jincheng Miao <jmiao at redhat.com>
Date: Fri, 2 Aug 2013 01:05:17 +0800
Subject: [PATCH] build: fix qemuagenttest build with -O0 in fedora 19.

When building libvirt with -O0 flag in fedora 19, it will fail to
generate qemuagenttest, a link error occurs like:

./.libs/libqemumonitortestutils.a(qemumonitortestutils.o): In function
`qemuMonitorTestFree':
libvirt/tests/qemumonitortestutils.c:346: undefined reference to
`qemuMonitorClose'
./.libs/libqemumonitortestutils.a(qemumonitortestutils.o): In function
`qemuMonitorTestNew':
libvirt/tests/qemumonitortestutils.c:870: undefined reference to
`qemuMonitorOpen'
collect2: error: ld returned 1 exit status

Fix it by listing libraries in the correct order to avoid lazy linkage.

Signed-off-by: Eric Blake <eblake at redhat.com>
---
 tests/Makefile.am | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9c578fa..789de9f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -417,21 +417,21 @@ qemumonitorjsontest_SOURCES = \
 	testutils.c testutils.h \
 	testutilsqemu.c testutilsqemu.h \
 	$(NULL)
-qemumonitorjsontest_LDADD = $(qemu_LDADDS) libqemumonitortestutils.la
+qemumonitorjsontest_LDADD = libqemumonitortestutils.la $(qemu_LDADDS)

 qemuagenttest_SOURCES = \
 	qemuagenttest.c \
 	testutils.c testutils.h \
 	testutilsqemu.c testutilsqemu.h \
 	$(NULL)
-qemuagenttest_LDADD = $(qemu_LDADDS) libqemumonitortestutils.la
+qemuagenttest_LDADD = libqemumonitortestutils.la $(qemu_LDADDS)

 qemuhotplugtest_SOURCES = \
 	qemuhotplugtest.c \
 	testutils.c testutils.h \
 	testutilsqemu.c testutilsqemu.h \
 	$(NULL)
-qemuhotplugtest_LDADD = $(qemu_LDADDS) libqemumonitortestutils.la
+qemuhotplugtest_LDADD = libqemumonitortestutils.la $(qemu_LDADDS)

 domainsnapshotxml2xmltest_SOURCES = \
 	domainsnapshotxml2xmltest.c testutilsqemu.c testutilsqemu.h \
-- 
1.8.3.1



-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130801/74b3721e/attachment-0001.sig>


More information about the libvir-list mailing list