[PATCH v2] rust: fix build when --disable-rust and meson < 1.9

Paolo Bonzini posted 1 patch 2 weeks, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260314075500.215628-1-pbonzini@redhat.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>
meson.build | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
[PATCH v2] rust: fix build when --disable-rust and meson < 1.9
Posted by Paolo Bonzini 2 weeks, 4 days ago
Commit e65030ed50ee moved rust_std and build.rust_std from per-target
override_options into the project's default_options, in order to avoid
repetition.  However, default_options are validated unconditionally at
project initialization, even when Rust is disabled.  This breaks builds
with meson < 1.9.0 which does not know about "build.rust_std":

  meson.build:1:0: ERROR: Unknown option: "build.rust_std".

Make the options conditional on the meson version, since Rust only
supports new versions of Meson anyway.

Fixes: e65030ed50ee ("rust: remove unnecessary repetitive options")
Reported-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 meson.build | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index 11139f540b0..00f482d3fa6 100644
--- a/meson.build
+++ b/meson.build
@@ -1,7 +1,11 @@
 project('qemu', ['c'], meson_version: '>=1.5.0',
         default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++23', 'b_colorout=auto',
-                          'b_staticpic=false', 'stdsplit=false', 'optimization=2', 'b_pie=true',
-                          'rust_std=2021', 'build.rust_std=2021'],
+                          'b_staticpic=false', 'stdsplit=false', 'optimization=2', 'b_pie=true'] +
+
+                          # build.rust_std breaks with older meson, but Rust does not
+                          # support old meson anyway
+                          (meson.version().version_compare('>= 1.9') ? ['rust_std=2021', 'build.rust_std=2021'] : ''),
+
         version: files('VERSION'))
 
 add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true,
-- 
2.53.0


Re: [PATCH v2] rust: fix build when --disable-rust and meson < 1.9
Posted by Marc-André Lureau 2 weeks, 2 days ago
Hi

On Sat, Mar 14, 2026 at 11:55 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> Commit e65030ed50ee moved rust_std and build.rust_std from per-target
> override_options into the project's default_options, in order to avoid
> repetition.  However, default_options are validated unconditionally at
> project initialization, even when Rust is disabled.  This breaks builds
> with meson < 1.9.0 which does not know about "build.rust_std":
>
>   meson.build:1:0: ERROR: Unknown option: "build.rust_std".
>
> Make the options conditional on the meson version, since Rust only
> supports new versions of Meson anyway.
>
> Fixes: e65030ed50ee ("rust: remove unnecessary repetitive options")
> Reported-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  meson.build | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index 11139f540b0..00f482d3fa6 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1,7 +1,11 @@
>  project('qemu', ['c'], meson_version: '>=1.5.0',
>          default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++23', 'b_colorout=auto',
> -                          'b_staticpic=false', 'stdsplit=false', 'optimization=2', 'b_pie=true',
> -                          'rust_std=2021', 'build.rust_std=2021'],
> +                          'b_staticpic=false', 'stdsplit=false', 'optimization=2', 'b_pie=true'] +
> +
> +                          # build.rust_std breaks with older meson, but Rust does not
> +                          # support old meson anyway
> +                          (meson.version().version_compare('>= 1.9') ? ['rust_std=2021', 'build.rust_std=2021'] : ''),

Fix the falsy expression to be [], then

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

thanks

> +
>          version: files('VERSION'))
>
>  add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true,
> --
> 2.53.0
>