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

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. --- 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) qemuhotplugtest_SOURCES = \ qemuhotplugtest.c \ -- 1.8.3.1

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@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@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

----- Original Message -----
From: "Eric Blake" <eblake@redhat.com> To: "Jincheng Miao" <jmiao@redhat.com> Cc: libvir-list@redhat.com Sent: Friday, August 2, 2013 4:09:24 AM Subject: Re: [libvirt] [PATCHv2] build: fix qemuagenttest build with -O0 in fedora 19.
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.
Sorry on my careless, I forget to 'make syntax-check'. And it caused by lacking '$(NULL)'.
--- 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)
here should be : +qemumonitorjsontest_LDADD = libqemumonitortestutils.la $(qemu_LDADDS) \ $(NULL)
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)
should be : +qemuagenttest_LDADD = libqemumonitortestutils.la $(qemu_LDADDS) \ $(NULL)
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)
should be: +qemuhotplugtest_LDADD = libqemumonitortestutils.la $(qemu_LDADDS) \ $(NULL)
domainsnapshotxml2xmltest_SOURCES = \ domainsnapshotxml2xmltest.c testutilsqemu.c testutilsqemu.h \

On 08/01/2013 08:43 PM, Jincheng Miao wrote:
----- Original Message -----
From: "Eric Blake" <eblake@redhat.com> To: "Jincheng Miao" <jmiao@redhat.com> Cc: libvir-list@redhat.com Sent: Friday, August 2, 2013 4:09:24 AM Subject: Re: [libvirt] [PATCHv2] build: fix qemuagenttest build with -O0 in fedora 19.
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.
Sorry on my careless, I forget to 'make syntax-check'. And it caused by lacking '$(NULL)'.
No, it was caused by having a space after text and before the newline.
+qemumonitorjsontest_LDADD = libqemumonitortestutils.la $(qemu_LDADDS)
here should be : +qemumonitorjsontest_LDADD = libqemumonitortestutils.la $(qemu_LDADDS) \ $(NULL)
Use of $(NULL) helps multi-line comments be extendable in the future - you only have to insert one line at the end, instead of modifying an existing line to add a \ as well as your addition. But when everything fits on one line, there is no point to using $(NULL). -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

----- Original Message -----
From: "Eric Blake" <eblake@redhat.com> To: "Jincheng Miao" <jmiao@redhat.com> Cc: libvir-list@redhat.com Sent: Friday, August 2, 2013 9:09:23 PM Subject: Re: [libvirt] [PATCHv2] build: fix qemuagenttest build with -O0 in fedora 19.
No, it was caused by having a space after text and before the newline.
Use of $(NULL) helps multi-line comments be extendable in the future - you only have to insert one line at the end, instead of modifying an existing line to add a \ as well as your addition. But when everything fits on one line, there is no point to using $(NULL).
yes, I retry it, as you said.
participants (2)
-
Eric Blake
-
Jincheng Miao