diff mbox series

[PULL,10/18] configure: pass whole target name to probe_target_compiler

Message ID 20220712124956.150451-11-pbonzini@redhat.com
State New
Headers show
Series [PULL,01/18] tests/vm: do not specify -bios option | expand

Commit Message

Paolo Bonzini July 12, 2022, 12:49 p.m. UTC
Let probe_target_compiler know if it is looking for a compiler for a
softmmu (freestanding) or a linux-user (hosted) environment.  The
detection for the compiler has to be done differently in the two
cases.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure | 52 ++++++++++++++++++++++++++++++++--------------------
 1 file changed, 32 insertions(+), 20 deletions(-)
diff mbox series

Patch

diff --git a/configure b/configure
index 0fd2838e82..5256bc88e5 100755
--- a/configure
+++ b/configure
@@ -1875,6 +1875,17 @@  compute_target_variable() {
   fi
 }
 
+# probe_target_compiler TARGET
+#
+# Look for a compiler for the given target, either native or cross.
+# Set variables target_* if a compiler is found, and container_cross_*
+# if a Docker-based cross-compiler image is known for the target.
+# Set got_cross_cc to yes/no depending on whether a non-container-based
+# compiler was found.
+#
+# If TARGET is a user-mode emulation target, also set build_static to
+# "y" if static linking is possible.
+#
 probe_target_compiler() {
   # reset all output variables
   container_image=
@@ -1896,7 +1907,8 @@  probe_target_compiler() {
   target_ranlib=
   target_strip=
 
-  case $1 in
+  target_arch=${1%%-*}
+  case $target_arch in
     aarch64) container_hosts="x86_64 aarch64" ;;
     alpha) container_hosts=x86_64 ;;
     arm) container_hosts="x86_64 aarch64" ;;
@@ -1925,7 +1937,7 @@  probe_target_compiler() {
   for host in $container_hosts; do
     test "$container" != no || continue
     test "$host" = "$cpu" || continue
-    case $1 in
+    case $target_arch in
       aarch64)
         # We don't have any bigendian build tools so we only use this for AArch64
         container_image=debian-arm64-cross
@@ -2041,23 +2053,23 @@  probe_target_compiler() {
     : ${container_cross_strip:=${container_cross_prefix}strip}
   done
 
-  eval "target_cflags=\${cross_cc_cflags_$1}"
-  if eval test -n "\"\${cross_cc_$1}\""; then
-    if eval has "\"\${cross_cc_$1}\""; then
-      eval "target_cc=\"\${cross_cc_$1}\""
+  eval "target_cflags=\${cross_cc_cflags_$target_arch}"
+  if eval test -n "\"\${cross_cc_$target_arch}\""; then
+    if eval has "\"\${cross_cc_$target_arch}\""; then
+      eval "target_cc=\"\${cross_cc_$target_arch}\""
     fi
   else
-    compute_target_variable $1 target_cc gcc
+    compute_target_variable $target_arch target_cc gcc
   fi
   target_ccas=$target_cc
-  compute_target_variable $1 target_ar ar
-  compute_target_variable $1 target_as as
-  compute_target_variable $1 target_ld ld
-  compute_target_variable $1 target_nm nm
-  compute_target_variable $1 target_objcopy objcopy
-  compute_target_variable $1 target_ranlib ranlib
-  compute_target_variable $1 target_strip strip
-  case "$1:$cpu" in
+  compute_target_variable $target_arch target_ar ar
+  compute_target_variable $target_arch target_as as
+  compute_target_variable $target_arch target_ld ld
+  compute_target_variable $target_arch target_nm nm
+  compute_target_variable $target_arch target_objcopy objcopy
+  compute_target_variable $target_arch target_ranlib ranlib
+  compute_target_variable $target_arch target_strip strip
+  case "$target_arch:$cpu" in
     aarch64_be:aarch64 | \
     armeb:arm | \
     i386:x86_64 | \
@@ -2079,7 +2091,7 @@  probe_target_compiler() {
       ;;
   esac
   if test -n "$target_cc"; then
-    case $1 in
+    case $target_arch in
       i386|x86_64)
         if $target_cc --version | grep -qi "clang"; then
           unset target_cc
@@ -2241,7 +2253,7 @@  done
 
 # Mac OS X ships with a broken assembler
 roms=
-probe_target_compiler i386
+probe_target_compiler i386-softmmu
 if test -n "$target_cc" &&
         test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
         test "$targetos" != "haiku" && test "$softmmu" = yes ; then
@@ -2264,7 +2276,7 @@  if test -n "$target_cc" &&
     fi
 fi
 
-probe_target_compiler ppc
+probe_target_compiler ppc-softmmu
 if test -n "$target_cc" && test "$softmmu" = yes; then
     roms="$roms pc-bios/vof"
     config_mak=pc-bios/vof/config.mak
@@ -2275,7 +2287,7 @@  fi
 
 # Only build s390-ccw bios if the compiler has -march=z900 or -march=z10
 # (which is the lowest architecture level that Clang supports)
-probe_target_compiler s390x
+probe_target_compiler s390x-softmmu
 if test -n "$target_cc" && test "$softmmu" = yes; then
   write_c_skeleton
   do_compiler "$target_cc" $target_cc_cflags -march=z900 -o $TMPO -c $TMPC
@@ -2488,7 +2500,6 @@  tcg_tests_targets=
 for target in $target_list; do
   arch=${target%%-*}
 
-  probe_target_compiler ${arch}
   config_target_mak=tests/tcg/config-$target.mak
 
   echo "# Automatically generated by configure - do not modify" > $config_target_mak
@@ -2507,6 +2518,7 @@  for target in $target_list; do
       ;;
   esac
 
+  probe_target_compiler $target
   got_cross_cc=no
   unset build_static