[PATCH 05/24] configure: set the bindgen cross target

marcandre.lureau@redhat.com posted 24 patches 1 week, 2 days ago
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Thomas Huth <thuth@redhat.com>, Yonggang Luo <luoyonggang@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Kohei Tokunaga <ktokunaga.mail@gmail.com>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, Ed Maste <emaste@freebsd.org>, Li-Wen Hsu <lwhsu@freebsd.org>
There is a newer version of this series
[PATCH 05/24] configure: set the bindgen cross target
Posted by marcandre.lureau@redhat.com 1 week, 2 days ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 configure | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/configure b/configure
index 66613f3f4c..32eb313941 100755
--- a/configure
+++ b/configure
@@ -1878,6 +1878,12 @@ if test "$skip_meson" = no; then
       eval "c=\$devices_${a}"
       echo "${a}-softmmu = '$c'" >> $cross
   done
+  if test "$rust" != disabled; then
+      if test "$cross_compile" = "yes"; then
+          # it's actually a clang target triple, but they should be same
+          echo "bindgen_clang_arguments = [$(meson_quote --target="$rust_target_triple")]" >> $cross
+      fi
+  fi
 
   echo "[built-in options]" >> $cross
   echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
-- 
2.51.0


Re: [PATCH 05/24] configure: set the bindgen cross target
Posted by Paolo Bonzini 1 week, 2 days ago
On 9/19/25 15:32, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   configure | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/configure b/configure
> index 66613f3f4c..32eb313941 100755
> --- a/configure
> +++ b/configure
> @@ -1878,6 +1878,12 @@ if test "$skip_meson" = no; then
>         eval "c=\$devices_${a}"
>         echo "${a}-softmmu = '$c'" >> $cross
>     done
> +  if test "$rust" != disabled; then
> +      if test "$cross_compile" = "yes"; then
> +          # it's actually a clang target triple, but they should be same
> +          echo "bindgen_clang_arguments = [$(meson_quote --target="$rust_target_triple")]" >> $cross
> +      fi
> +  fi

Not exactly, see https://github.com/rust-lang/rust-bindgen/blob/main/bindgen/lib.rs#L683.

It should not be hard to rewrite in shell starting from

   clang_arch=$rust_arch
   clang_machine=$rust_machine
   clang_os=$rust_os
   clang_osvariant=$rust_osvariant
   ...
   if test "$android" = yes; then
     # e.g. aarch64-linux-android
     rust_target_triple=$rust_arch-$rust_os-$rust_osvariant
     clang_target_triple=$clang_arch-$clang_os-$clang_osvariant
   else
     rust_target_triple=$rust_arch-$rust_machine-$rust_os${rust_osvariant:+-$rust_osvariant}
     clang_target_triple=$clang_arch-$clang_machine-$clang_os${clang_osvariant:+-$clang_osvariant}
   fi

Paolo