configure: create native file with contents of $host_cc

The argument of --host-cc is not obeyed when cross compiling.  To avoid
this issue, place it in a configuration file and pass it to meson
with --native-file.

While at it, clarify that --host-cc is not obeyed anyway when _not_
cross compiling, because cc="$host_cc" is placed before --host-cc is
processed.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2023-07-07 16:12:19 +02:00
parent b3403ed00b
commit 3c7ee49b81

15
configure vendored
View File

@ -288,7 +288,7 @@ static="no"
# ${cross_prefix}gcc (if cross-prefix specified) # ${cross_prefix}gcc (if cross-prefix specified)
# system compiler # system compiler
if test -z "${CC}${cross_prefix}"; then if test -z "${CC}${cross_prefix}"; then
cc="$host_cc" cc="cc"
else else
cc="${CC-${cross_prefix}gcc}" cc="${CC-${cross_prefix}gcc}"
fi fi
@ -927,8 +927,8 @@ Advanced options (experts only):
-Dmesonoptname=val passthrough option to meson unmodified -Dmesonoptname=val passthrough option to meson unmodified
--cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
--cc=CC use C compiler CC [$cc] --cc=CC use C compiler CC [$cc]
--host-cc=CC use C compiler CC [$host_cc] for code run at --host-cc=CC when cross compiling, use C compiler CC for code run
build time at build time [$host_cc]
--cxx=CXX use C++ compiler CXX [$cxx] --cxx=CXX use C++ compiler CXX [$cxx]
--objcc=OBJCC use Objective-C compiler OBJCC [$objcc] --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
--extra-cflags=CFLAGS append extra C compiler flags CFLAGS --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
@ -1892,7 +1892,6 @@ if test "$skip_meson" = no; then
echo "windres = [$(meson_quote $windres)]" >> $cross echo "windres = [$(meson_quote $windres)]" >> $cross
echo "windmc = [$(meson_quote $windmc)]" >> $cross echo "windmc = [$(meson_quote $windmc)]" >> $cross
if test "$cross_compile" = "yes"; then if test "$cross_compile" = "yes"; then
cross_arg="--cross-file config-meson.cross"
echo "[host_machine]" >> $cross echo "[host_machine]" >> $cross
echo "system = '$targetos'" >> $cross echo "system = '$targetos'" >> $cross
case "$cpu" in case "$cpu" in
@ -1909,6 +1908,14 @@ if test "$skip_meson" = no; then
else else
echo "endian = 'little'" >> $cross echo "endian = 'little'" >> $cross
fi fi
cross_arg="--cross-file config-meson.cross"
native="config-meson.native.new"
echo "# Automatically generated by configure - do not modify" > $native
echo "[binaries]" >> $native
echo "c = [$(meson_quote $host_cc)]" >> $native
mv $native config-meson.native
cross_arg="$cross_arg --native-file config-meson.native"
else else
cross_arg="--native-file config-meson.cross" cross_arg="--native-file config-meson.cross"
fi fi