do_compiler "$cxx" "$@"
}
+# Append $2 to the variable named $1, with space separation
+add_to() {
+ eval $1=\${$1:+\"\$$1 \"}\$2
+}
+
update_cxxflags() {
# Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
# options which some versions of GCC's C++ compiler complain about
libs_qga=""
debug_info="yes"
stack_protector=""
+safe_stack=""
use_containers="yes"
gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
debug_tcg="no"
debug="no"
sanitizers="no"
+tsan="no"
fortify_source=""
strip_opt="yes"
tcg_interpreter="no"
default_devices="yes"
plugins="no"
fuzzing="no"
+rng_none="no"
+secret_keyring=""
+libdaxctl=""
supported_cpu="no"
supported_os="no"
;;
--disable-sanitizers) sanitizers="no"
;;
+ --enable-tsan) tsan="yes"
+ ;;
+ --disable-tsan) tsan="no"
+ ;;
--enable-sparse) sparse="yes"
;;
--disable-sparse) sparse="no"
;;
--disable-stack-protector) stack_protector="no"
;;
+ --enable-safe-stack) safe_stack="yes"
+ ;;
+ --disable-safe-stack) safe_stack="no"
+ ;;
--disable-curses) curses="no"
;;
--enable-curses) curses="yes"
;;
--enable-vhost-user) vhost_user="yes"
;;
+ --disable-vhost-vdpa) vhost_vdpa="no"
+ ;;
+ --enable-vhost-vdpa) vhost_vdpa="yes"
+ ;;
--disable-vhost-kernel) vhost_kernel="no"
;;
--enable-vhost-kernel) vhost_kernel="yes"
;;
--gdb=*) gdb_bin="$optarg"
;;
+ --enable-rng-none) rng_none=yes
+ ;;
+ --disable-rng-none) rng_none=no
+ ;;
+ --enable-keyring) secret_keyring="yes"
+ ;;
+ --disable-keyring) secret_keyring="no"
+ ;;
+ --enable-libdaxctl) libdaxctl=yes
+ ;;
+ --disable-libdaxctl) libdaxctl=no
+ ;;
*)
echo "ERROR: unknown option $opt"
echo "Try '$0 --help' for more information"
--with-pkgversion=VERS use specified string as sub-version of the package
--enable-debug enable common debug build options
--enable-sanitizers enable default sanitizers
+ --enable-tsan enable thread sanitizer
--disable-strip disable stripping binaries
--disable-werror disable compilation abort on warning
--disable-stack-protector disable compiler-provided stack protection
debug-tcg TCG debugging (default is disabled)
debug-info debugging information
sparse sparse checker
+ safe-stack SafeStack Stack Smash Protection. Depends on
+ clang/llvm >= 3.7 and requires coroutine backend ucontext.
gnutls GNUTLS cryptography support
nettle nettle cryptography support
vhost-crypto vhost-user-crypto backend support
vhost-kernel vhost kernel backend support
vhost-user vhost-user backend support
+ vhost-vdpa vhost-vdpa kernel backend support
spice spice
rbd rados block device (rbd)
libiscsi iscsi support
debug-mutex mutex debugging support
libpmem libpmem support
xkbcommon xkbcommon support
+ rng-none dummy RNG, avoid using /dev/(u)random and getrandom()
+ libdaxctl libdaxctl support
NOTE: The object files are built at the place where configure is launched
EOF
error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
fi
-gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
-gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
-gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
-gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
-gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
-gcc_flags="-Wno-string-plus-int -Wno-typedef-redefinition $gcc_flags"
-# Note that we do not add -Werror to gcc_flags here, because that would
-# enable it for all configure tests. If a configure test failed due
-# to -Werror this would just silently disable some features,
-# so it's too error prone.
+# Accumulate -Wfoo and -Wno-bar separately.
+# We will list all of the enable flags first, and the disable flags second.
+# Note that we do not add -Werror, because that would enable it for all
+# configure tests. If a configure test failed due to -Werror this would
+# just silently disable some features, so it's too error prone.
+
+warn_flags=
+add_to warn_flags -Wold-style-declaration
+add_to warn_flags -Wold-style-definition
+add_to warn_flags -Wtype-limits
+add_to warn_flags -Wformat-security
+add_to warn_flags -Wformat-y2k
+add_to warn_flags -Winit-self
+add_to warn_flags -Wignored-qualifiers
+add_to warn_flags -Wempty-body
+add_to warn_flags -Wnested-externs
+add_to warn_flags -Wendif-labels
+add_to warn_flags -Wexpansion-to-defined
+
+nowarn_flags=
+add_to nowarn_flags -Wno-initializer-overrides
+add_to nowarn_flags -Wno-missing-include-dirs
+add_to nowarn_flags -Wno-shift-negative-value
+add_to nowarn_flags -Wno-string-plus-int
+add_to nowarn_flags -Wno-typedef-redefinition
+add_to nowarn_flags -Wno-tautological-type-limit-compare
+add_to nowarn_flags -Wno-psabi
+
+gcc_flags="$warn_flags $nowarn_flags"
cc_has_warning_flag() {
write_c_skeleton;
if test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
error_exit "vhost-user isn't available on win32"
fi
+test "$vhost_vdpa" = "" && vhost_vdpa=$linux
+if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
+ error_exit "vhost-vdpa is only available on Linux"
+fi
test "$vhost_kernel" = "" && vhost_kernel=$linux
if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
error_exit "vhost-kernel is only available on Linux"
if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
fi
+#vhost-vdpa backends
+test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
+if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
+ error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
+fi
# OR the vhost-kernel and vhost-user values for simplicity
if test "$vhost_net" = ""; then
have_ifaddrs_h=no
fi
+#########################################
+# libdrm check
+have_drm_h=no
+if check_include "libdrm/drm.h" ; then
+ have_drm_h=yes
+fi
+
##########################################
# VTE probe
mkdir -p dtc
if [ "$pwd_is_source_path" != "y" ] ; then
symlink "$source_path/dtc/Makefile" "dtc/Makefile"
- symlink "$source_path/dtc/scripts" "dtc/scripts"
fi
fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
fdt_ldflags="-L\$(BUILD_DIR)/dtc/libfdt"
if test "$tcmalloc" = "yes" ; then
cat > $TMPC << EOF
#include <stdlib.h>
-int main(void) { malloc(1); return 0; }
+int main(void) {
+ void *tmp = malloc(1);
+ if (tmp != NULL) {
+ return 0;
+ }
+ return 1;
+}
EOF
if compile_prog "" "-ltcmalloc" ; then
if test "$jemalloc" = "yes" ; then
cat > $TMPC << EOF
#include <stdlib.h>
-int main(void) { malloc(1); return 0; }
+int main(void) {
+ void *tmp = malloc(1);
+ if (tmp != NULL) {
+ return 0;
+ }
+ return 1;
+}
EOF
if compile_prog "" "-ljemalloc" ; then
int main(void) { return openpty(0, 0, 0, 0, 0); }
EOF
-if ! compile_prog "" "" ; then
+have_openpty="no"
+if compile_prog "" "" ; then
+ have_openpty="yes"
+else
if compile_prog "" "-lutil" ; then
libs_softmmu="-lutil $libs_softmmu"
libs_tools="-lutil $libs_tools"
+ have_openpty="yes"
fi
fi
fi
fi
+##################################################
+# SafeStack
+
+
+if test "$safe_stack" = "yes"; then
+cat > $TMPC << EOF
+int main(int argc, char *argv[])
+{
+#if ! __has_feature(safe_stack)
+#error SafeStack Disabled
+#endif
+ return 0;
+}
+EOF
+ flag="-fsanitize=safe-stack"
+ # Check that safe-stack is supported and enabled.
+ if compile_prog "-Werror $flag" "$flag"; then
+ # Flag needed both at compilation and at linking
+ QEMU_CFLAGS="$QEMU_CFLAGS $flag"
+ QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
+ else
+ error_exit "SafeStack not supported by your compiler"
+ fi
+ if test "$coroutine" != "ucontext"; then
+ error_exit "SafeStack is only supported by the coroutine backend ucontext"
+ fi
+else
+cat > $TMPC << EOF
+int main(int argc, char *argv[])
+{
+#if defined(__has_feature)
+#if __has_feature(safe_stack)
+#error SafeStack Enabled
+#endif
+#endif
+ return 0;
+}
+EOF
+if test "$safe_stack" = "no"; then
+ # Make sure that safe-stack is disabled
+ if ! compile_prog "-Werror" ""; then
+ # SafeStack was already enabled, try to explicitly remove the feature
+ flag="-fno-sanitize=safe-stack"
+ if ! compile_prog "-Werror $flag" "$flag"; then
+ error_exit "Configure cannot disable SafeStack"
+ fi
+ QEMU_CFLAGS="$QEMU_CFLAGS $flag"
+ QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
+ fi
+else # "$safe_stack" = ""
+ # Set safe_stack to yes or no based on pre-existing flags
+ if compile_prog "-Werror" ""; then
+ safe_stack="no"
+ else
+ safe_stack="yes"
+ if test "$coroutine" != "ucontext"; then
+ error_exit "SafeStack is only supported by the coroutine backend ucontext"
+ fi
+ fi
+fi
+fi
##########################################
# check if we have open_by_handle_at
#include <stdlib.h>
int main(void) {
void *tmp = malloc(10);
- return *(int *)(tmp + 2);
+ if (tmp != NULL) {
+ return *(int *)(tmp + 2);
+ }
}
EOF
if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
fi
fi
+# Thread sanitizer is, for now, much noisier than the other sanitizers;
+# keep it separate until that is not the case.
+if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
+ error_exit "TSAN is not supported with other sanitiziers."
+fi
+have_tsan=no
+have_tsan_iface_fiber=no
+if test "$tsan" = "yes" ; then
+ write_c_skeleton
+ if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
+ have_tsan=yes
+ fi
+ cat > $TMPC << EOF
+#include <sanitizer/tsan_interface.h>
+int main(void) {
+ __tsan_create_fiber(0);
+ return 0;
+}
+EOF
+ if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
+ have_tsan_iface_fiber=yes
+ fi
+fi
+
##########################################
# check for libpmem
fi
fi
+##########################################
+# check for libdaxctl
+
+if test "$libdaxctl" != "no"; then
+ if $pkg_config --atleast-version=57 "libdaxctl"; then
+ libdaxctl="yes"
+ libdaxctl_libs=$($pkg_config --libs libdaxctl)
+ libdaxctl_cflags=$($pkg_config --cflags libdaxctl)
+ libs_softmmu="$libs_softmmu $libdaxctl_libs"
+ QEMU_CFLAGS="$QEMU_CFLAGS $libdaxctl_cflags"
+ else
+ if test "$libdaxctl" = "yes" ; then
+ feature_not_found "libdaxctl" "Install libdaxctl"
+ fi
+ libdaxctl="no"
+ fi
+fi
+
##########################################
# check for slirp
;;
esac
+##########################################
+# check for usable __NR_keyctl syscall
+
+if test "$linux" = "yes" ; then
+
+ have_keyring=no
+ cat > $TMPC << EOF
+#include <errno.h>
+#include <asm/unistd.h>
+#include <linux/keyctl.h>
+#include <unistd.h>
+int main(void) {
+ return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
+}
+EOF
+ if compile_prog "" "" ; then
+ have_keyring=yes
+ fi
+fi
+if test "$secret_keyring" != "no"
+then
+ if test "$have_keyring" == "yes"
+ then
+ secret_keyring=yes
+ else
+ if test "$secret_keyring" = "yes"
+ then
+ error_exit "syscall __NR_keyctl requested, \
+but not implemented on your system"
+ else
+ secret_keyring=no
+ fi
+ fi
+fi
+
+##########################################
+# check for usable keyutils.h
+
+if test "$linux" = "yes" ; then
+
+ have_keyutils=no
+ cat > $TMPC << EOF
+#include <errno.h>
+#include <asm/unistd.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <keyutils.h>
+int main(void) {
+ return request_key("user", NULL, NULL, 0);
+}
+EOF
+ if compile_prog "" "-lkeyutils"; then
+ have_keyutils=yes
+ fi
+fi
+
##########################################
# End of CC checks
"Without code annotation, the report may be inferior."
fi
fi
+if test "$have_tsan" = "yes" ; then
+ if test "$have_tsan_iface_fiber" = "yes" ; then
+ QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
+ QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
+ else
+ error_exit "Cannot enable TSAN due to missing fiber annotation interface."
+ fi
+elif test "$tsan" = "yes" ; then
+ error_exit "Cannot enable TSAN due to missing sanitize thread interface."
+fi
if test "$have_ubsan" = "yes"; then
QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
fi
-if test "$solaris" = "no" ; then
+# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
+if test "$solaris" = "no" && test "$tsan" = "no"; then
if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
fi
if test "$linux" = yes; then
if test "$virtfs" != no && test "$cap_ng" = yes && test "$attr" = yes ; then
virtfs=yes
- tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
+ helpers="$helpers fsdev/virtfs-proxy-helper\$(EXESUF)"
else
if test "$virtfs" = yes; then
error_exit "VirtFS requires libcap-ng devel and libattr devel"
fi
mpath=no
fi
- tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
+ helpers="$helpers scsi/qemu-pr-helper\$(EXESUF)"
else
if test "$virtfs" = yes; then
error_exit "VirtFS is supported only on Linux"
write_c_skeleton
if compile_prog "-march=z900" ""; then
roms="$roms s390-ccw"
+ # SLOF is required for building the s390-ccw firmware on s390x,
+ # since it is using the libnet code from SLOF for network booting.
+ if test -e "${source_path}/.git" ; then
+ git_submodules="${git_submodules} roms/SLOF"
+ fi
fi
fi
echo "strip binaries $strip_opt"
echo "profiler $profiler"
echo "static build $static"
+echo "safe stack $safe_stack"
if test "$darwin" = "yes" ; then
echo "Cocoa support $cocoa"
fi
echo "vhost-vsock support $vhost_vsock"
echo "vhost-user support $vhost_user"
echo "vhost-user-fs support $vhost_user_fs"
+echo "vhost-vdpa support $vhost_vdpa"
echo "Trace backends $trace_backends"
if have_backend "simple"; then
echo "Trace output file $trace_file-<pid>"
echo "sheepdog support $sheepdog"
echo "capstone $capstone"
echo "libpmem support $libpmem"
+echo "libdaxctl support $libdaxctl"
echo "libudev $libudev"
echo "default devices $default_devices"
echo "plugin support $plugins"
echo "fuzzing support $fuzzing"
echo "gdb $gdb_bin"
+echo "rng-none $rng_none"
+echo "Linux keyring $secret_keyring"
if test "$supported_cpu" = "no"; then
echo
if test "$have_ifaddrs_h" = "yes" ; then
echo "HAVE_IFADDRS_H=y" >> $config_host_mak
fi
+if test "$have_drm_h" = "yes" ; then
+ echo "HAVE_DRM_H=y" >> $config_host_mak
+fi
if test "$have_broken_size_max" = "yes" ; then
echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
fi
+if test "$have_openpty" = "yes" ; then
+ echo "HAVE_OPENPTY=y" >> $config_host_mak
+fi
# Work around a system header bug with some kernel/XFS header
# versions where they both try to define 'struct fsxattr':
if test "$vhost_net_user" = "yes" ; then
echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
fi
+if test "$vhost_net_vdpa" = "yes" ; then
+ echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
+fi
if test "$vhost_crypto" = "yes" ; then
echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
fi
if test "$vhost_user" = "yes" ; then
echo "CONFIG_VHOST_USER=y" >> $config_host_mak
fi
+if test "$vhost_vdpa" = "yes" ; then
+ echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
+fi
if test "$vhost_user_fs" = "yes" ; then
echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
fi
echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
fi
+if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
+ echo "CONFIG_TSAN=y" >> $config_host_mak
+fi
+
if test "$has_environ" = "yes" ; then
echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
fi
echo "CONFIG_LIBPMEM=y" >> $config_host_mak
fi
+if test "$libdaxctl" = "yes" ; then
+ echo "CONFIG_LIBDAXCTL=y" >> $config_host_mak
+fi
+
if test "$bochs" = "yes" ; then
echo "CONFIG_BOCHS=y" >> $config_host_mak
fi
echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
fi
+if test "$secret_keyring" = "yes" ; then
+ echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
+ if test "$have_keyutils" = "yes" ; then
+ echo "CONFIG_TEST_SECRET_KEYRING=y" >> $config_host_mak
+ fi
+fi
+
if test "$tcg_interpreter" = "yes"; then
QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
elif test "$ARCH" = "sparc64" ; then
QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
fi
+echo "HELPERS=$helpers" >> $config_host_mak
echo "TOOLS=$tools" >> $config_host_mak
echo "ROMS=$roms" >> $config_host_mak
echo "MAKE=$make" >> $config_host_mak
echo "DECOMPRESS_EDK2_BLOBS=y" >> $config_host_mak
fi
+if test "$rng_none" = "yes"; then
+ echo "CONFIG_RNG_NONE=y" >> $config_host_mak
+fi
+
# use included Linux headers
if test "$linux" = "yes" ; then
mkdir -p linux-headers
echo "export CCACHE_CPP2=y" >> $config_host_mak
fi
+if test "$safe_stack" = "yes"; then
+ echo "CONFIG_SAFESTACK=y" >> $config_host_mak
+fi
+
# If we're using a separate build tree, set it up now.
# DIRS are directories which we simply mkdir in the build tree;
# LINKS are things to symlink back into the source tree
DIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
DIRS="$DIRS docs docs/interop fsdev scsi"
DIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
-DIRS="$DIRS roms/seabios roms/vgabios"
+DIRS="$DIRS roms/seabios"
LINKS="Makefile"
LINKS="$LINKS tests/tcg/lm32/Makefile po/Makefile"
LINKS="$LINKS tests/tcg/Makefile.target tests/fp/Makefile"
LINKS="$LINKS tests/plugin/Makefile"
LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
LINKS="$LINKS pc-bios/s390-ccw/Makefile"
-LINKS="$LINKS roms/seabios/Makefile roms/vgabios/Makefile"
+LINKS="$LINKS roms/seabios/Makefile"
LINKS="$LINKS pc-bios/qemu-icon.bmp"
LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
LINKS="$LINKS tests/acceptance tests/data"
$source_path/tests/tcg/configure.sh)
# temporary config to build submodules
-for rom in seabios vgabios ; do
+for rom in seabios; do
config_mak=roms/$rom/config.mak
echo "# Automatically generated by configure - do not modify" > $config_mak
echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak