[RFC PATCH] configure: don't try a "native" cross for i386

Alex Bennée posted 1 patch 1 year ago
Failed in applying to current master (apply log)
configure | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
[RFC PATCH] configure: don't try a "native" cross for i386
Posted by Alex Bennée 1 year ago
As 32 bit x86 become rarer we are starting to run into problems with
search paths. Although we switched to a Debian container we still
favour the native CC on a Bookworm host. As a result we have a broken
cross compile setup which then fails to build with:

    BUILD   i386-linux-user guest-tests
  In file included from /usr/include/linux/stat.h:5,
                   from /usr/include/bits/statx.h:31,
                   from /usr/include/sys/stat.h:465,
                   from /home/alex/lsrc/qemu.git/tests/tcg/multiarch/linux/linux-test.c:28:
  /usr/include/linux/types.h:5:10: fatal error: asm/types.h: No such file or directory
      5 | #include <asm/types.h>
        |          ^~~~~~~~~~~~~
  compilation terminated.
  make[1]: *** [Makefile:119: linux-test] Error 1
  make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:50: build-tcg-tests-i386-linux-user] Error 2

So lets stop trying to be cute and honour cross_prefix_i386 when
searching locally. We also need to ensure we are using the correct
prefix if we do end up using the container version. We can also drop
the extra CFLAGS while we are at it.

Fixes: 791e6fedc5 (tests/docker: replace fedora-i386 with debian-i686)
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 configure | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/configure b/configure
index 5e7b76e3a1..2343d629ec 100755
--- a/configure
+++ b/configure
@@ -1190,7 +1190,6 @@ fi
 : ${cross_cc_cflags_armeb="-mbig-endian"}
 : ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"}
 : ${cross_cc_cflags_hexagon="-mv73 -O2 -static"}
-: ${cross_cc_cflags_i386="-m32"}
 : ${cross_cc_cflags_ppc="-m32 -mbig-endian"}
 : ${cross_cc_cflags_ppc64="-m64 -mbig-endian"}
 : ${cross_cc_ppc64le="$cross_cc_ppc64"}
@@ -1308,7 +1307,7 @@ probe_target_compiler() {
         ;;
       i386)
         container_image=debian-i686-cross
-        container_cross_prefix=
+        container_cross_prefix=i686-linux-gnu-
         ;;
       loongarch64)
         container_image=debian-loongarch-cross
@@ -1394,7 +1393,6 @@ probe_target_compiler() {
   case "$target_arch:$cpu" in
     aarch64_be:aarch64 | \
     armeb:arm | \
-    i386:x86_64 | \
     mips*:mips64 | \
     ppc*:ppc64 | \
     sparc:sparc64 | \
-- 
2.39.2


Re: [RFC PATCH] configure: don't try a "native" cross for i386
Posted by Paolo Bonzini 1 year ago
On Thu, Nov 16, 2023 at 6:28 PM Alex Bennée <alex.bennee@linaro.org> wrote:
>
> As 32 bit x86 become rarer we are starting to run into problems with
> search paths. Although we switched to a Debian container we still
> favour the native CC on a Bookworm host. As a result we have a broken
> cross compile setup which then fails to build with:
>
>     BUILD   i386-linux-user guest-tests
>   In file included from /usr/include/linux/stat.h:5,
>                    from /usr/include/bits/statx.h:31,
>                    from /usr/include/sys/stat.h:465,
>                    from /home/alex/lsrc/qemu.git/tests/tcg/multiarch/linux/linux-test.c:28:
>   /usr/include/linux/types.h:5:10: fatal error: asm/types.h: No such file or directory
>       5 | #include <asm/types.h>
>         |          ^~~~~~~~~~~~~
>   compilation terminated.
>   make[1]: *** [Makefile:119: linux-test] Error 1
>   make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:50: build-tcg-tests-i386-linux-user] Error 2
>
> So lets stop trying to be cute and honour cross_prefix_i386 when
> searching locally. We also need to ensure we are using the correct
> prefix if we do end up using the container version. We can also drop
> the extra CFLAGS while we are at it.

This is a good idea for linux-user, and I would extend it to all
cases, but please don't do it for softmmu because it would break
building SeaBIOS and the boot ROMs with the system compiler.

As the above error shows, the issue is caused by incompatibilities
between the 32- and 64-bit Linux headers, and it does not apply to
freestanding environments used when building the firmware blobs and
the softmmu targets in tests/tcg .

Paolo


Paolo

