On Mon, 7 Aug 2023 at 10:49, Paolo Bonzini <pbonz...@redhat.com> wrote:
>
> The CPU model has to be canonicalized to what Meson wants in the cross
> file, to what Linux uses for its asm-$ARCH directories, and to what
> QEMU uses for its user-mode emulation host/$ARCH directories.  Do
> all three in a single case statement, and check that the Linux and
> QEMU directories actually exist.
>
> At a small cost in repeated lines, this ensures that there are no hidden
> ordering requirements between the case statements.  In particular, commit
> 89e5b7935e9 ("configure: Fix linux-user host detection for riscv64",
> 2023-08-06) broke ppc64le because it assigned host_arch based on a
> non-canonicalized version of $cpu.
>
> Reported-by: Joel Stanley <j...@jms.id.au>
> Fixes: 89e5b7935e9 ("configure: Fix linux-user host detection for riscv64", 
> 2023-08-06)
> Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
> ---
>  configure | 159 +++++++++++++++++++++++++++++-------------------------
>  1 file changed, 87 insertions(+), 72 deletions(-)
>
> diff --git a/configure b/configure
> index 484d38d81f4..fb213412d7c 100755
> --- a/configure
> +++ b/configure
> @@ -469,59 +469,104 @@ else
>    echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output 
> '$cpu'"
>  fi
>
> -case "$cpu" in
> -  riscv*)
> -    host_arch=riscv ;;
> -  x32)
> -    host_arch=x86_64 ;;
> -  *)
> -    host_arch="$cpu" ;;
> -esac
> -
> -# Normalise host CPU name and set multilib cflags.  The canonicalization
> -# isn't really necessary, because the architectures that we check for
> -# should not hit the 'uname -m' case, but better safe than sorry.
> +# Normalise host CPU name to the values used by Meson cross files and in 
> source
> +# directories, and set multilib cflags.  The canonicalization isn't really
> +# necessary, because the architectures that we check for should not hit the
> +# 'uname -m' case, but better safe than sorry.
> +#
>  # Note that this case should only have supported host CPUs, not guests.
> +# Please keep it sorted.
> +host_arch=
> +linux_arch=
>  case "$cpu" in
> +  aarch64)
> +    host_arch=aarch64
> +    linux_arch=arm64 ;;
> +
>    armv*b|armv*l|arm)
>      cpu="arm" ;;
> +    host_arch=arm
> +    linux_arch=arm ;;
>
>    i386|i486|i586|i686)
>      cpu="i386"
> +    host_arch=i386
> +    linux_arch=x86
>      CPU_CFLAGS="-m32" ;;
> +
> +  loongarch*)
> +    cpu=loongarch64
> +    host_arch=loongarch64 ;;
> +
> +  mips64*)
> +    cpu=mips64
> +    host_arch=mips
> +    linux_arch=mips ;;
> +  mips*)
> +    cpu=mips
> +    host_arch=mips
> +    linux_arch=mips ;;
> +
> +  ppc)
> +    host_arch=ppc
> +    linux_arch=powerpc
> +    CPU_CFLAGS="-m32" ;;
> +  ppc64)
> +    host_arch=ppc64
> +    linux_arch=powerpc
> +    CPU_CFLAGS="-m64 -mbig-endian" ;;
> +  ppc64le)
> +    cpu=ppc64
> +    host_arch=ppc64
> +    linux_arch=powerpc
> +    CPU_CFLAGS="-m64 -mlittle-endian" ;;
> +
> +  riscv32 | riscv64)
> +    host_arch=riscv
> +    linux_arch=riscv
> +    ;;

Can we be consistent within this case statement about whether
the ';;' is on its own line or at the end of the last line of
the case ? We are not fully consistent within the entire
configure script, but mostly we put it on a line of its
own. (I prefer that personally.)

thanks
-- PMM

Reply via email to