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@xxxxxxxxxx +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list