diff mbox series

rust: add --rust-target option for bindgen

Message ID 20250206111514.2134895-1-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show
Series rust: add --rust-target option for bindgen | expand

Commit Message

Paolo Bonzini Feb. 6, 2025, 11:15 a.m. UTC
Without it, recent bindgen will give an error

   error: extern block cannot be declared unsafe

if rustc is not new enough to support the "unsafe extern" construct.

Cc: qemu-rust@nongnu.org
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 meson.build | 3 +++
 1 file changed, 3 insertions(+)

Comments

Philippe Mathieu-Daudé Feb. 6, 2025, 11:37 a.m. UTC | #1
On 6/2/25 12:15, Paolo Bonzini wrote:
> Without it, recent bindgen will give an error
> 
>     error: extern block cannot be declared unsafe
> 
> if rustc is not new enough to support the "unsafe extern" construct.
> 
> Cc: qemu-rust@nongnu.org
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   meson.build | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/meson.build b/meson.build
> index 2c9ac9cfe1e..131b2225ab6 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -4054,6 +4054,9 @@ if have_rust
>         bindgen_args += ['--formatter', 'none']
>       endif
>     endif
> +  if bindgen.version().version_compare('>=0.66.0')
> +    bindgen_args += ['--rust-target', '1.59']
> +  endif
>     if bindgen.version().version_compare('<0.61.0')
>       # default in 0.61+
>       bindgen_args += ['--size_t-is-usize']

Should this be merged directly on master as build-fix?
Paolo Bonzini Feb. 6, 2025, 11:38 a.m. UTC | #2
On Thu, Feb 6, 2025 at 12:37 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
> >     if bindgen.version().version_compare('<0.61.0')
> >       # default in 0.61+
> >       bindgen_args += ['--size_t-is-usize']
>
> Should this be merged directly on master as build-fix?

If it's breaking CI I can send a pull request later. I wasn't sure if
it was just my branch with other Rust changes.

Paolo
Philippe Mathieu-Daudé Feb. 6, 2025, 11:43 a.m. UTC | #3
On 6/2/25 12:38, Paolo Bonzini wrote:
> On Thu, Feb 6, 2025 at 12:37 PM Philippe Mathieu-Daudé
> <philmd@linaro.org> wrote:
>>>      if bindgen.version().version_compare('<0.61.0')
>>>        # default in 0.61+
>>>        bindgen_args += ['--size_t-is-usize']
>>
>> Should this be merged directly on master as build-fix?
> 
> If it's breaking CI I can send a pull request later. I wasn't sure if
> it was just my branch with other Rust changes.

No, this is now affecting the main repository, so also all forks.
Stefan Hajnoczi Feb. 8, 2025, 2:03 p.m. UTC | #4
I merged this directly into qemu.git/master.

Stefan
diff mbox series

Patch

diff --git a/meson.build b/meson.build
index 2c9ac9cfe1e..131b2225ab6 100644
--- a/meson.build
+++ b/meson.build
@@ -4054,6 +4054,9 @@  if have_rust
       bindgen_args += ['--formatter', 'none']
     endif
   endif
+  if bindgen.version().version_compare('>=0.66.0')
+    bindgen_args += ['--rust-target', '1.59']
+  endif
   if bindgen.version().version_compare('<0.61.0')
     # default in 0.61+
     bindgen_args += ['--size_t-is-usize']