diff mbox series

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

Message ID 20231116172820.2481604-1-alex.bennee@linaro.org
State New
Headers show
Series [RFC] configure: don't try a "native" cross for i386 | expand

Commit Message

Alex Bennée Nov. 16, 2023, 5:28 p.m. UTC
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(-)

Comments

Daniel P. Berrangé Nov. 16, 2023, 5:49 p.m. UTC | #1
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
Paolo Bonzini Nov. 20, 2023, 10:35 a.m. UTC | #2
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
>
diff mbox series

Patch

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 | \