> Fixes: 791e6fedc5 (tests/docker: replace fedora-i386 with debian-i686)
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  configure | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/configure b/configure
> index 5e7b76e3a1..2343d629ec 100755
> --- a/configure
> +++ b/configure
> @@ -1190,7 +1190,6 @@ fi
>  : ${cross_cc_cflags_armeb="-mbig-endian"}
>  : ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"}
>  : ${cross_cc_cflags_hexagon="-mv73 -O2 -static"}
> -: ${cross_cc_cflags_i386="-m32"}
>  : ${cross_cc_cflags_ppc="-m32 -mbig-endian"}
>  : ${cross_cc_cflags_ppc64="-m64 -mbig-endian"}
>  : ${cross_cc_ppc64le="$cross_cc_ppc64"}
> @@ -1308,7 +1307,7 @@ probe_target_compiler() {
>          ;;
>        i386)
>          container_image=debian-i686-cross
> -        container_cross_prefix=
> +        container_cross_prefix=i686-linux-gnu-
>          ;;
>        loongarch64)
>          container_image=debian-loongarch-cross
> @@ -1394,7 +1393,6 @@ probe_target_compiler() {
>    case "$target_arch:$cpu" in
>      aarch64_be:aarch64 | \
>      armeb:arm | \
> -    i386:x86_64 | \
>      mips*:mips64 | \
>      ppc*:ppc64 | \
>      sparc:sparc64 | \
> --
> 2.39.2
>
Re: [RFC PATCH] configure: don't try a "native" cross for i386
Posted by Daniel P. Berrangé 1 year ago
On Thu, Nov 16, 2023 at 05:28:20PM +0000, Alex Bennée wrote:
> As 32 bit x86 become rarer we are starting to run into problems with
> search paths. Although we switched to a Debian container we still
> favour the native CC on a Bookworm host. As a result we have a broken
> cross compile setup which then fails to build with:
> 
>     BUILD   i386-linux-user guest-tests
>   In file included from /usr/include/linux/stat.h:5,
>                    from /usr/include/bits/statx.h:31,
>                    from /usr/include/sys/stat.h:465,
>                    from /home/alex/lsrc/qemu.git/tests/tcg/multiarch/linux/linux-test.c:28:
>   /usr/include/linux/types.h:5:10: fatal error: asm/types.h: No such file or directory
>       5 | #include <asm/types.h>
>         |          ^~~~~~~~~~~~~
>   compilation terminated.
>   make[1]: *** [Makefile:119: linux-test] Error 1
>   make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:50: build-tcg-tests-i386-linux-user] Error 2
> 
> So lets stop trying to be cute and honour cross_prefix_i386 when
> searching locally. We also need to ensure we are using the correct
> prefix if we do end up using the container version. We can also drop
> the extra CFLAGS while we are at it.
> 
> Fixes: 791e6fedc5 (tests/docker: replace fedora-i386 with debian-i686)
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  configure | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

> 
> diff --git a/configure b/configure
> index 5e7b76e3a1..2343d629ec 100755
> --- a/configure
> +++ b/configure
> @@ -1190,7 +1190,6 @@ fi
>  : ${cross_cc_cflags_armeb="-mbig-endian"}
>  : ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"}
>  : ${cross_cc_cflags_hexagon="-mv73 -O2 -static"}
> -: ${cross_cc_cflags_i386="-m32"}
>  : ${cross_cc_cflags_ppc="-m32 -mbig-endian"}
>  : ${cross_cc_cflags_ppc64="-m64 -mbig-endian"}
>  : ${cross_cc_ppc64le="$cross_cc_ppc64"}
> @@ -1308,7 +1307,7 @@ probe_target_compiler() {
>          ;;
>        i386)
>          container_image=debian-i686-cross
> -        container_cross_prefix=
> +        container_cross_prefix=i686-linux-gnu-
>          ;;
>        loongarch64)
>          container_image=debian-loongarch-cross
> @@ -1394,7 +1393,6 @@ probe_target_compiler() {
>    case "$target_arch:$cpu" in
>      aarch64_be:aarch64 | \
>      armeb:arm | \
> -    i386:x86_64 | \
>      mips*:mips64 | \
>      ppc*:ppc64 | \
>      sparc:sparc64 | \

I kinda wonder if we have people using the rest of this arch compat
stuff too ? With debian making it easy to parallel install the full
cross-arch toolchains + matching libraries, it shouldn't be needed in
general for any arch ?  Getting rid of QEMU specific special cases
like this in configure would be nice.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|