From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PATCH 13/24] build: move coroutine backend selection to meson
Date: Thu, 11 May 2023 11:50:10 +0200 [thread overview]
Message-ID: <20230511095021.1397802-14-pbonzini@redhat.com> (raw)
In-Reply-To: <20230511095021.1397802-1-pbonzini@redhat.com>
To simplify the code, rename coroutine-win32.c to match the option
passed to configure.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
configure | 62 -------------------
meson.build | 32 +++++++++-
meson_options.txt | 3 +
scripts/meson-buildoptions.py | 1 +
scripts/meson-buildoptions.sh | 3 +
...{coroutine-win32.c => coroutine-windows.c} | 0
util/meson.build | 2 +-
7 files changed, 38 insertions(+), 65 deletions(-)
rename util/{coroutine-win32.c => coroutine-windows.c} (100%)
diff --git a/configure b/configure
index 3989d2660e47..c264bf4cadee 100755
--- a/configure
+++ b/configure
@@ -282,7 +282,6 @@ softmmu="yes"
linux_user=""
bsd_user=""
pie=""
-coroutine=""
plugins="$default_feature"
meson=""
ninja=""
@@ -843,8 +842,6 @@ for opt do
;;
--enable-fdt=*) fdt="$optarg"
;;
- --with-coroutine=*) coroutine="$optarg"
- ;;
--with-git=*) git="$optarg"
;;
--with-git-submodules=*)
@@ -1003,8 +1000,6 @@ Advanced options (experts only):
--disable-werror disable compilation abort on warning
--disable-stack-protector disable compiler-provided stack protection
--cpu=CPU Build for host CPU [$cpu]
- --with-coroutine=BACKEND coroutine backend. Supported options:
- ucontext, sigaltstack, windows
--enable-plugins
enable plugins via shared library loading
--disable-containers don't use containers for cross-building
@@ -1459,61 +1454,6 @@ case "$fdt" in
;;
esac
-##########################################
-# check and set a backend for coroutine
-
-# We prefer ucontext, but it's not always possible. The fallback
-# is sigcontext. On Windows the only valid backend is the Windows
-# specific one.
-
-ucontext_works=no
-if test "$darwin" != "yes"; then
- cat > $TMPC << EOF
-#include <ucontext.h>
-#ifdef __stub_makecontext
-#error Ignoring glibc stub makecontext which will always fail
-#endif
-int main(void) { makecontext(0, 0, 0); return 0; }
-EOF
- if compile_prog "" "" ; then
- ucontext_works=yes
- fi
-fi
-
-if test "$coroutine" = ""; then
- if test "$mingw32" = "yes"; then
- coroutine=win32
- elif test "$ucontext_works" = "yes"; then
- coroutine=ucontext
- else
- coroutine=sigaltstack
- fi
-else
- case $coroutine in
- windows)
- if test "$mingw32" != "yes"; then
- error_exit "'windows' coroutine backend only valid for Windows"
- fi
- # Unfortunately the user visible backend name doesn't match the
- # coroutine-*.c filename for this case, so we have to adjust it here.
- coroutine=win32
- ;;
- ucontext)
- if test "$ucontext_works" != "yes"; then
- error_exit "'ucontext' backend requested but makecontext not available"
- fi
- ;;
- sigaltstack)
- if test "$mingw32" = "yes"; then
- error_exit "only the 'windows' coroutine backend is valid for Windows"
- fi
- ;;
- *)
- error_exit "unknown coroutine backend $coroutine"
- ;;
- esac
-fi
-
########################################
# check if ccache is interfering with
# semantic analysis of macros
@@ -2089,8 +2029,6 @@ if [ "$bsd" = "yes" ] ; then
echo "CONFIG_BSD=y" >> $config_host_mak
fi
-echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
-
if test "$plugins" = "yes" ; then
echo "CONFIG_PLUGIN=y" >> $config_host_mak
fi
diff --git a/meson.build b/meson.build
index 31151f240ad8..2d34ff8a61ec 100644
--- a/meson.build
+++ b/meson.build
@@ -211,6 +211,34 @@ if get_option('prefer_static')
qemu_ldflags += get_option('b_pie') ? '-static-pie' : '-static'
endif
+coroutine_backend = get_option('coroutine_backend')
+ucontext_probe = '''
+ #include <ucontext.h>
+ #ifdef __stub_makecontext
+ #error Ignoring glibc stub makecontext which will always fail
+ #endif
+ int main(void) { makecontext(0, 0, 0); return 0; }'''
+
+# On Windows the only valid backend is the Windows specific one.
+# For POSIX prefer ucontext, but it's not always possible. The fallback
+# is sigcontext.
+supported_backends = []
+if targetos == 'windows'
+ supported_backends += ['windows']
+else
+ if targetos != 'darwin' and cc.links(ucontext_probe)
+ supported_backends += ['ucontext']
+ endif
+ supported_backends += ['sigaltstack']
+endif
+
+if coroutine_backend == 'auto'
+ coroutine_backend = supported_backends[0]
+elif coroutine_backend not in supported_backends
+ error('"@0@" backend requested but not available. Available backends: @1@' \
+ .format(coroutine_backend, ', '.join(supported_backends)))
+endif
+
# Compiles if SafeStack *not* enabled
safe_stack_probe = '''
int main(void)
@@ -232,7 +260,7 @@ if get_option('safe_stack') != not cc.compiles(safe_stack_probe)
qemu_cflags += safe_stack_arg
qemu_ldflags += safe_stack_arg
endif
-if get_option('safe_stack') and config_host['CONFIG_COROUTINE_BACKEND'] != 'ucontext'
+if get_option('safe_stack') and coroutine_backend != 'ucontext'
error('SafeStack is only supported with the ucontext coroutine backend')
endif
@@ -4012,7 +4040,7 @@ summary(summary_info, bool_yn: true, section: 'Targets and accelerators')
# Block layer
summary_info = {}
-summary_info += {'coroutine backend': config_host['CONFIG_COROUTINE_BACKEND']}
+summary_info += {'coroutine backend': coroutine_backend}
summary_info += {'coroutine pool': have_coroutine_pool}
if have_block
summary_info += {'Block whitelist (rw)': get_option('block_drv_rw_whitelist')}
diff --git a/meson_options.txt b/meson_options.txt
index f04b12ca0783..9ddd500f8998 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -31,6 +31,9 @@ option('fuzzing_engine', type : 'string', value : '',
description: 'fuzzing engine library for OSS-Fuzz')
option('trace_file', type: 'string', value: 'trace',
description: 'Trace file prefix for simple backend')
+option('coroutine_backend', type: 'combo',
+ choices: ['ucontext', 'sigaltstack', 'windows', 'auto'],
+ value: 'auto', description: 'coroutine backend to use')
# Everything else can be set via --enable/--disable-* option
# on the configure script command line. After adding an option
diff --git a/scripts/meson-buildoptions.py b/scripts/meson-buildoptions.py
index a04dcc70a5b7..4c7f13fdfc40 100755
--- a/scripts/meson-buildoptions.py
+++ b/scripts/meson-buildoptions.py
@@ -35,6 +35,7 @@
OPTION_NAMES = {
"b_coverage": "gcov",
"b_lto": "lto",
+ "coroutine_backend": "with-coroutine",
"malloc": "enable-malloc",
"pkgversion": "with-pkgversion",
"qemu_firmwarepath": "firmwarepath",
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 5ea787deb89e..1d14390d972c 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -62,6 +62,8 @@ meson_options_help() {
printf "%s\n" ' --sysconfdir=VALUE Sysconf data directory [etc]'
printf "%s\n" ' --tls-priority=VALUE Default TLS protocol/cipher priority string'
printf "%s\n" ' [NORMAL]'
+ printf "%s\n" ' --with-coroutine=CHOICE coroutine backend to use (choices:'
+ printf "%s\n" ' auto/sigaltstack/ucontext/windows)'
printf "%s\n" ' --with-pkgversion=VALUE use specified string as sub-version of the'
printf "%s\n" ' package'
printf "%s\n" ' --with-trace-file=VALUE Trace file prefix for simple backend [trace]'
@@ -243,6 +245,7 @@ _meson_option_parse() {
--disable-cocoa) printf "%s" -Dcocoa=disabled ;;
--enable-coreaudio) printf "%s" -Dcoreaudio=enabled ;;
--disable-coreaudio) printf "%s" -Dcoreaudio=disabled ;;
+ --with-coroutine=*) quote_sh "-Dcoroutine_backend=$2" ;;
--enable-coroutine-pool) printf "%s" -Dcoroutine_pool=true ;;
--disable-coroutine-pool) printf "%s" -Dcoroutine_pool=false ;;
--enable-crypto-afalg) printf "%s" -Dcrypto_afalg=enabled ;;
diff --git a/util/coroutine-win32.c b/util/coroutine-windows.c
similarity index 100%
rename from util/coroutine-win32.c
rename to util/coroutine-windows.c
diff --git a/util/meson.build b/util/meson.build
index 2cb103fc727e..e1f1c39e1081 100644
--- a/util/meson.build
+++ b/util/meson.build
@@ -78,7 +78,7 @@ if have_block or have_ga
util_ss.add(files('base64.c'))
util_ss.add(files('main-loop.c'))
util_ss.add(files('qemu-coroutine.c', 'qemu-coroutine-lock.c', 'qemu-coroutine-io.c'))
- util_ss.add(files('coroutine-@0@.c'.format(config_host['CONFIG_COROUTINE_BACKEND'])))
+ util_ss.add(files(f'coroutine-@coroutine_backend@.c'))
util_ss.add(files('thread-pool.c', 'qemu-timer.c'))
util_ss.add(files('qemu-sockets.c'))
endif
--
2.40.1
next prev parent reply other threads:[~2023-05-11 9:52 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-11 9:49 [PATCH 00/24] Meson changes for QEMU 8.1 Paolo Bonzini
2023-05-11 9:49 ` [PATCH 01/24] meson: regenerate meson-buildoptions.sh Paolo Bonzini
2023-05-11 9:49 ` [PATCH 02/24] meson: require 0.63.0 Paolo Bonzini
2023-05-11 9:50 ` [PATCH 03/24] meson: use prefer_static option Paolo Bonzini
2023-05-11 9:50 ` [PATCH 04/24] meson: remove static_kwargs Paolo Bonzini
2023-05-11 9:50 ` [PATCH 05/24] meson: add more version numbers to the summary Paolo Bonzini
2023-05-11 9:50 ` [PATCH 06/24] meson: drop unnecessary declare_dependency() Paolo Bonzini
2023-05-11 9:50 ` [PATCH 07/24] build: move glib detection and workarounds to meson Paolo Bonzini
2023-05-11 9:50 ` [PATCH 08/24] configure: remove pkg-config functions Paolo Bonzini
2023-05-11 9:50 ` [PATCH 09/24] configure, meson: move --enable-modules to Meson Paolo Bonzini
2023-05-11 9:50 ` [PATCH 10/24] meson: prepare move of QEMU_CFLAGS to meson Paolo Bonzini
2023-05-11 9:50 ` [PATCH 11/24] build: move sanitizer tests " Paolo Bonzini
2023-05-11 9:50 ` [PATCH 12/24] build: move SafeStack " Paolo Bonzini
2023-05-11 9:50 ` Paolo Bonzini [this message]
2023-05-11 9:50 ` [PATCH 14/24] build: move stack protector flag selection " Paolo Bonzini
2023-05-11 9:50 ` [PATCH 15/24] build: move warning " Paolo Bonzini
2023-05-11 9:50 ` [PATCH 16/24] build: move remaining compiler flag tests " Paolo Bonzini
2023-05-11 9:50 ` [PATCH 17/24] build: move compiler version check " Paolo Bonzini
2023-05-11 9:50 ` [PATCH 18/24] build: move --disable-debug-info " Paolo Bonzini
2023-07-26 6:45 ` Michael Tokarev
2023-05-11 9:50 ` [PATCH 19/24] configure: remove compiler sanity check Paolo Bonzini
2024-01-18 19:23 ` Thomas Huth
2023-05-11 9:50 ` [PATCH 20/24] configure: do not rerun the tests with -Werror Paolo Bonzini
2023-05-11 9:50 ` [PATCH 21/24] configure: remove unnecessary mkdir Paolo Bonzini
2023-05-11 9:50 ` [PATCH 22/24] configure: reorder option parsing code Paolo Bonzini
2023-05-11 9:50 ` [PATCH 23/24] configure: remove unnecessary check Paolo Bonzini
2023-05-11 9:50 ` [PATCH 24/24] docs/devel: update build system docs Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230511095021.1397802-14-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).