From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Michael Tokarev <mjt@tls.msk.ru>
Subject: [PATCH 03/17] meson, cutils: allow non-relocatable installs
Date: Mon, 16 Oct 2023 08:31:13 +0200 [thread overview]
Message-ID: <20231016063127.161204-4-pbonzini@redhat.com> (raw)
In-Reply-To: <20231016063127.161204-1-pbonzini@redhat.com>
Suggested-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
meson.build | 21 +++++++++++++++++++++
meson_options.txt | 2 ++
scripts/meson-buildoptions.sh | 3 +++
util/cutils.c | 11 ++++++++---
4 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/meson.build b/meson.build
index 010d2c649c2..251838f2609 100644
--- a/meson.build
+++ b/meson.build
@@ -2111,6 +2111,7 @@ config_host_data.set('CONFIG_OPENGL', opengl.found())
config_host_data.set('CONFIG_PLUGIN', get_option('plugins'))
config_host_data.set('CONFIG_RBD', rbd.found())
config_host_data.set('CONFIG_RDMA', rdma.found())
+config_host_data.set('CONFIG_RELOCATABLE', get_option('relocatable'))
config_host_data.set('CONFIG_SAFESTACK', get_option('safe_stack'))
config_host_data.set('CONFIG_SDL', sdl.found())
config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
@@ -4054,6 +4055,7 @@ if 'simple' in get_option('trace_backends')
endif
summary_info += {'D-Bus display': dbus_display}
summary_info += {'QOM debugging': get_option('qom_cast_debug')}
+summary_info += {'Relocatable install': get_option('relocatable')}
summary_info += {'vhost-kernel support': have_vhost_kernel}
summary_info += {'vhost-net support': have_vhost_net}
summary_info += {'vhost-user support': have_vhost_user}
@@ -4356,3 +4358,22 @@ if host_arch == 'unknown' or not supported_oses.contains(targetos)
message('If you want to help supporting QEMU on this platform, please')
message('contact the developers at qemu-devel@nongnu.org.')
endif
+
+actually_reloc = get_option('relocatable')
+# check if get_relocated_path() is actually able to relocate paths
+if get_option('relocatable') and \
+ not (get_option('prefix') / get_option('bindir')).startswith(get_option('prefix') / '')
+ message()
+ warning('bindir not included within prefix, the installation will not be relocatable.')
+ message()
+ message('Use --disable-relocatable to remove this warning.')
+ actually_reloc = false
+endif
+if not actually_reloc and (targetos == 'windows' or get_option('relocatable'))
+ if targetos == 'windows'
+ message()
+ warning('Windows installs should usually be relocatable.')
+ endif
+ message()
+ message('QEMU will have to be installed under ' + get_option('prefix') + '.')
+endif
diff --git a/meson_options.txt b/meson_options.txt
index 6a17b909680..e237b268469 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -101,6 +101,8 @@ option('cfi_debug', type: 'boolean', value: false,
description: 'Verbose errors in case of CFI violation')
option('multiprocess', type: 'feature', value: 'auto',
description: 'Out of process device emulation support')
+option('relocatable', type : 'boolean', value : 'true',
+ description: 'toggle relocatable install')
option('vfio_user_server', type: 'feature', value: 'disabled',
description: 'vfio-user server support')
option('dbus_display', type: 'feature', value: 'auto',
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 2a74b0275b3..d4b89e6b443 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -17,6 +17,7 @@ meson_options_help() {
printf "%s\n" ' code for the Hexagon frontend'
printf "%s\n" ' --disable-install-blobs install provided firmware blobs'
printf "%s\n" ' --disable-qom-cast-debug cast debugging support'
+ printf "%s\n" ' --disable-relocatable toggle relocatable install'
printf "%s\n" ' --docdir=VALUE Base directory for documentation installation'
printf "%s\n" ' (can be empty) [share/doc]'
printf "%s\n" ' --enable-block-drv-whitelist-in-tools'
@@ -421,6 +422,8 @@ _meson_option_parse() {
--disable-rbd) printf "%s" -Drbd=disabled ;;
--enable-rdma) printf "%s" -Drdma=enabled ;;
--disable-rdma) printf "%s" -Drdma=disabled ;;
+ --enable-relocatable) printf "%s" -Drelocatable=true ;;
+ --disable-relocatable) printf "%s" -Drelocatable=false ;;
--enable-replication) printf "%s" -Dreplication=enabled ;;
--disable-replication) printf "%s" -Dreplication=disabled ;;
--enable-rng-none) printf "%s" -Drng_none=true ;;
diff --git a/util/cutils.c b/util/cutils.c
index c99d26c5e2d..64f817b477b 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -1178,9 +1178,11 @@ char *get_relocated_path(const char *dir)
#else
g_string_append(result, dir);
#endif
- } else if (!starts_with_prefix(dir) || !starts_with_prefix(bindir)) {
- g_string_assign(result, dir);
- } else {
+ goto out;
+ }
+
+ if (IS_ENABLED(CONFIG_RELOCATABLE) &&
+ starts_with_prefix(dir) && starts_with_prefix(bindir)) {
g_string_assign(result, exec_dir);
/* Advance over common components. */
@@ -1203,7 +1205,10 @@ char *get_relocated_path(const char *dir)
assert(G_IS_DIR_SEPARATOR(dir[-1]));
g_string_append(result, dir - 1);
}
+ goto out;
}
+ g_string_assign(result, dir);
+out:
return g_string_free(result, false);
}
--
2.41.0
next prev parent reply other threads:[~2023-10-16 6:33 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 6:31 [PATCH 00/17] More build system cleanups, optional non-relocatable installs Paolo Bonzini
2023-10-16 6:31 ` [PATCH 01/17] meson: do not build shaders by default Paolo Bonzini
2023-10-16 9:04 ` Manos Pitsidianakis
2023-10-16 6:31 ` [PATCH 02/17] meson: do not use set10 Paolo Bonzini
2023-10-19 0:06 ` Richard Henderson
2023-10-16 6:31 ` Paolo Bonzini [this message]
2023-10-16 7:12 ` [PATCH 03/17] meson, cutils: allow non-relocatable installs Markus Armbruster
2023-10-16 21:29 ` Paolo Bonzini
2023-10-17 5:46 ` Markus Armbruster
2023-10-16 9:08 ` Manos Pitsidianakis
2023-10-16 9:48 ` Paolo Bonzini
2023-10-16 6:31 ` [PATCH 04/17] configure: clean up handling of CFI option Paolo Bonzini
2023-10-16 9:22 ` Philippe Mathieu-Daudé
2023-10-16 9:44 ` Paolo Bonzini
2023-10-16 13:33 ` Philippe Mathieu-Daudé
2023-10-16 6:31 ` [PATCH 05/17] hw/xen: cleanup sourcesets Paolo Bonzini
2023-10-16 6:31 ` [PATCH 06/17] hw/remote: move stub vfu_object_set_bus_irq out of stubs/ Paolo Bonzini
2023-10-16 6:31 ` [PATCH 07/17] tests/tcg/arm: move non-SVE tests out of conditional Paolo Bonzini
2023-10-16 6:31 ` [PATCH 08/17] configure, tests/tcg: simplify GDB conditionals Paolo Bonzini
2023-10-16 9:12 ` Manos Pitsidianakis
2023-10-16 6:31 ` [PATCH 09/17] configure: clean up plugin option handling Paolo Bonzini
2023-10-16 6:31 ` [PATCH 10/17] configure: clean up PIE " Paolo Bonzini
2023-10-16 6:31 ` [PATCH 11/17] configure: remove some dead cruft Paolo Bonzini
2023-10-16 9:32 ` Thomas Huth
2023-10-16 6:31 ` [PATCH 12/17] configure: move target-specific defaults to an external machine file Paolo Bonzini
2023-10-16 6:31 ` [PATCH 13/17] configure: move environment-specific defaults to config-meson.cross Paolo Bonzini
2023-10-16 6:31 ` [PATCH 14/17] configure: unify handling of several Debian cross containers Paolo Bonzini
2023-10-16 6:31 ` [PATCH 15/17] configure, meson: use command line options to configure qemu-ga Paolo Bonzini
2023-10-16 6:31 ` [PATCH 16/17] meson-buildoptions: document the data at the top Paolo Bonzini
2023-10-16 6:31 ` [PATCH 17/17] meson: add a note on why we use config_host for program paths 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=20231016063127.161204-4-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=mjt@tls.msk.ru \
--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).