meson: pass more options directly as -D

If an option is not used anywhere by the configure script, it can be just
added to $meson_options even if it is not parsed by the automatically
generated bits in scripts/meson-buildoptions.sh.

The only slightly tricky case is $debug, where the

  if test "$fortify_source" = "yes" ; then
    QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
    debug=no
  fi

assignment is dead; configure sets fortify_source=no whenever debug=yes.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2022-04-20 17:33:58 +02:00
parent c09c1ce7e9
commit c54b59ee0d
4 changed files with 22 additions and 29 deletions

39
configure vendored
View File

@ -235,7 +235,6 @@ static="no"
cross_compile="no"
cross_prefix=""
host_cc="cc"
lto="false"
stack_protector=""
safe_stack=""
use_containers="yes"
@ -291,13 +290,10 @@ vhost_vsock="$default_feature"
vhost_user="no"
vhost_user_fs="$default_feature"
vhost_vdpa="$default_feature"
debug_info="yes"
debug_tcg="no"
debug="no"
sanitizers="no"
tsan="no"
fortify_source="yes"
gcov="no"
EXESUF=""
modules="no"
prefix="/usr/local"
@ -327,10 +323,7 @@ else
fi
fdt="auto"
# 2. Support --with/--without option
default_devices="true"
# 3. Automatically enable/disable other options
# 2. Automatically enable/disable other options
tcg="enabled"
cfi="false"
@ -680,6 +673,9 @@ werror=""
. $source_path/scripts/meson-buildoptions.sh
meson_options=
meson_option_add() {
meson_options="$meson_options $(quote_sh "$1")"
}
meson_option_parse() {
meson_options="$meson_options $(_meson_option_parse "$@")"
if test $? -eq 1; then
@ -732,9 +728,9 @@ for opt do
;;
--cross-cc-*)
;;
--enable-debug-info) debug_info="yes"
--enable-debug-info) meson_option_add -Ddebug=true
;;
--disable-debug-info) debug_info="no"
--disable-debug-info) meson_option_add -Ddebug=false
;;
--enable-modules)
modules="yes"
@ -754,9 +750,9 @@ for opt do
error_exit "Can't mix --target-list-exclude with --target-list"
fi
;;
--with-default-devices) default_devices="true"
--with-default-devices) meson_option_add -Ddefault_devices=true
;;
--without-default-devices) default_devices="false"
--without-default-devices) meson_option_add -Ddefault_devices=false
;;
--with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
;;
@ -772,8 +768,6 @@ for opt do
;;
--without-default-features) # processed above
;;
--enable-gcov) gcov="yes"
;;
--static)
static="yes"
QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
@ -800,7 +794,7 @@ for opt do
# Enable debugging options that aren't excessively noisy
debug_tcg="yes"
meson_option_parse --enable-debug-mutex ""
debug="yes"
meson_option_add -Doptimization=0
fortify_source="no"
;;
--enable-sanitizers) sanitizers="yes"
@ -849,10 +843,6 @@ for opt do
;;
--disable-werror) werror="no"
;;
--enable-lto) lto="true"
;;
--disable-lto) lto="false"
;;
--enable-stack-protector) stack_protector="yes"
;;
--disable-stack-protector) stack_protector="no"
@ -863,7 +853,7 @@ for opt do
;;
--enable-cfi)
cfi="true";
lto="true";
meson_option_add -Db_lto=true
;;
--disable-cfi) cfi="false"
;;
@ -1101,7 +1091,6 @@ Advanced options (experts only):
--cpu=CPU Build for host CPU [$cpu]
--with-coroutine=BACKEND coroutine backend. Supported options:
ucontext, sigaltstack, windows
--enable-gcov enable test coverage analysis with gcov
--enable-plugins
enable plugins via shared library loading
--disable-containers don't use containers for cross-building
@ -1117,7 +1106,6 @@ cat << EOF
modules modules support (non-Windows)
debug-tcg TCG debugging (default is disabled)
debug-info debugging information
lto Enable Link-Time Optimization.
safe-stack SafeStack Stack Smash Protection. Depends on
clang/llvm >= 3.7 and requires coroutine backend ucontext.
vhost-net vhost-net kernel acceleration support
@ -1938,7 +1926,6 @@ write_c_skeleton
if test "$fortify_source" = "yes" ; then
QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
debug=no
fi
case "$ARCH" in
@ -2367,15 +2354,11 @@ if test "$skip_meson" = no; then
NINJA=$ninja $meson setup \
--prefix "$prefix" \
--bindir "$bindir" \
-Ddefault_devices=$default_devices \
-Dqemu_suffix="$qemu_suffix" \
-Dsmbd="$smbd" \
-Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
-Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
-Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
-Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
-Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
-Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg \
-Dcfi=$cfi -Dtcg=$tcg \
-Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
$(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
$(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \

View File

@ -1,6 +1,6 @@
project('qemu', ['c'], meson_version: '>=0.59.3',
default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 'b_colorout=auto',
'b_staticpic=false', 'stdsplit=false'],
'b_staticpic=false', 'stdsplit=false', 'optimization=2'],
version: files('VERSION'))
add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true)

View File

@ -33,6 +33,8 @@ SKIP_OPTIONS = {
}
OPTION_NAMES = {
"b_coverage": "gcov",
"b_lto": "lto",
"malloc": "enable-malloc",
"pkgversion": "with-pkgversion",
"qemu_firmwarepath": "firmwarepath",
@ -41,6 +43,8 @@ OPTION_NAMES = {
}
BUILTIN_OPTIONS = {
"b_coverage",
"b_lto",
"datadir",
"includedir",
"libdir",

View File

@ -27,7 +27,9 @@ meson_options_help() {
printf "%s\n" ' --enable-fdt[=CHOICE] Whether and how to find the libfdt library'
printf "%s\n" ' (choices: auto/disabled/enabled/internal/system)'
printf "%s\n" ' --enable-fuzzing build fuzzing targets'
printf "%s\n" ' --enable-gcov Enable coverage tracking.'
printf "%s\n" ' --enable-gprof QEMU profiling with gprof'
printf "%s\n" ' --enable-lto Use link time optimization'
printf "%s\n" ' --enable-malloc=CHOICE choose memory allocator to use [system] (choices:'
printf "%s\n" ' jemalloc/system/tcmalloc)'
printf "%s\n" ' --enable-module-upgrades try to load modules from alternate paths for'
@ -182,6 +184,10 @@ _meson_option_parse() {
--disable-avx2) printf "%s" -Davx2=disabled ;;
--enable-avx512f) printf "%s" -Davx512f=enabled ;;
--disable-avx512f) printf "%s" -Davx512f=disabled ;;
--enable-gcov) printf "%s" -Db_coverage=true ;;
--disable-gcov) printf "%s" -Db_coverage=false ;;
--enable-lto) printf "%s" -Db_lto=true ;;
--disable-lto) printf "%s" -Db_lto=false ;;
--block-drv-ro-whitelist=*) quote_sh "-Dblock_drv_ro_whitelist=$2" ;;
--block-drv-rw-whitelist=*) quote_sh "-Dblock_drv_rw_whitelist=$2" ;;
--enable-block-drv-whitelist-in-tools) printf "%s" -Dblock_drv_whitelist_in_tools=true ;;