[libvirt] [PATCH] Fix test case qemuagenttest compilation.

When compiling 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 And I checked this error, it caused by the position of libqemumonitortestutils.a in gcc arguments. If libqemumonitortestutils.a before libvirt_driver_qemu_impl.a and libvirt_driver_network_impl.a, the compilation passed. Otherwise, failed. I think this should be a gcc's bug, but nevermind, just fix it in libvirt. --- 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 07/31/2013 02:36 PM, Jincheng Miao wrote:
When compiling 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
What platform was this on? Some distros are set up to be tolerant of lazy resolution, which masks issues like this (hence, I'm _not_ seeing this error on Fedora).
And I checked this error, it caused by the position of libqemumonitortestutils.a in gcc arguments.
If libqemumonitortestutils.a before libvirt_driver_qemu_impl.a and libvirt_driver_network_impl.a, the compilation passed. Otherwise, failed.
I think this should be a gcc's bug, but nevermind, just fix it in libvirt.
No, it's not a bug in gcc, but an actual bug in libvirt. If you can't rely on lazy resolution (such as on platforms like mingw, except that mingw doesn't build qemumonitortestutils in the first place), then libraries MUST be listed in the order in which later libraries satisfy symbols used by earlier libraries. ACK, although I'd like to touch up your commit message (and in particular mention the platform where this matters) before pushing.
--- 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 \
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 08/01/2013 05:48 AM, Eric Blake wrote:
When compiling 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
What platform was this on? Some distros are set up to be tolerant of lazy resolution, which masks issues like this (hence, I'm _not_ seeing this error on Fedora).
Actually I am using fedora 19 too. And the toolchain is: gcc-4.8.1-1.fc19.x86_64 libtool-2.4.2-16.fc19.x86_64
And I checked this error, it caused by the position of libqemumonitortestutils.a in gcc arguments.
If libqemumonitortestutils.a before libvirt_driver_qemu_impl.a and libvirt_driver_network_impl.a, the compilation passed. Otherwise, failed.
I think this should be a gcc's bug, but nevermind, just fix it in libvirt.
No, it's not a bug in gcc, but an actual bug in libvirt. If you can't rely on lazy resolution (such as on platforms like mingw, except that mingw doesn't build qemumonitortestutils in the first place), then libraries MUST be listed in the order in which later libraries satisfy symbols used by earlier libraries.
How do I check whether I am relying on lazy link?
ACK, although I'd like to touch up your commit message (and in particular mention the platform where this matters) before pushing.

On Wed, Jul 31, 2013 at 11:50:18PM -0400, Jincheng Miao wrote:
On 08/01/2013 05:48 AM, Eric Blake wrote:
When compiling 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
What platform was this on? Some distros are set up to be tolerant of lazy resolution, which masks issues like this (hence, I'm _not_ seeing this error on Fedora).
Actually I am using fedora 19 too. And the toolchain is: gcc-4.8.1-1.fc19.x86_64 libtool-2.4.2-16.fc19.x86_64
Did you ask to disable shared libraries when you built libvirt ? That's the only reason I can imagine why you'd see this kind of error. 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 :|

Hi DB, I do not disable shared libs explicit in my memory, I think that is all default. My fc19 computer is in my home. So I will check it when I get home as soon as possible. ----- Original Message ----- From: "Daniel P. Berrange" <berrange@redhat.com> To: "Jincheng Miao" <jmiao@redhat.com> Cc: "Eric Blake" <eblake@redhat.com>, libvir-list@redhat.com Sent: Thursday, August 1, 2013 4:01:24 PM Subject: Re: [libvirt] [PATCH] Fix test case qemuagenttest compilation. On Wed, Jul 31, 2013 at 11:50:18PM -0400, Jincheng Miao wrote:
On 08/01/2013 05:48 AM, Eric Blake wrote:
When compiling 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
What platform was this on? Some distros are set up to be tolerant of lazy resolution, which masks issues like this (hence, I'm _not_ seeing this error on Fedora).
Actually I am using fedora 19 too. And the toolchain is: gcc-4.8.1-1.fc19.x86_64 libtool-2.4.2-16.fc19.x86_64
Did you ask to disable shared libraries when you built libvirt ? That's the only reason I can imagine why you'd see this kind of error. 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 :|

hi DB, in my fc19 build log, I see ../src/.libs/libvirt.so, maybe it tells that no disable shared libraries. ----- Original Message ----- From: "Jincheng Miao" <jmiao@redhat.com> To: "Daniel P. Berrange" <berrange@redhat.com> Cc: libvir-list@redhat.com Sent: Thursday, August 1, 2013 4:08:49 PM Subject: Re: [libvirt] [PATCH] Fix test case qemuagenttest compilation. Hi DB, I do not disable shared libs explicit in my memory, I think that is all default. My fc19 computer is in my home. So I will check it when I get home as soon as possible. ----- Original Message ----- From: "Daniel P. Berrange" <berrange@redhat.com> To: "Jincheng Miao" <jmiao@redhat.com> Cc: "Eric Blake" <eblake@redhat.com>, libvir-list@redhat.com Sent: Thursday, August 1, 2013 4:01:24 PM Subject: Re: [libvirt] [PATCH] Fix test case qemuagenttest compilation. On Wed, Jul 31, 2013 at 11:50:18PM -0400, Jincheng Miao wrote:
On 08/01/2013 05:48 AM, Eric Blake wrote:
When compiling 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
What platform was this on? Some distros are set up to be tolerant of lazy resolution, which masks issues like this (hence, I'm _not_ seeing this error on Fedora).
Actually I am using fedora 19 too. And the toolchain is: gcc-4.8.1-1.fc19.x86_64 libtool-2.4.2-16.fc19.x86_64
Did you ask to disable shared libraries when you built libvirt ? That's the only reason I can imagine why you'd see this kind of error. 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 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

If I build libvirt with CFLAGS="-O0" in fedora 19, the error will happen. If CFLAGS="-O2", not. I think this optimization options break the rule of lazy linking. ----- Original Message ----- From: "Eric Blake" <eblake@redhat.com> To: "Jincheng Miao" <jmiao@redhat.com> Cc: libvir-list@redhat.com Sent: Thursday, August 1, 2013 5:48:07 AM Subject: Re: [libvirt] [PATCH] Fix test case qemuagenttest compilation. On 07/31/2013 02:36 PM, Jincheng Miao wrote:
When compiling 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
What platform was this on? Some distros are set up to be tolerant of lazy resolution, which masks issues like this (hence, I'm _not_ seeing this error on Fedora).
And I checked this error, it caused by the position of libqemumonitortestutils.a in gcc arguments.
If libqemumonitortestutils.a before libvirt_driver_qemu_impl.a and libvirt_driver_network_impl.a, the compilation passed. Otherwise, failed.
I think this should be a gcc's bug, but nevermind, just fix it in libvirt.
No, it's not a bug in gcc, but an actual bug in libvirt. If you can't rely on lazy resolution (such as on platforms like mingw, except that mingw doesn't build qemumonitortestutils in the first place), then libraries MUST be listed in the order in which later libraries satisfy symbols used by earlier libraries. ACK, although I'd like to touch up your commit message (and in particular mention the platform where this matters) before pushing.
--- 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 \
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 08/01/2013 10:04 AM, Jincheng Miao wrote: [please don't top-post on technical lists]
If I build libvirt with CFLAGS="-O0" in fedora 19, the error will happen. If CFLAGS="-O2", not. I think this optimization options break the rule of lazy linking.
I still couldn't reproduce your problem, when I tried './autogen CFLAGS=-O0'. Can you show the exact ./autogen.sh line you used (or at least what './config.status --version' shows), so that I know what options you enabled and disabled to get to a point where you hit a link failure? -- 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:01:02 AM Subject: Re: [libvirt] [PATCH] Fix test case qemuagenttest compilation.
I still couldn't reproduce your problem, when I tried './autogen CFLAGS=-O0'. Can you show the exact ./autogen.sh line you used (or at least what './config.status --version' shows), so that I know what options you enabled and disabled to get to a point where you hit a link failure?
I used: CFLAGS="-g2 -O0" ./autogen.sh --prefix=$HOME/libvirt-inst Does it '-g2' cause this error?
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Jincheng Miao