Skip to content

Commit

Permalink
configure: Honour cross-prefix when finding ObjC compiler
Browse files Browse the repository at this point in the history
Currently when configure picks an ObjectiveC compiler it doesn't pay
attention to the cross-prefix.  This isn't a big deal in practice,
because we only use ObjC on macos and you can't cross-compile to
macos.  But it's a bit inconsistent.

Rearrange the handling of objcc in configure so that we do the
same thing that we do with cc and cxx. This means that the logic
for picking the ObjC compiler goes from:
 if --objcc is specified, use that
 otherwise if clang is available, use that
 otherwise use $cc
to:
 if --objcc is specified, use that
 otherwise if --cross-prefix is specified, use ${cross_prefix}clang
 otherwise if clang is available, use that
 otherwise use $cc

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1185
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20230418161554.744834-1-peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
pm215 authored and bonzini committed Apr 20, 2023
1 parent 32a9d73 commit c0c34c9
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ for opt do
;;
--cxx=*) CXX="$optarg"
;;
--objcc=*) objcc="$optarg"
;;
--cpu=*) cpu="$optarg"
;;
--extra-cflags=*)
Expand Down Expand Up @@ -361,6 +363,21 @@ else
cxx="${CXX-${cross_prefix}g++}"
fi

# Preferred ObjC compiler:
# $objcc (if set, i.e. via --objcc option)
# ${cross_prefix}clang (if cross-prefix specified)
# clang (if available)
# $cc
if test -z "${objcc}${cross_prefix}"; then
if has clang; then
objcc=clang
else
objcc="$cc"
fi
else
objcc="${objcc-${cross_prefix}clang}"
fi

ar="${AR-${cross_prefix}ar}"
as="${AS-${cross_prefix}as}"
ccas="${CCAS-$cc}"
Expand Down Expand Up @@ -647,13 +664,6 @@ do
fi
done

# Default objcc to clang if available, otherwise use CC
if has clang; then
objcc=clang
else
objcc="$cc"
fi

if test "$mingw32" = "yes" ; then
EXESUF=".exe"
# MinGW needs -mthreads for TLS and macro _MT.
Expand Down Expand Up @@ -713,7 +723,7 @@ for opt do
;;
--cxx=*)
;;
--objcc=*) objcc="$optarg"
--objcc=*)
;;
--make=*) make="$optarg"
;;
Expand Down

0 comments on commit c0c34c9

Please sign in to comment.