[NOTFORMERGE PATCH 6/6] buildsys: Allow building guest-agent on 32-bit hosts

Philippe Mathieu-Daudé posted 6 patches 1 week, 1 day ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, David Hildenbrand <david@kernel.org>, Igor Mammedov <imammedo@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
[NOTFORMERGE PATCH 6/6] buildsys: Allow building guest-agent on 32-bit hosts
Posted by Philippe Mathieu-Daudé 1 week, 1 day ago
Partially revert commit range 5053e0a65db...90e2e8ada7c.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 configure   | 64 +++++++++++++++++++++++++++++++++++++++++++----------
 meson.build |  2 +-
 2 files changed, 53 insertions(+), 13 deletions(-)

diff --git a/configure b/configure
index eea90306728..e984ec2bd3c 100755
--- a/configure
+++ b/configure
@@ -381,6 +381,8 @@ fi
 if test ! -z "$cpu" ; then
   # command line argument
   :
+elif check_define __i386__ ; then
+  cpu="i386"
 elif check_define __x86_64__ ; then
   if check_define __ILP32__ ; then
     cpu="x32"
@@ -399,22 +401,30 @@ elif check_define _ARCH_PPC64 ; then
   else
     cpu="ppc64"
   fi
-elif check_define __mips64 ; then
-  cpu="mips64"
+elif check_define __mips__ ; then
+  if check_define __mips64 ; then
+    cpu="mips64"
+  fi
 elif check_define __s390__ ; then
   if check_define __s390x__ ; then
     cpu="s390x"
   else
     cpu="s390"
   fi
-elif check_define __riscv && check_define _LP64 ; then
-  cpu="riscv64"
+elif check_define __riscv ; then
+  if check_define _LP64 ; then
+    cpu="riscv64"
+  else
+    cpu="riscv32"
+  fi
+elif check_define __arm__ ; then
+  cpu="arm"
 elif check_define __aarch64__ ; then
   cpu="aarch64"
 elif check_define __loongarch64 ; then
   cpu="loongarch64"
 elif check_define EMSCRIPTEN ; then
-  error_exit "wasm64 must be specified to the cpu flag"
+  error_exit "wasm32 or wasm64 must be specified to the cpu flag"
 else
   # Using uname is really broken, but it is just a fallback for architectures
   # that are going to use TCI anyway
@@ -440,6 +450,18 @@ case "$cpu" in
     linux_arch=arm64
     ;;
 
+  armv*b|armv*l|arm)
+    cpu=arm
+    host_arch=arm
+    ;;
+
+  i386|i486|i586|i686)
+    cpu="i386"
+    host_arch=i386
+    linux_arch=x86
+    CPU_CFLAGS="-m32"
+    ;;
+
   loongarch*)
     cpu=loongarch64
     host_arch=loongarch64
@@ -448,7 +470,7 @@ case "$cpu" in
 
   mips64*|mipsisa64*)
     cpu=mips64
-    host_arch=mips64
+    host_arch=mips
     linux_arch=mips
     ;;
 
@@ -464,8 +486,8 @@ case "$cpu" in
     CPU_CFLAGS="-m64 -mlittle-endian"
     ;;
 
-  riscv64)
-    host_arch=riscv64
+  riscv32 | riscv64)
+    host_arch=riscv
     linux_arch=riscv
     ;;
 
@@ -500,6 +522,9 @@ case "$cpu" in
     linux_arch=x86
     CPU_CFLAGS="-m64"
     ;;
+  wasm32)
+    CPU_CFLAGS="-m32"
+    ;;
   wasm64)
     CPU_CFLAGS="-m64 -sMEMORY64=$wasm64_memory64"
     ;;
@@ -1287,7 +1312,7 @@ EOF
     test "$bigendian" = no && rust_arch=${rust_arch}el
     ;;
 
-  riscv64)
+  riscv32|riscv64)
     # e.g. riscv64gc-unknown-linux-gnu, but riscv64-linux-android
     test "$android" = no && rust_arch=${rust_arch}gc
     ;;
@@ -1449,18 +1474,26 @@ probe_target_compiler() {
         container_image=debian-all-test-cross
         container_cross_prefix=aarch64-linux-gnu-
         ;;
-      alpha|hppa|m68k|mips|riscv64|sh4|sparc64)
+      hppa|m68k|mips|riscv64|sparc64)
         container_image=debian-all-test-cross
         ;;
       mips64)
         container_image=debian-all-test-cross
         container_cross_prefix=mips64-linux-gnuabi64-
         ;;
-      ppc|ppc64|ppc64le)
+      ppc64|ppc64le)
         container_image=debian-all-test-cross
         container_cross_prefix=powerpc${target_arch#ppc}-linux-gnu-
         ;;
 
+      # debian-legacy-test-cross architectures (need Debian 11)
+      # - libc6.1-dev-alpha-cross: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1054412
+      # - sh4-linux-user: binaries don't run with bookworm compiler
+
+      alpha|sh4)
+        container_image=debian-legacy-test-cross
+        ;;
+
       # architectures with individual containers
 
       aarch64)
@@ -1930,7 +1963,14 @@ if test "$skip_meson" = no; then
   if test "$cross_compile" = "yes"; then
     echo "[host_machine]" >> $cross
     echo "system = '$host_os'" >> $cross
-    echo "cpu_family = '$cpu'" >> $cross
+    case "$cpu" in
+        i386)
+            echo "cpu_family = 'x86'" >> $cross
+            ;;
+        *)
+            echo "cpu_family = '$cpu'" >> $cross
+            ;;
+    esac
     echo "cpu = '$cpu'" >> $cross
     if test "$bigendian" = "yes" ; then
         echo "endian = 'big'" >> $cross
diff --git a/meson.build b/meson.build
index d7c4095b395..ae412263ec7 100644
--- a/meson.build
+++ b/meson.build
@@ -323,7 +323,7 @@ endif
 # Compiler flags #
 ##################
 
-if cc.sizeof('void *') < 8
+if not have_ga and cc.sizeof('void *') < 8
   error('QEMU requires a 64-bit CPU host architecture')
 endif
 
-- 
2.53.0