[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH RESEND v9 3/9] configure, meson: detect Rust toolchain
|
From: |
Daniel P . Berrangé |
|
Subject: |
Re: [PATCH RESEND v9 3/9] configure, meson: detect Rust toolchain |
|
Date: |
Wed, 28 Aug 2024 13:28:29 +0100 |
|
User-agent: |
Mutt/2.2.12 (2023-09-09) |
On Wed, Aug 28, 2024 at 07:11:44AM +0300, Manos Pitsidianakis wrote:
> From: Paolo Bonzini <pbonzini@redhat.com>
>
> Include the correct path and arguments to rustc in the native
> and cross files (native compilation is needed for procedural
> macros).
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> configure | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
> meson.build | 8 +++-----
> 2 files changed, 51 insertions(+), 7 deletions(-)
>
> diff --git a/configure b/configure
> index
> 019fcbd0ef7b07e7b0280b358099cae72c73aa98..9ef6005c557fc627c7c6c732b4c92ed1b934f474
> 100755
> --- a/configure
> +++ b/configure
> @@ -207,6 +207,8 @@ for opt do
> ;;
> --objcc=*) objcc="$optarg"
> ;;
> + --rustc=*) RUSTC="$optarg"
> + ;;
> --cpu=*) cpu="$optarg"
> ;;
> --extra-cflags=*)
> @@ -252,6 +254,9 @@ python=
> download="enabled"
> skip_meson=no
> use_containers="yes"
> +# do not enable by default because cross compilation requires
> --rust-target-triple
> +rust="disabled"
> +rust_target_triple=""
> gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
> gdb_arches=""
>
> @@ -317,6 +322,8 @@ windmc="${WINDMC-${cross_prefix}windmc}"
> pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}"
> sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
>
> +rustc="${RUSTC-rustc}"
> +
> check_define() {
> cat > $TMPC <<EOF
> #if !defined($1)
> @@ -636,6 +643,8 @@ for opt do
> ;;
> --objcc=*)
> ;;
> + --rustc=*)
> + ;;
> --make=*)
> ;;
> --install=*)
> @@ -755,8 +764,14 @@ for opt do
> ;;
> --container-engine=*) container_engine="$optarg"
> ;;
> + --rust-target-triple=*) rust_target_triple="$optarg"
> + ;;
> --gdb=*) gdb_bin="$optarg"
> ;;
> + --enable-rust) rust=enabled
> + ;;
> + --disable-rust) rust=disabled
> + ;;
> # everything else has the same name in configure and meson
> --*) meson_option_parse "$opt" "$optarg"
> ;;
> @@ -859,6 +874,7 @@ Advanced options (experts only):
> at build time [$host_cc]
> --cxx=CXX use C++ compiler CXX [$cxx]
> --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
> + --rustc=RUSTC use Rust compiler RUSTC [$rustc]
> --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
> --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
> --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags
> OBJCFLAGS
> @@ -869,8 +885,9 @@ Advanced options (experts only):
> --python=PYTHON use specified python [$python]
> --ninja=NINJA use specified ninja [$ninja]
> --static enable static build [$static]
> - --without-default-features default all --enable-* options to "disabled"
> - --without-default-devices do not include any device that is not needed to
> + --rust-target-triple=TRIPLE target for Rust cross compilation
> + --without-default-features default all --enable-* options to "disabled"
> + --without-default-devices do not include any device that is not needed
> to
> start the emulator (only use if you are including
> desired devices in configs/devices/)
> --with-devices-ARCH=NAME override default configs/devices
> @@ -1139,6 +1156,21 @@ EOF
> fi
>
> ##########################################
> +# detect rust triple
> +
> +if test "$rust" != disabled && has "$rustc" && $rustc -vV >
> "${TMPDIR1}/${TMPB}.out"; then
> + rust_host_triple=$(sed -n 's/^host: //p' "${TMPDIR1}/${TMPB}.out")
> +else
> + if test "$rust" = enabled; then
> + error_exit "could not execute rustc binary \"$rustc\""
> + fi
> + rust=disabled
> +fi
> +if test "$rust" != disabled && test -z "$rust_target_triple"; then
> + rust_target_triple=$rust_host_triple
> +fi
Defaulting to the $rust_host_triple is incorrect when QEMU has been
told to build for a non-host target.
Either we need todo the right thing and auto-set rust target based
on QEMU target (preferred), or we need to make it a fatal error
when rust target is omitted & QEMU is building a non-host target.
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
- [PATCH RESEND v9 0/9] Add Rust build support, ARM PL011 device impl, Manos Pitsidianakis, 2024/08/28
- [PATCH RESEND v9 3/9] configure, meson: detect Rust toolchain, Manos Pitsidianakis, 2024/08/28
- [PATCH RESEND v9 1/9] Require meson version 1.5.0, Manos Pitsidianakis, 2024/08/28
- [PATCH RESEND v9 4/9] rust: add bindgen step as a meson dependency, Manos Pitsidianakis, 2024/08/28
- [PATCH RESEND v9 5/9] .gitattributes: add Rust diff and merge attributes, Manos Pitsidianakis, 2024/08/28
- [PATCH RESEND v9 6/9] meson.build: add HAVE_GLIB_WITH_ALIGNED_ALLOC flag, Manos Pitsidianakis, 2024/08/28
- [PATCH RESEND v9 2/9] build-sys: Add rust feature option, Manos Pitsidianakis, 2024/08/28
- [PATCH RESEND v9 8/9] rust: add utility procedural macro crate, Manos Pitsidianakis, 2024/08/28
- [PATCH RESEND v9 7/9] rust: add crate to expose bindings and interfaces, Manos Pitsidianakis, 2024/08/28