Skip to contentSkip to conversation

qemu git does not build on 32bits anymore (incl mingw32)

Qemu-devel Michael Tokarev 2 participants 7 messages Feb 15, 2014

lore
Share & tools
lore
#0 lore raw

Since this commit:

commit 999b53ec8794f203964db3ecf939a3da5c4bc843

Author: Claudio Fontana <[email protected]>
Date:   Wed Feb 5 17:27:28 2014 +0000

disas: Implement disassembly output for A64

Use libvixl to implement disassembly output in debug logs for A64, for use with both AArch64 hosts and targets.

[PMM:
* added support for target disassembly
* switched to custom QEMUDisassembler so the output format matches what QEMU expects
* make sure we correctly fall back to "just print hex" if we didn't build the AArch64 disassembler because of lack of a C++ compiler
* rename from 'aarch64' to 'arm-a64' because this is a disassembler for the A64 instruction set
* merge aarch64.c and aarch64-cxx.cc into one C++ file
* simplify the aarch64.c<->aarch64-cxx.cc interface]

Qemu does not build on mingw32 anymore, with the following error messages:

CXX disas/libvixl/utils.o
disas/libvixl/utils.cc:98: error: integer constant is too large for 'unsigned long' type disas/libvixl/utils.cc:111: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:111: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:112: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:112: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:113: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:113: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:114: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:114: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:115: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:115: error: integer constant is too large for 'long' type
make: *** [disas/libvixl/utils.o] Error 1

Attached patch fixes this.

/mjt

From: Michael Tokarev <[email protected]>
Subject: libvixl: fix 64bit constants usage

Since commit 999b53ec8794f203964db3ecf939a3da5c4bc843:
Author: Claudio Fontana <[email protected]>
Date: Wed Feb 5 17:27:28 2014 +0000

disas: Implement disassembly output for A64

Use libvixl to implement disassembly output in debug logs for A64, for use with both AArch64 hosts and targets.

disas/libvixl/ contains functions which uses 64bit constants without using appropriate suffixes, which fails on 32bits.

Fix this by using ULL suffix.

disas/libvixl/a64/disasm-a64.cc +8 -8
index 4a49748..5c6b898 100644
@@ -269,19 +269,19 @@ bool Disassembler::IsMovzMovnImm(unsigned reg_size, uint64_t value) {
          ((reg_size == kWRegSize) && (value <= 0xffffffff)));
 
   // Test for movz: 16 bits set at positions 0, 16, 32 or 48.
