From: "Alex Bennée" <alex.bennee@linaro.org>
To: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Cc: qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Gustavo Romero" <gustavo.romero@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Junjie Mao" <junjie.mao@intel.com>,
"Zhao Liu" <zhao1.liu@intel.com>
Subject: Re: [PATCH RESEND v9 3/9] configure, meson: detect Rust toolchain
Date: Wed, 28 Aug 2024 13:11:55 +0100 [thread overview]
Message-ID: <875xrk4zjo.fsf@draig.linaro.org> (raw)
In-Reply-To: <20240828-rust-pl011-v9-3-35579191f17c@linaro.org> (Manos Pitsidianakis's message of "Wed, 28 Aug 2024 07:11:44 +0300")
Manos Pitsidianakis <manos.pitsidianakis@linaro.org> writes:
> 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"
> + ;;
Could we not map from --cross-prefix to the target triple? Having to
specify both seems prone to failure.
> --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
> +
> +##########################################
> # functions to probe cross compilers
>
> container="no"
> @@ -1604,6 +1636,9 @@ if test "$container" != no; then
> echo "RUNC=$runc" >> $config_host_mak
> fi
> echo "SUBDIRS=$subdirs" >> $config_host_mak
> +if test "$rust" != disabled; then
> + echo "RUST_TARGET_TRIPLE=$rust_target_triple" >> $config_host_mak
> +fi
> echo "PYTHON=$python" >> $config_host_mak
> echo "MKVENV_ENSUREGROUP=$mkvenv ensuregroup $mkvenv_online_flag" >> $config_host_mak
> echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
> @@ -1735,6 +1770,13 @@ if test "$skip_meson" = no; then
> echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
> test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
> test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
> + if test "$rust" != disabled; then
> + if test "$rust_host_triple" != "$rust_target_triple"; then
> + echo "rust = [$(meson_quote $rustc --target "$rust_target_triple")]" >> $cross
> + else
> + echo "rust = [$(meson_quote $rustc)]" >> $cross
> + fi
> + fi
> echo "ar = [$(meson_quote $ar)]" >> $cross
> echo "dlltool = [$(meson_quote $dlltool)]" >> $cross
> echo "nm = [$(meson_quote $nm)]" >> $cross
> @@ -1770,6 +1812,9 @@ if test "$skip_meson" = no; then
> echo "# Automatically generated by configure - do not modify" > $native
> echo "[binaries]" >> $native
> echo "c = [$(meson_quote $host_cc)]" >> $native
> + if test "$rust" != disabled; then
> + echo "rust = [$(meson_quote $rustc)]" >> $cross
> + fi
> mv $native config-meson.native
> meson_option_add --native-file
> meson_option_add config-meson.native
> @@ -1788,6 +1833,7 @@ if test "$skip_meson" = no; then
> test "$pie" = no && meson_option_add -Db_pie=false
>
> # QEMU options
> + test "$rust" != "auto" && meson_option_add "-Drust=$rust"
> test "$cfi" != false && meson_option_add "-Dcfi=$cfi" "-Db_lto=$cfi"
> test "$docs" != auto && meson_option_add "-Ddocs=$docs"
> test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
> diff --git a/meson.build b/meson.build
> index 67eb4eda649d5f0566de2b75466b5a9d9ca87ab4..065739ccb7300f4f0d487602485802f9f68fb095 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -70,9 +70,6 @@ if host_os == 'darwin' and \
> all_languages += ['objc']
> objc = meson.get_compiler('objc')
> endif
> -if get_option('rust').enabled() and meson.version().version_compare('<1.0.0')
> - error('Rust support requires Meson version >=1.0.0')
> -endif
Ahh this is probably needs merging into the patch 2.
> have_rust = false
> if not get_option('rust').disabled() and add_languages('rust', required: get_option('rust'), native: false)
> rustc = meson.get_compiler('rust')
> @@ -4307,8 +4304,9 @@ else
> endif
> summary_info += {'Rust support': have_rust}
> if have_rust
> - summary_info += {'rustc version': rustc.version()}
> - summary_info += {'rustc': ' '.join(rustc.cmd_array())}
> + summary_info += {'rustc version': rustc.version()}
> + summary_info += {'rustc': ' '.join(rustc.cmd_array())}
> + summary_info += {'Rust target': config_host['RUST_TARGET_TRIPLE']}
> endif
> option_cflags = (get_option('debug') ? ['-g'] : [])
> if get_option('optimization') != 'plain'
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2024-08-28 12:12 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-28 4:11 [PATCH RESEND v9 0/9] Add Rust build support, ARM PL011 device impl Manos Pitsidianakis
2024-08-28 4:11 ` [PATCH RESEND v9 1/9] Require meson version 1.5.0 Manos Pitsidianakis
2024-08-28 10:43 ` Alex Bennée
2024-08-28 4:11 ` [PATCH RESEND v9 2/9] build-sys: Add rust feature option Manos Pitsidianakis
2024-08-28 11:26 ` Alex Bennée
2024-08-28 4:11 ` [PATCH RESEND v9 3/9] configure, meson: detect Rust toolchain Manos Pitsidianakis
2024-08-28 12:11 ` Alex Bennée [this message]
2024-08-28 12:28 ` Daniel P. Berrangé
2024-09-04 11:03 ` Paolo Bonzini
2024-09-04 11:32 ` Paolo Bonzini
2024-08-28 4:11 ` [PATCH RESEND v9 4/9] rust: add bindgen step as a meson dependency Manos Pitsidianakis
2024-08-28 4:11 ` [PATCH RESEND v9 5/9] .gitattributes: add Rust diff and merge attributes Manos Pitsidianakis
2024-08-28 4:11 ` [PATCH RESEND v9 6/9] meson.build: add HAVE_GLIB_WITH_ALIGNED_ALLOC flag Manos Pitsidianakis
2024-08-28 13:15 ` Alex Bennée
2024-08-28 4:11 ` [PATCH RESEND v9 7/9] rust: add crate to expose bindings and interfaces Manos Pitsidianakis
2024-08-28 13:08 ` Alex Bennée
2024-08-30 1:19 ` Junjie Mao
2024-08-30 6:43 ` Manos Pitsidianakis
2024-08-30 8:50 ` Junjie Mao
2024-08-30 11:03 ` Alex Bennée
2024-08-31 8:25 ` Manos Pitsidianakis
2024-09-02 5:58 ` Junjie Mao
2024-09-06 7:56 ` Paolo Bonzini
2024-09-04 11:01 ` Paolo Bonzini
2024-09-05 3:05 ` Junjie Mao
2024-09-05 7:50 ` Manos Pitsidianakis
2024-08-28 4:11 ` [PATCH RESEND v9 8/9] rust: add utility procedural macro crate Manos Pitsidianakis
2024-08-28 4:11 ` [PATCH RESEND v9 9/9] rust: add PL011 device model Manos Pitsidianakis
2024-09-04 11:04 ` Paolo Bonzini
2024-09-06 10:41 ` Paolo Bonzini
2024-08-28 13:18 ` [PATCH RESEND v9 0/9] Add Rust build support, ARM PL011 device impl Alex Bennée
2024-09-04 11:31 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875xrk4zjo.fsf@draig.linaro.org \
--to=alex.bennee@linaro.org \
--cc=berrange@redhat.com \
--cc=gustavo.romero@linaro.org \
--cc=junjie.mao@intel.com \
--cc=manos.pitsidianakis@linaro.org \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).