[libvirt] [PATCH] Add missing linker flags for MinGW build

This fix should completely close https://bugzilla.redhat.com/show_bug.cgi?id=1214605 Signed-off-by: Pavel Fedin <p.fedin@samsung.com> tests/Makefile.am | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 09dc2cb..e69235b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -553,7 +553,8 @@ qemuxml2argvmock_la_SOURCES = \ qemuxml2argvmock.c qemuxml2argvmock_la_CFLAGS = $(AM_CFLAGS) qemuxml2argvmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS) qemuxml2xmltest_SOURCES = \ qemuxml2xmltest.c testutilsqemu.c testutilsqemu.h \ @@ -614,7 +615,8 @@ qemucaps2xmlmock_la_SOURCES = \ qemucaps2xmlmock.c qemucaps2xmlmock_la_CFLAGS = $(AM_CFLAGS) qemucaps2xmlmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS) qemuagenttest_SOURCES = \ qemuagenttest.c \ @@ -722,7 +724,8 @@ bhyvexml2argvmock_la_SOURCES = \ bhyvexml2argvmock.c bhyvexml2argvmock_la_CFLAGS = $(AM_CFLAGS) bhyvexml2argvmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS) bhyve_LDADDS = ../src/libvirt_driver_bhyve_impl.la if WITH_STORAGE @@ -930,7 +933,9 @@ virnetserverclientmock_la_SOURCES = \ virnetserverclientmock.c virnetserverclientmock_la_CFLAGS = $(AM_CFLAGS) virnetserverclientmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(GNULIB_LIBS) \ + $(MINGW_EXTRA_LDFLAGS) if WITH_GNUTLS virnettlscontexttest_SOURCES = \ @@ -1009,7 +1014,8 @@ libvirportallocatormock_la_SOURCES = \ virportallocatortest.c libvirportallocatormock_la_CFLAGS = $(AM_CFLAGS) -DMOCK_HELPER=1 libvirportallocatormock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS) vircgrouptest_SOURCES = \ vircgrouptest.c testutils.h testutils.c @@ -1019,7 +1025,8 @@ vircgroupmock_la_SOURCES = \ vircgroupmock.c vircgroupmock_la_CFLAGS = $(AM_CFLAGS) vircgroupmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS) vircryptotest_SOURCES = \ vircryptotest.c testutils.h testutils.c @@ -1039,7 +1046,8 @@ virpcimock_la_CFLAGS = $(AM_CFLAGS) virpcimock_la_LIBADD = $(GNULIB_LIBS) \ ../src/libvirt.la virpcimock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS) virnetdevtest_SOURCES = \ virnetdevtest.c testutils.h testutils.c @@ -1052,7 +1060,8 @@ virnetdevmock_la_CFLAGS = $(AM_CFLAGS) $(LIBNL_CFLAGS) virnetdevmock_la_LIBADD = $(GNULIB_LIBS) \ ../src/libvirt.la virnetdevmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS) if WITH_LINUX virusbtest_SOURCES = \ @@ -1066,13 +1075,15 @@ virnetdevbandwidthtest_LDADD = $(LDADDS) $(LIBXML_LIBS) virusbmock_la_SOURCES = virusbmock.c virusbmock_la_CFLAGS = $(AM_CFLAGS) virusbmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS) virnetdevbandwidthmock_la_SOURCES = \ virnetdevbandwidthmock.c virnetdevbandwidthmock_la_CFLAGS = $(AM_CFLAGS) virnetdevbandwidthmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS) else ! WITH_LINUX EXTRA_DIST += virusbtest.c virusbmock.c \ @@ -1089,7 +1100,8 @@ virmockdbus_la_SOURCES = \ virmockdbus.c virmockdbus_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) virmockdbus_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS) virpolkittest_SOURCES = \ virpolkittest.c testutils.h testutils.c @@ -1136,7 +1148,8 @@ endif ! WITH_TESTS libsecurityselinuxhelper_la_SOURCES = \ securityselinuxhelper.c libsecurityselinuxhelper_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS) securityselinuxtest_SOURCES = \ securityselinuxtest.c testutils.h testutils.c @@ -1209,7 +1222,8 @@ endif WITH_LIBVIRTD libshunload_la_SOURCES = shunloadhelper.c libshunload_la_LIBADD = ../src/libvirt.la libshunload_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS) shunloadtest_SOURCES = \ shunloadtest.c Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia

