aboutsummaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure269
1 files changed, 230 insertions, 39 deletions
diff --git a/configure b/configure
index 019fcbd..2b2b3d6 100755
--- a/configure
+++ b/configure
@@ -13,7 +13,7 @@ export CCACHE_RECACHE=yes
# make source path absolute
source_path=$(cd "$(dirname -- "$0")"; pwd)
-if test "$PWD" = "$source_path"
+if test "$PWD" -ef "$source_path"
then
echo "Using './build' as the directory for build output"
@@ -207,6 +207,10 @@ for opt do
;;
--objcc=*) objcc="$optarg"
;;
+ --rustc=*) RUSTC="$optarg"
+ ;;
+ --rustdoc=*) RUSTDOC="$optarg"
+ ;;
--cpu=*) cpu="$optarg"
;;
--extra-cflags=*)
@@ -252,6 +256,8 @@ python=
download="enabled"
skip_meson=no
use_containers="yes"
+rust="disabled"
+rust_target_triple=""
gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
gdb_arches=""
@@ -310,6 +316,7 @@ objcopy="${OBJCOPY-${cross_prefix}objcopy}"
ld="${LD-${cross_prefix}ld}"
ranlib="${RANLIB-${cross_prefix}ranlib}"
nm="${NM-${cross_prefix}nm}"
+readelf="${READELF-${cross_prefix}readelf}"
strip="${STRIP-${cross_prefix}strip}"
widl="${WIDL-${cross_prefix}widl}"
windres="${WINDRES-${cross_prefix}windres}"
@@ -317,6 +324,9 @@ windmc="${WINDMC-${cross_prefix}windmc}"
pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}"
sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
+rustc="${RUSTC-rustc}"
+rustdoc="${RUSTDOC-rustdoc}"
+
check_define() {
cat > $TMPC <<EOF
#if !defined($1)
@@ -353,6 +363,10 @@ elif check_define __NetBSD__; then
host_os=netbsd
elif check_define __APPLE__; then
host_os=darwin
+elif check_define EMSCRIPTEN ; then
+ host_os=emscripten
+ cpu=wasm32
+ cross_compile="yes"
else
# This is a fatal error, but don't report it yet, because we
# might be going to just print the --help text, or it might
@@ -388,7 +402,11 @@ elif check_define _ARCH_PPC ; then
cpu="ppc"
fi
elif check_define __mips__ ; then
- cpu="mips"
+ if check_define __mips64 ; then
+ cpu="mips64"
+ else
+ cpu="mips"
+ fi
elif check_define __s390__ ; then
if check_define __s390x__ ; then
cpu="s390x"
@@ -425,6 +443,7 @@ fi
# Please keep it sorted and synchronized with meson.build's host_arch.
host_arch=
linux_arch=
+raw_cpu=$cpu
case "$cpu" in
aarch64)
host_arch=aarch64
@@ -514,6 +533,9 @@ case "$cpu" in
linux_arch=x86
CPU_CFLAGS="-m64"
;;
+ wasm32)
+ CPU_CFLAGS="-m32"
+ ;;
esac
if test -n "$host_arch" && {
@@ -528,17 +550,17 @@ if test -n "$linux_arch" && ! test -d "$source_path/linux-headers/asm-$linux_arc
fi
check_py_version() {
- # We require python >= 3.8.
+ # We require python >= 3.9.
# NB: a True python conditional creates a non-zero return code (Failure)
- "$1" -c 'import sys; sys.exit(sys.version_info < (3,8))'
+ "$1" -c 'import sys; sys.exit(sys.version_info < (3,9))'
}
first_python=
if test -z "${PYTHON}"; then
# 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.12 python3.11 \
- python3.10 python3.9 python3.8; do
+ for binary in python3 python python3.13 python3.12 python3.11 \
+ python3.10 python3.9 ; do
if has "$binary"; then
python=$(command -v "$binary")
if check_py_version "$python"; then
@@ -610,6 +632,9 @@ meson_option_parse() {
exit 1
fi
}
+has_meson_option() {
+ test "${meson_options#*"$1"}" != "$meson_options"
+}
meson_add_machine_file() {
if test "$cross_compile" = "yes"; then
@@ -636,6 +661,10 @@ for opt do
;;
--objcc=*)
;;
+ --rustc=*)
+ ;;
+ --rustdoc=*)
+ ;;
--make=*)
;;
--install=*)
@@ -755,8 +784,14 @@ for opt do
;;
--container-engine=*) container_engine="$optarg"
;;
+ --rust-target-triple=*) rust_target_triple="$optarg"
+ ;;
--gdb=*) gdb_bin="$optarg"
;;
+ --enable-rust) rust=enabled
+ ;;
+ --disable-rust) rust=disabled
+ ;;
# everything else has the same name in configure and meson
--*) meson_option_parse "$opt" "$optarg"
;;
@@ -859,6 +894,8 @@ Advanced options (experts only):
at build time [$host_cc]
--cxx=CXX use C++ compiler CXX [$cxx]
--objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
+ --rustc=RUSTC use Rust compiler RUSTC [$rustc]
+ --rustdoc=RUSTDOC use rustdoc binary RUSTDOC [$rustdoc]
--extra-cflags=CFLAGS append extra C compiler flags CFLAGS
--extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
--extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
@@ -869,8 +906,9 @@ Advanced options (experts only):
--python=PYTHON use specified python [$python]
--ninja=NINJA use specified ninja [$ninja]
--static enable static build [$static]
- --without-default-features default all --enable-* options to "disabled"
- --without-default-devices do not include any device that is not needed to
+ --rust-target-triple=TRIPLE compilation target for Rust code [autodetect]
+ --without-default-features default all --enable-* options to "disabled"
+ --without-default-devices do not include any device that is not needed to
start the emulator (only use if you are including
desired devices in configs/devices/)
--with-devices-ARCH=NAME override default configs/devices
@@ -908,7 +946,7 @@ then
# 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.8 is required." \
+ error_exit "Cannot use '$first_python', Python >= 3.9 is required." \
"Use --python=/path/to/python to specify a supported Python."
else
error_exit "Python not found. Use --python=/path/to/python"
@@ -916,11 +954,11 @@ then
fi
if ! check_py_version "$python"; then
- error_exit "Cannot use '$python', Python >= 3.8 is required." \
+ error_exit "Cannot use '$python', Python >= 3.9 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"
+ " CentOS: dnf install python3.12"
fi
# Resolve PATH
@@ -1029,8 +1067,11 @@ if test "$static" = "yes" ; then
plugins="no"
fi
if test "$plugins" != "no"; then
- plugins=yes
- subdirs="$subdirs contrib/plugins"
+ if has_meson_option "-Dtcg_interpreter=true"; then
+ plugins="no"
+ else
+ plugins=yes
+ fi
fi
cat > $TMPC << EOF
@@ -1103,8 +1144,10 @@ fi
# gdb test
if test -n "$gdb_bin"; then
- gdb_version=$($gdb_bin --version | head -n 1)
- if version_ge ${gdb_version##* } 9.1; then
+ gdb_version_string=$($gdb_bin --version | head -n 1)
+ # Extract last field in the version string
+ gdb_version=${gdb_version_string##* }
+ if version_ge $gdb_version 9.1; then
gdb_arches=$($python "$source_path/scripts/probe-gdb-support.py" $gdb_bin)
else
gdb_bin=""
@@ -1139,6 +1182,140 @@ EOF
fi
##########################################
+# detect rust triple
+
+meson_version=$($meson --version)
+if test "$rust" != disabled && ! version_ge "$meson_version" 1.8.1; then
+ if test "$rust" = enabled; then
+ error_exit "Rust support needs Meson 1.8.1 or newer"
+ fi
+ echo "Rust needs Meson 1.8.1, disabling" 2>&1
+ rust=disabled
+fi
+if test "$rust" != disabled && has "$rustc" && $rustc -vV > "${TMPDIR1}/${TMPB}.out"; then
+ rust_host_triple=$(sed -n 's/^host: //p' "${TMPDIR1}/${TMPB}.out")
+else
+ if test "$rust" = enabled; then
+ error_exit "could not execute rustc binary \"$rustc\""
+ fi
+ rust=disabled
+fi
+if test "$rust" != disabled && test -z "$rust_target_triple"; then
+ # arch and os generally matches between meson and rust
+ rust_arch=$host_arch
+ rust_os=$host_os
+ rust_machine=unknown
+ rust_osvariant=
+
+ # tweak rust_os if needed; also, machine and variant depend on the OS
+ android=no
+ case "$host_os" in
+ darwin)
+ # e.g. aarch64-apple-darwin
+ rust_machine=apple
+ ;;
+
+ linux)
+ # detect android/glibc/musl
+ if check_define __ANDROID__; then
+ rust_osvariant=android
+ android=yes
+ else
+ cat > $TMPC << EOF
+#define _GNU_SOURCE
+#include <features.h>
+#ifndef __USE_GNU
+error using musl
+#endif
+EOF
+ if compile_object; then
+ rust_osvariant=gnu
+ else
+ rust_osvariant=musl
+ fi
+ fi
+
+ case "$cpu" in
+ arm)
+ # e.g. arm-unknown-linux-gnueabi, arm-unknown-linux-gnueabihf
+ write_c_skeleton
+ compile_object
+ if $READELF -A $TMPO | grep Tag_API_VFP_args: > /dev/null; then
+ rust_osvariant=${rust_osvariant}eabihf
+ else
+ rust_osvariant=${rust_osvariant}eabi
+ fi
+ ;;
+
+ mips64)
+ # e.g. mips64-unknown-linux-gnuabi64
+ rust_osvariant=${rust_osvariant}abi64
+ ;;
+ esac
+ ;;
+
+ netbsd)
+ # e.g. arm-unknown-netbsd-eabihf
+ test "$host_arch" = arm && rust_osvariant=eabihf
+ ;;
+
+ sunos)
+ rust_machine=pc
+ rust_os=solaris
+ ;;
+
+ windows)
+ # e.g. aarch64-pc-windows-gnullvm, x86_64-pc-windows-gnu (MSVC not supported)
+ rust_machine=pc
+ if test "$host_arch" = aarch64; then
+ rust_osvariant=gnullvm
+ else
+ rust_osvariant=gnu
+ fi
+ ;;
+ esac
+
+ # now tweak the architecture part, possibly based on pre-canonicalization --cpu
+ case "$host_arch" in
+ arm)
+ # preserve ISA version (armv7 etc.) from $raw_cpu if passed via --cpu
+ rust_arch=$raw_cpu
+ test "$rust_arch" = arm && test "$rust_os" != linux && rust_arch=armv7
+ ;;
+
+ mips)
+ # preserve ISA version (mipsisa64r6 etc.) and include endianness
+ rust_arch=${raw_cpu%el}
+ test "$bigendian" = no && rust_arch=${rust_arch}el
+ ;;
+
+ riscv32|riscv64)
+ # e.g. riscv64gc-unknown-linux-gnu, but riscv64-linux-android
+ test "$android" = no && rust_arch=${rust_arch}gc
+ ;;
+
+ sparc64)
+ if test "$rust_os" = solaris; then
+ rust_arch=sparcv9
+ rust_machine=sun
+ fi
+ ;;
+
+ x86_64)
+ # e.g. x86_64-unknown-linux-gnux32
+ test "$raw_cpu" = x32 && rust_osvariant=${rust_osvariant}x32
+ ;;
+ esac
+
+ if test "$android" = yes; then
+ # e.g. aarch64-linux-android
+ rust_target_triple=$rust_arch-$rust_os-$rust_osvariant
+ else
+ rust_target_triple=$rust_arch-$rust_machine-$rust_os${rust_osvariant:+-$rust_osvariant}
+ fi
+fi
+
+##########################################
# functions to probe cross compilers
container="no"
@@ -1246,9 +1423,9 @@ probe_target_compiler() {
target_arch=${1%%-*}
case $target_arch in
aarch64) container_hosts="x86_64 aarch64" ;;
+ aarch64_be) container_hosts="x86_64 aarch64" ;;
alpha) container_hosts=x86_64 ;;
arm) container_hosts="x86_64 aarch64" ;;
- cris) container_hosts=x86_64 ;;
hexagon) container_hosts=x86_64 ;;
hppa) container_hosts=x86_64 ;;
i386) container_hosts=x86_64 ;;
@@ -1276,6 +1453,10 @@ probe_target_compiler() {
case $target_arch in
# debian-all-test-cross architectures
+ aarch64_be)
+ container_image=debian-all-test-cross
+ container_cross_prefix=aarch64-linux-gnu-
+ ;;
hppa|m68k|mips|riscv64|sparc64)
container_image=debian-all-test-cross
;;
@@ -1307,9 +1488,6 @@ probe_target_compiler() {
container_image=debian-armhf-cross
container_cross_prefix=arm-linux-gnueabihf-
;;
- cris)
- container_image=fedora-cris-cross
- ;;
hexagon)
container_cross_prefix=hexagon-unknown-linux-musl-
container_cross_cc=${container_cross_prefix}clang
@@ -1326,7 +1504,7 @@ probe_target_compiler() {
container_cross_prefix=microblaze-linux-musl-
;;
mips64el)
- container_image=debian-mips64el-cross
+ container_image=debian-all-test-cross
container_cross_prefix=mips64el-linux-gnuabi64-
;;
tricore)
@@ -1528,10 +1706,9 @@ LINKS="$LINKS pc-bios/optionrom/Makefile"
LINKS="$LINKS pc-bios/s390-ccw/Makefile"
LINKS="$LINKS pc-bios/vof/Makefile"
LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
-LINKS="$LINKS tests/avocado tests/data"
+LINKS="$LINKS tests/data"
LINKS="$LINKS tests/qemu-iotests/check tests/qemu-iotests/Makefile"
LINKS="$LINKS python"
-LINKS="$LINKS contrib/plugins/Makefile "
for f in $LINKS ; do
if [ -e "$source_path/$f" ]; then
symlink "$source_path/$f" "$f"
@@ -1604,6 +1781,9 @@ if test "$container" != no; then
echo "RUNC=$runc" >> $config_host_mak
fi
echo "SUBDIRS=$subdirs" >> $config_host_mak
+if test "$rust" != disabled; then
+ echo "RUST_TARGET_TRIPLE=$rust_target_triple" >> $config_host_mak
+fi
echo "PYTHON=$python" >> $config_host_mak
echo "MKVENV_ENSUREGROUP=$mkvenv ensuregroup $mkvenv_online_flag" >> $config_host_mak
echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
@@ -1614,22 +1794,6 @@ if test "$default_targets" = "yes"; then
echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
fi
-# contrib/plugins configuration
-echo "# Automatically generated by configure - do not modify" > contrib/plugins/$config_host_mak
-echo "SRC_PATH=$source_path/contrib/plugins" >> contrib/plugins/$config_host_mak
-echo "PKG_CONFIG=${pkg_config}" >> contrib/plugins/$config_host_mak
-echo "CC=$cc $CPU_CFLAGS" >> contrib/plugins/$config_host_mak
-echo "CFLAGS=${CFLAGS-$default_cflags} $EXTRA_CFLAGS" >> contrib/plugins/$config_host_mak
-if test "$host_os" = windows; then
- echo "DLLTOOL=$dlltool" >> contrib/plugins/$config_host_mak
-fi
-if test "$host_os" = darwin; then
- echo "CONFIG_DARWIN=y" >> contrib/plugins/$config_host_mak
-fi
-if test "$host_os" = windows; then
- echo "CONFIG_WIN32=y" >> contrib/plugins/$config_host_mak
-fi
-
# tests/tcg configuration
mkdir -p tests/tcg
echo "# Automatically generated by configure - do not modify" > tests/tcg/$config_host_mak
@@ -1673,10 +1837,15 @@ for target in $target_list; do
echo "GDB=$gdb_bin" >> $config_target_mak
fi
- if test "${arch}" = "aarch64" && version_ge ${gdb_version##* } 15.0; then
+ if test "${gdb_arches#*aarch64}" != "$gdb_arches" && version_ge $gdb_version 15.1; then
echo "GDB_HAS_MTE=y" >> $config_target_mak
fi
+ if test "${gdb_arches#*aarch64}" != "$gdb_arches" && version_ge $gdb_version 16.0; then
+ # GDB has to support MTE in baremetal to allow debugging MTE in QEMU system mode
+ echo "GDB_SUPPORTS_MTE_IN_BAREMETAL=y" >> $config_target_mak
+ fi
+
echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs
tcg_tests_targets="$tcg_tests_targets $target"
fi
@@ -1735,12 +1904,22 @@ if test "$skip_meson" = no; then
echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
+ if test "$rust" != disabled; then
+ if test "$rust_host_triple" != "$rust_target_triple"; then
+ echo "rust = [$(meson_quote $rustc --target "$rust_target_triple")]" >> $cross
+ echo "rustdoc = [$(meson_quote $rustdoc --target "$rust_target_triple")]" >> $cross
+ else
+ echo "rust = [$(meson_quote $rustc)]" >> $cross
+ echo "rustdoc = [$(meson_quote $rustdoc)]" >> $cross
+ fi
+ fi
echo "ar = [$(meson_quote $ar)]" >> $cross
echo "dlltool = [$(meson_quote $dlltool)]" >> $cross
echo "nm = [$(meson_quote $nm)]" >> $cross
echo "pkgconfig = [$(meson_quote $pkg_config)]" >> $cross
echo "pkg-config = [$(meson_quote $pkg_config)]" >> $cross
echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
+ echo "readelf = [$(meson_quote $readelf)]" >> $cross
if has $sdl2_config; then
echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
fi
@@ -1770,6 +1949,9 @@ if test "$skip_meson" = no; then
echo "# Automatically generated by configure - do not modify" > $native
echo "[binaries]" >> $native
echo "c = [$(meson_quote $host_cc)]" >> $native
+ if test "$rust" != disabled; then
+ echo "rust = [$(meson_quote $rustc)]" >> $cross
+ fi
mv $native config-meson.native
meson_option_add --native-file
meson_option_add config-meson.native
@@ -1788,6 +1970,7 @@ if test "$skip_meson" = no; then
test "$pie" = no && meson_option_add -Db_pie=false
# QEMU options
+ test "$rust" != "disabled" && meson_option_add "-Drust=$rust"
test "$cfi" != false && meson_option_add "-Dcfi=$cfi" "-Db_lto=$cfi"
test "$docs" != auto && meson_option_add "-Ddocs=$docs"
test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
@@ -1872,3 +2055,11 @@ echo ' "$@"' >>config.status
chmod +x config.status
rm -r "$TMPDIR1"
+
+if test "$rust" != disabled; then
+ echo
+ echo 'INFO: Rust bindings generation with `bindgen` might fail in some cases where'
+ echo 'the detected `libclang` does not match the expected `clang` version/target. In'
+ echo 'this case you must pass the path to `clang` and `libclang` to your build'
+ echo 'command invocation using the environment variables CLANG_PATH and LIBCLANG_PATH'
+fi