]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
meson: check in main meson.build for native Rust compiler
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 14 Oct 2024 14:36:40 +0000 (16:36 +0200)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 14 Oct 2024 14:48:05 +0000 (15:48 +0100)
A working native Rust compiler is always needed in order to compile Rust
code, even when cross compiling, in order to build the procedural macros
that QEMU uses.

Right now, the check is done in rust/qemu-api-macros/meson.build, but this
has two disadvantages.  First, it makes the build fail when the Meson "rust"
option is set to "auto" (instead, Rust support should be disabled).  Second,
add_languages() is one of the few functions that are executed even by
"meson introspect", except that "meson introspect" executes both branches
of "if" statements!  Therefore, "meson introspect" tries to look for a
Rust compiler even if the option is disabled---and then fails because
the compiler is required by rust/qemu-api-macros/meson.build.  This is
visible for example if the compilation host has a stale
scripts/meson-buildoptions.sh and no rustc installed.

Both issues can be fixed by moving the check to the main meson.build,
together with the check for the cross compiler.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
meson.build
rust/qemu-api-macros/meson.build

index aecc381932dcffe6b6415a9eaa95aed8fcc3a50f..c85f964bed4cd0cc1d0f51c34abeb6de4540e2e4 100644 (file)
@@ -71,7 +71,8 @@ if host_os == 'darwin' and \
   objc = meson.get_compiler('objc')
 endif
 have_rust = false
-if not get_option('rust').disabled() and add_languages('rust', required: get_option('rust'), native: false)
+if not get_option('rust').disabled() and add_languages('rust', required: get_option('rust'), native: false) \
+    and add_languages('rust', required: get_option('rust'), native: true)
   rustc = meson.get_compiler('rust')
   have_rust = true
   if rustc.version().version_compare('<1.80.0')
index 48af91ed389120ddd6e15f6ee002f5da7063e329..517b9a4d2d57822191d5a055f034b9c38a309952 100644 (file)
@@ -1,5 +1,3 @@
-add_languages('rust', required: true, native: true)
-
 quote_dep = dependency('quote-1-rs', native: true)
 syn_dep = dependency('syn-2-rs', native: true)
 proc_macro2_dep = dependency('proc-macro2-1-rs', native: true)