[libvirt] libvirt and mingw64 x64, bad idea?

Hi, I tried to update the fedora mingw package to follow the mingw64 packaging guideline and allow build for x86 and x64. But I got into build warning and errors for x86_64. (using Fedora Cross project repo: http://build1.openftd.org/fedora-cross/fedora-cross.repo, x86_64-w64-mingw32-gcc (GCC) 4.6.2 20110908 and later) ./configure --host=x86_64-w64-mingw32 --build=x86_64-unknown-linux-gnu --target=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32/sys-root/mingw --exec-prefix=/usr/x86_64-w64-mingw32/sys-root/mingw --bindir=/usr/x86_64-w64-mingw32/sys-root/mingw/bin --sbindir=/usr/x86_64-w64-mingw32/sys-root/mingw/sbin --sysconfdir=/usr/x86_64-w64-mingw32/sys-root/mingw/etc --datadir=/usr/x86_64-w64-mingw32/sys-root/mingw/share --includedir=/usr/x86_64-w64-mingw32/sys-root/mingw/include --libdir=/usr/x86_64-w64-mingw32/sys-root/mingw/lib --libexecdir=/usr/x86_64-w64-mingw32/sys-root/mingw/libexec --localstatedir=/usr/x86_64-w64-mingw32/sys-root/mingw/var --sharedstatedir=/usr/x86_64-w64-mingw32/sys-root/mingw/com --mandir=/usr/x86_64-w64-mingw32/sys-root/mingw/share/man --infodir=/usr/x86_64-w64-mingw32/sys-root/mingw/share/info --without-xen --without-qemu --without-openvz --without-lxc --without-vbox --without-xenapi --without-sasl --without-avahi --without-polkit --without-python --without-libvirtd --without-uml --without-phyp --without-hyperv --without-vmware --without-netcf --without-audit --without-dtrace --enable-static The somewhat worrying error is: util/command.c:54:1: error: static assertion failed: "verify (sizeof(pid_t) <= sizeof(int))" /* We have quite a bit of changes to make if this doesn't hold. */ verify(sizeof(pid_t) <= sizeof(int)); There are a few other warnings, see attached files. Is this going to be something difficult and worth to fix? regards -- Marc-André Lureau

On 01/23/2012 03:29 PM, Marc-André Lureau wrote:
Hi,
I tried to update the fedora mingw package to follow the mingw64 packaging guideline and allow build for x86 and x64. But I got into build warning and errors for x86_64. (using Fedora Cross project repo: http://build1.openftd.org/fedora-cross/fedora-cross.repo, x86_64-w64-mingw32-gcc (GCC) 4.6.2 20110908 and later)
The somewhat worrying error is:
util/command.c:54:1: error: static assertion failed: "verify (sizeof(pid_t) <= sizeof(int))"
/* We have quite a bit of changes to make if this doesn't hold. */ verify(sizeof(pid_t) <= sizeof(int));
Oh my. I guess it makes sense - while Linux pid_t is just a (linearly-incrementing) index into an array of kernel structs, other OS's use pid_t as the actual kernel pointer to the location in physical memory where the process information is stored; so if you have 64-bit pointers, you have a 64-bit pid_t. Alas, this means that any interface where we are operating on pid_t, but passed an int, are broken. Thankfully, I don't see any interface like that in libvirt.c, and we are free to change any internal functions without breaking the ABI. I did a rough audit of command.c, virpidfile.c, and util.c; it actually looks like all the interfaces that deal with a process were correctly using pid_t; so maybe that compile-time assertion stems from an older revision of code where we still had a bad interface, since fixed. </me searches...> Ah, the real reason is that we do 'printf("%d", pid)', which obviously doesn't work. We have to audit all of those instances, and swap them to 'printf("%llu", (unsigned long long) pid)', or something equally gross (and even %ul is insufficient, no thanks to mingw64 having 'long' being just 32 bits).
There are a few other warnings, see attached files.
Is this going to be something difficult and worth to fix?
Definitely worth fixing. CC malloca.lo malloca.c: In function 'mmalloca': malloca.c:88:18: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] malloca.c: In function 'freea': malloca.c:121:25: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] This is a bug in gnulib; can you redirect it there (as it will affect more than just libvirt). CC fcntl.lo fcntl.c: In function 'dupfd': fcntl.c:97:40: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] Likewise. CC poll.lo poll.c: In function 'IsSocketHandle': poll.c:83:7: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] poll.c: In function 'windows_compute_revents': poll.c:187:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] Likewise. CC select.lo select.c: In function 'IsSocketHandle': select.c:90:7: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] select.c: In function 'windows_poll_handle': select.c:175:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] select.c: In function 'rpl_select': select.c:288:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] select.c:303:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] Likewise. CC stat.lo stat.c: In function 'rpl_stat': stat.c:67:3: warning: passing argument 2 of 'orig_stat' from incompatible pointer type [enabled by default] stat.c:31:1: note: expected 'struct _stat64 *' but argument is of type 'struct stat *' stat.c:113:11: warning: passing argument 2 of 'orig_stat' from incompatible pointer type [enabled by default] stat.c:31:1: note: expected 'struct _stat64 *' but argument is of type 'struct stat *' Likewise, and especially nasty if gnulib doesn't get it right. CC libvirt_util_la-command.lo util/command.c:54:1: error: static assertion failed: "verify (sizeof(pid_t) <= sizeof(int))" util/command.c: In function 'virCommandRun': util/command.c:1882:9: warning: passing argument 2 of '_fstat64' from incompatible pointer type [enabled by default] This may be fixed once we import gnulib fixes. /usr/x86_64-w64-mingw32/sys-root/mingw/include/sys/stat.h:71:23: note: expected 'struct _stat64 *' but argument is of type 'struct stat *' util/command.c:1886:10: warning: passing argument 2 of '_fstat64' from incompatible pointer type [enabled by default] /usr/x86_64-w64-mingw32/sys-root/mingw/include/sys/stat.h:71:23: note: expected 'struct _stat64 *' but argument is of type 'struct stat *' util/command.c:1890:10: warning: passing argument 2 of '_fstat64' from incompatible pointer type [enabled by default] /usr/x86_64-w64-mingw32/sys-root/mingw/include/sys/stat.h:71:23: note: expected 'struct _stat64 *' but argument is of type 'struct stat *' util/command.c: In function 'virCommandRunAsync': util/command.c:2118:9: warning: format '%d' expects argument of type 'int', but argument 7 has type 'pid_t' [-Wformat] Yep, that's the sort of thing that we have to touch up in order to remove the assertion. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Mon, Jan 23, 2012 at 05:20:50PM -0700, Eric Blake wrote:
On 01/23/2012 03:29 PM, Marc-André Lureau wrote:
Hi,
I tried to update the fedora mingw package to follow the mingw64 packaging guideline and allow build for x86 and x64. But I got into build warning and errors for x86_64. (using Fedora Cross project repo: http://build1.openftd.org/fedora-cross/fedora-cross.repo, x86_64-w64-mingw32-gcc (GCC) 4.6.2 20110908 and later)
The somewhat worrying error is:
util/command.c:54:1: error: static assertion failed: "verify (sizeof(pid_t) <= sizeof(int))"
/* We have quite a bit of changes to make if this doesn't hold. */ verify(sizeof(pid_t) <= sizeof(int));
Oh my. I guess it makes sense - while Linux pid_t is just a (linearly-incrementing) index into an array of kernel structs, other OS's use pid_t as the actual kernel pointer to the location in physical memory where the process information is stored; so if you have 64-bit pointers, you have a 64-bit pid_t.
Alas, this means that any interface where we are operating on pid_t, but passed an int, are broken. Thankfully, I don't see any interface like that in libvirt.c, and we are free to change any internal functions without breaking the ABI.
Arguably, we could even change the public API, provided that we hide the change behind an #ifdef WIN64, since we have never done a release that is officially working on WIN64. That would obviously want to be something of a last resort though. 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 :|
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Marc-André Lureau