safe_stack=""
use_containers="yes"
gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
+gdb_arches=""
if test -e "$source_path/.git"
then
: ${make=${MAKE-make}}
-# We prefer python 3.x. A bare 'python' is traditionally
-# python 2.x, but some distros have it as python 3.x, so
-# we check that too
+
+check_py_version() {
+ # We require python >= 3.6.
+ # NB: a True python conditional creates a non-zero return code (Failure)
+ "$1" -c 'import sys; sys.exit(sys.version_info < (3,6))'
+}
+
python=
-explicit_python=no
-for binary in "${PYTHON-python3}" python
-do
- if has "$binary"
- then
- python=$(command -v "$binary")
- break
+first_python=
+if test -z "${PYTHON}"; then
+ explicit_python=no
+ # A bare 'python' is traditionally python 2.x, but some distros
+ # have it as python 3.x, so check in both places.
+ for binary in python3 python python3.11 python3.10 python3.9 python3.8 python3.7 python3.6; do
+ if has "$binary"; then
+ python=$(command -v "$binary")
+ if check_py_version "$python"; then
+ # This one is good.
+ first_python=
+ break
+ else
+ first_python=$python
+ fi
+ fi
+ done
+else
+ # Same as above, but only check the environment variable.
+ has "${PYTHON}" || error_exit "The PYTHON environment variable does not point to an executable"
+ python=$(command -v "$PYTHON")
+ explicit_python=yes
+ if check_py_version "$python"; then
+ # This one is good.
+ first_python=
+ else
+ first_python=$first_python
fi
-done
-
+fi
# Check for ancillary tools used in testing
genisoimage=
if test -z "$python"
then
- error_exit "Python not found. Use --python=/path/to/python"
+ # If first_python is set, there was a binary somewhere even though
+ # it was not suitable. Use it for the error message.
+ if test -n "$first_python"; then
+ error_exit "Cannot use '$first_python', Python >= 3.6 is required." \
+ "Use --python=/path/to/python to specify a supported Python."
+ else
+ error_exit "Python not found. Use --python=/path/to/python"
+ fi
fi
+
if ! has "$make"
then
error_exit "GNU make ($make) not found"
fi
-# Note that if the Python conditional here evaluates True we will exit
-# with status 1 which is a shell 'false' value.
-if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
+if ! check_py_version "$python"; then
error_exit "Cannot use '$python', Python >= 3.6 is required." \
"Use --python=/path/to/python to specify a supported Python."
fi
-# Suppress writing compiled files
-python="$python -B"
+# Resolve PATH + suppress writing compiled files
+python="$(command -v "$python") -B"
+
+has_meson() {
+ local python_dir=$(dirname "$python")
+ # PEP405: pyvenv.cfg is either adjacent to the Python executable
+ # or one directory above
+ if test -f $python_dir/pyvenv.cfg || test -f $python_dir/../pyvenv.cfg; then
+ # Ensure that Meson and Python come from the same virtual environment
+ test -x "$python_dir/meson" &&
+ test "$(command -v meson)" -ef "$python_dir/meson"
+ else
+ has meson
+ fi
+}
if test -z "$meson"; then
- if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.61.5; then
+ if test "$explicit_python" = no && has_meson && version_ge "$(meson --version)" 0.61.5; then
meson=meson
elif test "$git_submodules_action" != 'ignore' ; then
meson=git
add_to warn_flags -Wexpansion-to-defined
add_to warn_flags -Wimplicit-fallthrough=2
add_to warn_flags -Wmissing-format-attribute
-add_to warn_flags -Wthread-safety
+
+if test "$targetos" != "darwin"; then
+ add_to warn_flags -Wthread-safety
+fi
nowarn_flags=
add_to nowarn_flags -Wno-initializer-overrides
error_exit "-static-pie not available due to missing toolchain support"
else
pie="no"
- QEMU_CFLAGS="-fno-pie -no-pie $QEMU_CFLAGS"
+ QEMU_CFLAGS="-fno-pie $QEMU_CFLAGS"
fi
elif test "$pie" = "no"; then
if compile_prog "-Werror -fno-pie" "-no-pie"; then
# functions to probe cross compilers
container="no"
+runc=""
if test $use_containers = "yes" && (has "docker" || has "podman"); then
case $($python "$source_path"/tests/docker/docker.py probe) in
*docker) container=docker ;;
esac
if test "$container" != "no"; then
docker_py="$python $source_path/tests/docker/docker.py --engine $container"
+ runc=$($python "$source_path"/tests/docker/docker.py probe)
fi
fi
# tests might fail. Prefer to keep the relevant files in their own
# directory and symlink the directory instead.
LINKS="Makefile"
+LINKS="$LINKS docs/config"
LINKS="$LINKS pc-bios/optionrom/Makefile"
LINKS="$LINKS pc-bios/s390-ccw/Makefile"
LINKS="$LINKS pc-bios/vof/Makefile"
gdb_version=$($gdb_bin --version | head -n 1)
if version_ge ${gdb_version##* } 9.1; then
echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
+ gdb_arches=$("$source_path/scripts/probe-gdb-support.py" $gdb_bin)
else
gdb_bin=""
fi
if test "$container" != no; then
echo "ENGINE=$container" >> $config_host_mak
+ echo "RUNC=$runc" >> $config_host_mak
fi
echo "ROMS=$roms" >> $config_host_mak
echo "MAKE=$make" >> $config_host_mak
write_target_makefile "build-tcg-tests-$target" >> "$config_target_mak"
echo "BUILD_STATIC=$build_static" >> "$config_target_mak"
echo "QEMU=$PWD/$qemu" >> "$config_target_mak"
+
+ # will GDB work with these binaries?
+ if test "${gdb_arches#*$arch}" != "$gdb_arches"; then
+ echo "HOST_GDB_SUPPORTS_ARCH=y" >> "$config_target_mak"
+ fi
+
echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs
tcg_tests_targets="$tcg_tests_targets $target"
fi