-  if (((value & 0xffffffffffff0000UL) == 0UL) ||
-      ((value & 0xffffffff0000ffffUL) == 0UL) ||
-      ((value & 0xffff0000ffffffffUL) == 0UL) ||
-      ((value & 0x0000ffffffffffffUL) == 0UL)) {
+  if (((value & 0xffffffffffff0000ULL) == 0ULL) ||
+      ((value & 0xffffffff0000ffffULL) == 0ULL) ||
+      ((value & 0xffff0000ffffffffULL) == 0ULL) ||
+      ((value & 0x0000ffffffffffffULL) == 0ULL)) {
     return true;
   }
 
   // Test for movn: NOT(16 bits set at positions 0, 16, 32 or 48).
   if ((reg_size == kXRegSize) &&
-      (((value & 0xffffffffffff0000UL) == 0xffffffffffff0000UL) ||
-       ((value & 0xffffffff0000ffffUL) == 0xffffffff0000ffffUL) ||
-       ((value & 0xffff0000ffffffffUL) == 0xffff0000ffffffffUL) ||
-       ((value & 0x0000ffffffffffffUL) == 0x0000ffffffffffffUL))) {
+      (((value & 0xffffffffffff0000ULL) == 0xffffffffffff0000ULL) ||
+       ((value & 0xffffffff0000ffffULL) == 0xffffffff0000ffffULL) ||
+       ((value & 0xffff0000ffffffffULL) == 0xffff0000ffffffffULL) ||
+       ((value & 0x0000ffffffffffffULL) == 0x0000ffffffffffffULL))) {
     return true;
   }
   if ((reg_size == kWRegSize) &&
disas/libvixl/utils.cc +13 -7
index 6f85e61..a45fb95 100644
@@ -95,7 +95,7 @@ int CountSetBits(uint64_t value, int width) {
   ASSERT((width == 32) || (width == 64));
 
   // Mask out unused bits to ensure that they are not counted.
-  value &= (0xffffffffffffffffUL >> (64-width));
+  value &= (0xffffffffffffffffULL >> (64-width));
 
   // Add up the set bits.
   // The algorithm works by adding pairs of bit fields together iteratively,
@@ -108,12 +108,18 @@ int CountSetBits(uint64_t value, int width) {
   // value =   h+g+f+e     d+c+b+a
   //                  \          |
   // value =       h+g+f+e+d+c+b+a
-  value = ((value >> 1) & 0x5555555555555555) + (value & 0x5555555555555555);
-  value = ((value >> 2) & 0x3333333333333333) + (value & 0x3333333333333333);
-  value = ((value >> 4) & 0x0f0f0f0f0f0f0f0f) + (value & 0x0f0f0f0f0f0f0f0f);
-  value = ((value >> 8) & 0x00ff00ff00ff00ff) + (value & 0x00ff00ff00ff00ff);
-  value = ((value >> 16) & 0x0000ffff0000ffff) + (value & 0x0000ffff0000ffff);
-  value = ((value >> 32) & 0x00000000ffffffff) + (value & 0x00000000ffffffff);
+  value = ((value >> 1) & 0x5555555555555555ULL) +
+           (value & 0x5555555555555555ULL);
+  value = ((value >> 2) & 0x3333333333333333ULL) +
+           (value & 0x3333333333333333ULL);
+  value = ((value >> 4) & 0x0f0f0f0f0f0f0f0fULL) +
+           (value & 0x0f0f0f0f0f0f0f0fULL);
+  value = ((value >> 8) & 0x00ff00ff00ff00ffULL) +
+           (value & 0x00ff00ff00ff00ffULL);
+  value = ((value >> 16) & 0x0000ffff0000ffffULL) +
+           (value & 0x0000ffff0000ffffULL);
+  value = ((value >> 32) & 0x00000000ffffffffULL) +
+           (value & 0x00000000ffffffffULL);
 
   return value;
 }
roms/seabios +1 -1
index 96917a8..31b8b4e 160000
@@ -1 +1 @@
-Subproject commit 96917a8ed761f017fc8c72ba3b9181fbac03ac59
+Subproject commit 31b8b4eea9d9ad58a73b22a6060d3ac1c419c26d
Reviewed-by
#1 lore raw
Quoted 42 lines · Michael Tokarev

Since this commit:

commit 999b53ec8794f203964db3ecf939a3da5c4bc843

Author: Claudio Fontana <[email protected]>
Date:   Wed Feb 5 17:27:28 2014 +0000

disas: Implement disassembly output for A64

Use libvixl to implement disassembly output in debug logs for A64, for use with both AArch64 hosts and targets.

[PMM:
* added support for target disassembly
* switched to custom QEMUDisassembler so the output format matches what QEMU expects
* make sure we correctly fall back to "just print hex" if we didn't build the AArch64 disassembler because of lack of a C++ compiler
* rename from 'aarch64' to 'arm-a64' because this is a disassembler for the A64 instruction set
* merge aarch64.c and aarch64-cxx.cc into one C++ file
* simplify the aarch64.c<->aarch64-cxx.cc interface]

Qemu does not build on mingw32 anymore, with the following error messages:

CXX disas/libvixl/utils.o
disas/libvixl/utils.cc:98: error: integer constant is too large for 'unsigned long' type disas/libvixl/utils.cc:111: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:111: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:112: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:112: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:113: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:113: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:114: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:114: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:115: error: integer constant is too large for 'long' type disas/libvixl/utils.cc:115: error: integer constant is too large for 'long' type
make: *** [disas/libvixl/utils.o] Error 1

Quoted 1 line

Attached patch fixes this.

Ugh, sorry about that. I thought I'd caught them but obviously the Windows 32 bit build is pickier than the Linux one (it's clearly right though).

PS: your patch has a stray roms/seabios update hunk in it. Other than that

and I'll apply it directly shortly since it's a build-breakage.

thanks
-- PMM

#2 lore raw
Quoted 2 lines · Peter Maydell

Ugh, sorry about that. I thought I'd caught them but obviously the Windows 32 bit build is pickier than the Linux one (it's clearly right though).

Incidentally if you have a simple recipe for setting up a windows mingw build environment on Ubuntu (preferably not bleeding-edge Ubuntu) then I'm happy to add "compile-test for win32" to my pullreq application checklist.

thanks
-- PMM

#3 lore raw
Quoted 4 lines · Peter Maydell

Incidentally if you have a simple recipe for setting up a windows mingw build environment on Ubuntu (preferably not bleeding-edge Ubuntu) then I'm happy to add "compile-test for win32" to my pullreq application checklist.

Hm. I've never did that before, but it appeared quite easy to do.

apt-get install mingw32

grabbed a few -dev binaries from http://www.gtk.org/download/win32.php,
namely:

glib
zlib
gettext-runtime
libpng
pixman

and extracted them into a common directory (say, $mingwhome).

Next, created /usr/local/bin/i586-mingw32msvc-pkg-config with the following:

--- cut ---
#!/bin/sh
prefix=$mingwhome PKG_CONFIG_LIBDIR=$prefix/lib/pkgconfig export PKG_CONFIG_LIBDIR
exec pkg-config --define-variable=prefix=$prefix $@ --- cut ---

Now I can build qemu like this:

 ./configure --cross-prefix=i586-mingw32msvc- \
    --extra-cflags=-I$mingwhome/include \
    --extra-ldflags=-I$mingwhome/lib

That's basically all.

This works on debian wheezy.

Similar setup should work for w64 too, except in
this case mingw-w64 is needed, and libs from
http://www.gtk.org/download/win64.php .

Initially I followed http://wiki.qemu.org/Hosts/W32 .

BTW, current debian wheezy catches these constants in 32bits too. I mean, when the host is 32bits.

Thanks,

/mjt

#4 lore raw
Quoted 7 lines · Michael Tokarev
Quoted 4 lines · Peter Maydell

Incidentally if you have a simple recipe for setting up a windows mingw build environment on Ubuntu (preferably not bleeding-edge Ubuntu) then I'm happy to add "compile-test for win32" to my pullreq application checklist.

Hm. I've never did that before, but it appeared quite easy to do.

Thanks for the instructions; I'll get that set up.

Quoted 2 lines

BTW, current debian wheezy catches these constants in 32bits too. I mean, when the host is 32bits.

Must be a new-gcc thing, then, maybe? My test 32 bit Linux host has gcc-4.6.3-1ubuntu5 and that builds fine (it did complain about some of the constants which is why I caught and fixed those).

thanks
-- PMM

#5 lore raw
Quoted 9 lines · Peter Maydell
Quoted 2 lines · Michael Tokarev

BTW, current debian wheezy catches these constants in 32bits too. I mean, when the host is 32bits.

Must be a new-gcc thing, then, maybe? My test 32 bit Linux host has gcc-4.6.3-1ubuntu5 and that builds fine (it did complain about some of the constants which is why I caught and fixed those).

gcc-4.7.2 (which is the version on debian wheezy) complains about these. It is actually the same compiler I used to build mingw32 stuff.

/mjt

#6 lore raw
In reply to Peter Maydell
Quoted 10 lines · Peter Maydell
Quoted 7 lines · Michael Tokarev
Quoted 4 lines · Peter Maydell

Incidentally if you have a simple recipe for setting up a windows mingw build environment on Ubuntu (preferably not bleeding-edge Ubuntu) then I'm happy to add "compile-test for win32" to my pullreq application checklist.

Hm. I've never did that before, but it appeared quite easy to do.

Thanks for the instructions; I'll get that set up.

OK, I've set up the win32 cross-compiler, confirmed that it doesn't build and that this patch fixes the problem, and pushed the fix to master (without the stray seabios update hunk).

thanks
-- PMM