On Mon, Apr 27, 2015 at 01:40:53PM +0300, Pavel Fedin wrote:
This fix should completely close https://bugzilla.redhat.com/show_bug.cgi?id=1214605
Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
tests/Makefile.am | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-)
Firstly, this patch is mangled by some mail client, try using git's send-email so it's properly applicable. I wouldn't normally do that, but I fixed it this time ;) Secondly, I think it should fix it, but you added one line indented with spaces while others are using tabs. I must say that's quite OK since we are not consistent in that especially with the mock libs rules and I'm going to clean this in a follow-up patch.
diff --git a/tests/Makefile.am b/tests/Makefile.am index 09dc2cb..e69235b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -553,7 +553,8 @@ qemuxml2argvmock_la_SOURCES = \ qemuxml2argvmock.c qemuxml2argvmock_la_CFLAGS = $(AM_CFLAGS) qemuxml2argvmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS)
qemuxml2xmltest_SOURCES = \ qemuxml2xmltest.c testutilsqemu.c testutilsqemu.h \ @@ -614,7 +615,8 @@ qemucaps2xmlmock_la_SOURCES = \ qemucaps2xmlmock.c qemucaps2xmlmock_la_CFLAGS = $(AM_CFLAGS) qemucaps2xmlmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS)
qemuagenttest_SOURCES = \ qemuagenttest.c \ @@ -722,7 +724,8 @@ bhyvexml2argvmock_la_SOURCES = \ bhyvexml2argvmock.c bhyvexml2argvmock_la_CFLAGS = $(AM_CFLAGS) bhyvexml2argvmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS)
bhyve_LDADDS = ../src/libvirt_driver_bhyve_impl.la if WITH_STORAGE @@ -930,7 +933,9 @@ virnetserverclientmock_la_SOURCES = \ virnetserverclientmock.c virnetserverclientmock_la_CFLAGS = $(AM_CFLAGS) virnetserverclientmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(GNULIB_LIBS) \
Thirdly, I wonder why you needed to add this, is gnulib really needed? is that because of those strdup()s in the file? Why doesn't it fail with gcc then? Fourthly (is that even a word?), I'd ACK this and push it, but just please let me know whether GNULIB_LIBS is really needed here, so I know if I need to amend this or not. Thanks, Martin

On Mon, Apr 27, 2015 at 03:07:06PM +0200, Martin Kletzander wrote:
On Mon, Apr 27, 2015 at 01:40:53PM +0300, Pavel Fedin wrote:
This fix should completely close https://bugzilla.redhat.com/show_bug.cgi?id=1214605
Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
tests/Makefile.am | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-)
Firstly, this patch is mangled by some mail client, try using git's send-email so it's properly applicable. I wouldn't normally do that, but I fixed it this time ;)
Secondly, I think it should fix it, but you added one line indented with spaces while others are using tabs. I must say that's quite OK since we are not consistent in that especially with the mock libs rules and I'm going to clean this in a follow-up patch.
diff --git a/tests/Makefile.am b/tests/Makefile.am index 09dc2cb..e69235b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -553,7 +553,8 @@ qemuxml2argvmock_la_SOURCES = \ qemuxml2argvmock.c qemuxml2argvmock_la_CFLAGS = $(AM_CFLAGS) qemuxml2argvmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS)
qemuxml2xmltest_SOURCES = \ qemuxml2xmltest.c testutilsqemu.c testutilsqemu.h \ @@ -614,7 +615,8 @@ qemucaps2xmlmock_la_SOURCES = \ qemucaps2xmlmock.c qemucaps2xmlmock_la_CFLAGS = $(AM_CFLAGS) qemucaps2xmlmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS)
qemuagenttest_SOURCES = \ qemuagenttest.c \ @@ -722,7 +724,8 @@ bhyvexml2argvmock_la_SOURCES = \ bhyvexml2argvmock.c bhyvexml2argvmock_la_CFLAGS = $(AM_CFLAGS) bhyvexml2argvmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(MINGW_EXTRA_LDFLAGS)
bhyve_LDADDS = ../src/libvirt_driver_bhyve_impl.la if WITH_STORAGE @@ -930,7 +933,9 @@ virnetserverclientmock_la_SOURCES = \ virnetserverclientmock.c virnetserverclientmock_la_CFLAGS = $(AM_CFLAGS) virnetserverclientmock_la_LDFLAGS = -module -avoid-version \ - -rpath /evil/libtool/hack/to/force/shared/lib/creation + -rpath /evil/libtool/hack/to/force/shared/lib/creation \ + $(GNULIB_LIBS) \
Thirdly, I wonder why you needed to add this, is gnulib really needed? is that because of those strdup()s in the file? Why doesn't it fail with gcc then?
Fourthly (is that even a word?), I'd ACK this and push it, but just please let me know whether GNULIB_LIBS is really needed here, so I know if I need to amend this or not.
I just realized that *if* this is still an issue, it is a different from the original one and it would be nice to have it in a different patch then. I'm pushing it without gnulib libs added, feel free to post another patch if there's still an issue with any test. Martin

Hello!
Thirdly, I wonder why you needed to add this, is gnulib really needed? is that because of those strdup()s in the file? Why doesn't it fail with gcc then?
Fourthly (is that even a word?), I'd ACK this and push it, but just please let me know whether GNULIB_LIBS is really needed here, so I know if I need to amend this or not.
Yes, it is. Without GNULIB i get "undefined symbol" on... rtl_something... Sorry, don't remember, but this clearly belongs to gnulib. On Linux .so module can contain undefined symbols, which will be picked up from surrounding binaries; on Windows it cannot. Hence this little problem. Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia

