fi
fi
- mkdir build
- touch $MARKER
+ if ! mkdir build || ! touch $MARKER
+ then
+ echo "ERROR: Could not create ./build directory. Check the permissions on"
+ echo "your source directory, or try doing an out-of-tree build."
+ exit 1
+ fi
cat > GNUmakefile <<'EOF'
# This file is auto-generated by configure to support in-source tree
safe_stack=""
use_containers="yes"
gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
+gdb_arches=""
+glib_has_gslice="no"
if test -e "$source_path/.git"
then
sanitizers="no"
tsan="no"
fortify_source="yes"
+docs="auto"
EXESUF=""
modules="no"
prefix="/usr/local"
pie=""
coroutine=""
plugins="$default_feature"
-meson=""
ninja=""
bindir="bin"
skip_meson=no
;;
--cxx=*) CXX="$optarg"
;;
+ --objcc=*) objcc="$optarg"
+ ;;
--cpu=*) cpu="$optarg"
;;
--extra-cflags=*)
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}"
check_py_version() {
- # We require python >= 3.6.
+ # We require python >= 3.7.
# NB: a True python conditional creates a non-zero return code (Failure)
- "$1" -c 'import sys; sys.exit(sys.version_info < (3,6))'
+ "$1" -c 'import sys; sys.exit(sys.version_info < (3,7))'
}
python=
+pypi="enabled"
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
+ for binary in python3 python python3.11 python3.10 python3.9 python3.8 python3.7; do
if has "$binary"; then
python=$(command -v "$binary")
if check_py_version "$python"; then
# 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=
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.
;;
--cxx=*)
;;
- --objcc=*) objcc="$optarg"
+ --objcc=*)
;;
--make=*) make="$optarg"
;;
--install=*)
;;
- --python=*) python="$optarg" ; explicit_python=yes
+ --python=*) python="$optarg"
;;
--skip-meson) skip_meson=yes
;;
- --meson=*) meson="$optarg"
- ;;
--ninja=*) ninja="$optarg"
;;
--smbd=*) smbd="$optarg"
;;
--disable-debug-info) meson_option_add -Ddebug=false
;;
+ --enable-docs) docs=enabled
+ ;;
+ --disable-docs) docs=disabled
+ ;;
--enable-modules)
modules="yes"
;;
--enable-debug)
# Enable debugging options that aren't excessively noisy
debug_tcg="yes"
+ meson_option_parse --enable-debug-graph-lock ""
meson_option_parse --enable-debug-mutex ""
meson_option_add -Doptimization=0
fortify_source="no"
--with-git-submodules=*)
git_submodules_action="$optarg"
;;
+ --disable-pypi) pypi="disabled"
+ ;;
+ --enable-pypi) pypi="enabled"
+ ;;
--enable-plugins) if test "$mingw32" = "yes"; then
error_exit "TCG plugins not currently supported on Windows platforms"
else
--cross-prefix-ARCH=PREFIX cross compiler prefix when building ARCH guest test cases
--make=MAKE use specified make [$make]
--python=PYTHON use specified python [$python]
- --meson=MESON use specified meson [$meson]
--ninja=NINJA use specified ninja [$ninja]
--smbd=SMBD use specified smbd [$smbd]
--with-git=GIT use specified git [$git]
# 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." \
+ error_exit "Cannot use '$first_python', Python >= 3.7 is required." \
"Use --python=/path/to/python to specify a supported Python."
else
error_exit "Python not found. Use --python=/path/to/python"
fi
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."
+ error_exit "Cannot use '$python', Python >= 3.7 is required." \
+ "Use --python=/path/to/python to specify a supported Python." \
+ "Maybe try:" \
+ " openSUSE Leap 15.3+: zypper install python39" \
+ " CentOS 8: dnf install python38"
fi
-# Resolve PATH + suppress writing compiled files
-python="$(command -v "$python") -B"
+# Resolve PATH
+python="$(command -v "$python")"
-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
-}
+# Create a Python virtual environment using our configured python.
+# The stdout of this script will be the location of a symlink that
+# points to the configured Python.
+# Entry point scripts for pip, meson, and sphinx are generated if those
+# packages are present.
-if test -z "$meson"; 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
- elif test -e "${source_path}/meson/meson.py" ; then
- meson=internal
- else
- if test "$explicit_python" = yes; then
- error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
- else
- error_exit "Meson not found. Use --meson=/path/to/meson"
- fi
- fi
-else
- # Meson uses its own Python interpreter to invoke other Python scripts,
- # but the user wants to use the one they specified with --python.
- #
- # We do not want to override the distro Python interpreter (and sometimes
- # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
- # just require --meson=git|internal together with --python.
- if test "$explicit_python" = yes; then
- case "$meson" in
- git | internal) ;;
- *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
- esac
- fi
+# Defaults assumed for now:
+# - venv is cleared if it exists already;
+# - venv is allowed to use system packages;
+# - all setup can be performed offline;
+# - missing packages may be fetched from PyPI,
+# unless --disable-pypi is passed.
+# - pip is not installed into the venv when possible,
+# but ensurepip is called as a fallback when necessary.
+
+echo "python determined to be '$python'"
+echo "python version: $($python --version)"
+
+python="$($python -B "${source_path}/python/scripts/mkvenv.py" create pyvenv)"
+if test "$?" -ne 0 ; then
+ error_exit "python venv creation failed"
+fi
+
+# Suppress writing compiled files
+python="$python -B"
+mkvenv="$python ${source_path}/python/scripts/mkvenv.py"
+
+mkvenv_flags=""
+if test "$pypi" = "enabled" ; then
+ mkvenv_flags="--online"
fi
-if test "$meson" = git; then
- git_submodules="${git_submodules} meson"
+if ! $mkvenv ensure \
+ $mkvenv_flags \
+ --dir "${source_path}/python/wheels" \
+ --diagnose "meson" \
+ "meson>=0.61.5" ;
+then
+ exit 1
fi
-case "$meson" in
- git | internal)
- meson="$python ${source_path}/meson/meson.py"
- ;;
- *) meson=$(command -v "$meson") ;;
-esac
+# At this point, we expect Meson to be installed and available.
+# We expect mkvenv or pip to have created pyvenv/bin/meson for us.
+# We ignore PATH completely here: we want to use the venv's Meson
+# *exclusively*.
+
+meson="$(cd pyvenv/bin; pwd)/meson"
+
+# Conditionally ensure Sphinx is installed.
+
+mkvenv_flags=""
+if test "$pypi" = "enabled" -a "$docs" = "enabled" ; then
+ mkvenv_flags="--online"
+fi
+
+if test "$docs" != "disabled" ; then
+ if ! $mkvenv ensure \
+ $mkvenv_flags \
+ --diagnose "sphinx-build" \
+ "sphinx>=1.6.0" "sphinx-rtd-theme>=0.5.0";
+ then
+ if test "$docs" = "enabled" ; then
+ exit 1
+ fi
+ echo "Sphinx not found/usable, disabling docs."
+ docs=disabled
+ else
+ docs=enabled
+ fi
+fi
# Probe for ninja
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
fi
done
+# Check whether glib has gslice, which we have to avoid for correctness.
+# TODO: remove this check and the corresponding workaround (qtree) when
+# the minimum supported glib is >= $glib_dropped_gslice_version.
+glib_dropped_gslice_version=2.75.3
+for i in $glib_modules; do
+ if ! $pkg_config --atleast-version=$glib_dropped_gslice_version $i; then
+ glib_has_gslice="yes"
+ break
+ fi
+done
+
glib_bindir="$($pkg_config --variable=bindir glib-2.0)"
if test -z "$glib_bindir" ; then
glib_bindir="$($pkg_config --variable=prefix glib-2.0)"/bin
# detect the static linking issue of ubsan, see also:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
cat > $TMPC << EOF
-#include <stdlib.h>
-int main(void) {
- void *tmp = malloc(10);
- if (tmp != NULL) {
- return *(int *)(tmp + 2);
- }
- return 1;
+int main(int argc, char **argv)
+{
+ return argc + 1;
}
EOF
if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; 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
echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
echo "GLIB_BINDIR=$glib_bindir" >> $config_host_mak
echo "GLIB_VERSION=$($pkg_config --modversion glib-2.0)" >> $config_host_mak
+if test "$glib_has_gslice" = "yes" ; then
+ echo "HAVE_GLIB_WITH_SLICE_ALLOCATOR=y" >> $config_host_mak
+fi
echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
echo "EXESUF=$EXESUF" >> $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
rm -rf meson-private meson-info meson-logs
+ # Prevent meson from automatically downloading wrapped subprojects when missing.
+ # You can use 'meson subprojects download' before running configure.
+ meson_option_add "--wrap-mode=nodownload"
+
# Built-in options
test "$bindir" != "bin" && meson_option_add "-Dbindir=$bindir"
test "$default_feature" = no && meson_option_add -Dauto_features=disabled
# QEMU options
test "$cfi" != false && meson_option_add "-Dcfi=$cfi"
+ test "$docs" != auto && meson_option_add "-Ddocs=$docs"
test "$fdt" != auto && meson_option_add "-Dfdt=$fdt"
test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
test "$qemu_suffix" != qemu && meson_option_add "-Dqemu_suffix=$qemu_suffix"