On Mon, Apr 27, 2015 at 05:40:28PM +0300, Pavel Fedin wrote:
Hello!
Thirdly, I wonder why you needed to add this, is gnulib really needed? is that because of those strdup()s in the file? Why doesn't it fail with gcc then?
Fourthly (is that even a word?), I'd ACK this and push it, but just please let me know whether GNULIB_LIBS is really needed here, so I know if I need to amend this or not.
Yes, it is. Without GNULIB i get "undefined symbol" on... rtl_something... Sorry, don't remember, but this clearly belongs to gnulib. On Linux .so module can contain undefined symbols, which will be picked up from surrounding binaries; on Windows it cannot. Hence this little problem.
I already saw that with one build using MinGW (unfortunately I'm currently unable to use mingw compiler on my machine), so I sent another patch for that, added your SoB, but added it to LDADD instead of LDFLAGS as that's the right place to use it. If it works, feel free to close the BZ or reply if it doesn't. Have a nice day, Martin

Hello!
If it works, feel free to close the BZ or reply if it doesn't.
It doesn't seem to work. And the error is, indeed: --- cut --- CCLD virnetserverclientmock.la .libs/virnetserverclientmock_la-virnetserverclientmock.o: In function `virNetSocketGetSELinuxContext': C:\mingw64\msys\1.0\src\libvirt\tests/virnetserverclientmock.c:61: undefined reference to `rpl_strdup' .libs/virnetserverclientmock_la-virnetserverclientmock.o: In function `virGetUserName': C:\mingw64\msys\1.0\src\libvirt\tests/virnetserverclientmock.c:50: undefined reference to `rpl_strdup' .libs/virnetserverclientmock_la-virnetserverclientmock.o: In function `virGetGroupName': C:\mingw64\msys\1.0\src\libvirt\tests/virnetserverclientmock.c:55: undefined reference to `rpl_strdup' collect2.exe: error: ld returned 1 exit status --- cut --- I will recheck. Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia
-----Original Message----- From: libvir-list-bounces@redhat.com [mailto:libvir-list- bounces@redhat.com] On Behalf Of Martin Kletzander Sent: Monday, April 27, 2015 6:07 PM To: Pavel Fedin Cc: libvir-list@redhat.com Subject: Re: [libvirt] [PATCH] Add missing linker flags for MinGW build
Hello!
Thirdly, I wonder why you needed to add this, is gnulib really needed? is that because of those strdup()s in the file? Why doesn't it fail with gcc then?
Fourthly (is that even a word?), I'd ACK this and push it, but just please let me know whether GNULIB_LIBS is really needed here, so I know if I need to amend this or not.
Yes, it is. Without GNULIB i get "undefined symbol" on... rtl_something... Sorry, don't remember, but this clearly belongs to gnulib. On Linux .so module can contain undefined symbols, which will be
up from surrounding binaries; on Windows it cannot. Hence this little
On Mon, Apr 27, 2015 at 05:40:28PM +0300, Pavel Fedin wrote: picked problem.
I already saw that with one build using MinGW (unfortunately I'm currently unable to use mingw compiler on my machine), so I sent another patch for that, added your SoB, but added it to LDADD instead of LDFLAGS as that's the right place to use it.
Have a nice day, Martin

Hello!
If it works, feel free to close the BZ or reply if it doesn't.
I have checked. For some reason, $(virnetserverclientmock_la_LDADDS) does not take part anywhere. Here are generated rules: --- cut --- virnetserverclientmock_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(virnetserverclientmock_la_CFLAGS) $(CFLAGS) \ $(virnetserverclientmock_la_LDFLAGS) $(LDFLAGS) -o $@ --- cut --- virnetserverclientmock.la: $(virnetserverclientmock_la_OBJECTS) $(virnetserverclientmock_la_DEPENDENCIES) $(EXTRA_virnetserverclientmock_la_DEPENDENCIES) $(AM_V_CCLD)$(virnetserverclientmock_la_LINK) $(am_virnetserverclientmock_la_rpath) $(virnetserverclientmock_la_OBJECTS) $(virnetserverclientmock_la_LIBADD) $(LIBS) --- cut --- I have looked through Makefile.am, xxx_LDADD seems to be used only for executables, and not for shared libraries. Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia

Hello!
I have checked. For some reason, $(virnetserverclientmock_la_LDADDS) does not take part anywhere. Here are generated rules:
It has to be virnetserverclientmock_la_LIBADD instead. I have tested, works fine. Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia

On Tue, Apr 28, 2015 at 11:40:02AM +0300, Pavel Fedin wrote:
Hello!
I have checked. For some reason, $(virnetserverclientmock_la_LDADDS) does not take part anywhere. Here are generated rules:
It has to be virnetserverclientmock_la_LIBADD instead. I have tested, works fine.
I just wrote that and was waiting with an answer until I can check whether that helps. Yes it needs to be LIBADD, I'll send a v2.
Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia
participants (2)
-
Martin Kletzander
-
Pavel Fedin