All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: "Stefan Hajnoczi" <stefanha@redhat.com>,
	"Mads Ynddal" <mads@ynddal.dk>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Alex Benné e" <alex.bennee@linaro.org>,
	"Daniel P. Berrangé " <berrange@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Philippe Mathieu-Daudé " <philmd@linaro.org>,
	"Zhao Liu" <zhao1.liu@intel.com>,
	"Gustavo Romero" <gustavo.romero@linaro.org>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	rowan.hart@intel.com,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"John Snow" <jsnow@redhat.com>, "Cleber Rosa" <crosa@redhat.com>
Subject: Re: [RFC PATCH v3 1/5] build-sys: Add rust feature option
Date: Thu, 20 Jun 2024 21:06:41 +0300	[thread overview]
Message-ID: <fe5ah.cugg8hrhlzn0@linaro.org> (raw)
In-Reply-To: <ae1397b5-4154-4aeb-bf5f-3a62adcc05fd@redhat.com>

On Thu, 20 Jun 2024 16:21, Paolo Bonzini <pbonzini@redhat.com> wrote:
>On 6/19/24 22:13, Manos Pitsidianakis wrote:
>> Add options for Rust in meson_options.txt, meson.build, configure to
>> prepare for adding Rust code in the followup commits.
>> 
>> `rust` is a reserved meson name, so we have to use an alternative.
>> `with_rust` was chosen.
>> 
>> A cargo_wrapper.py script is added that is heavily based on the work of
>> Marc-André Lureau from 2021.
>> 
>> https://patchew.org/QEMU/20210907121943.3498701-1-marcandre.lureau@redhat.com/
>> 
>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
>
>The cargo_wrapper.py script is not used yet, so it should be
>delayed until it's used.

That's true, I just wanted to make review easier by splitting it out. 
Can we squash them later or do you think I should I do it for the next 
series version?



>
>For the detection of the toolchain, I'd rather do everything in
>configure since that's where the cross file is built.  Something like:
>
>diff --git a/configure b/configure
>index 8b6a2f16ceb..6412a1021c3 100755
>--- a/configure
>+++ b/configure
>@@ -173,6 +173,8 @@ fi
>  
>  # default parameters
>  container_engine="auto"
>+rust_target_triple=""
>+with_rust="no"
>  cpu=""
>  cross_compile="no"
>  cross_prefix=""
>@@ -201,6 +202,8 @@ for opt do
>    --cross-prefix=*) cross_prefix="$optarg"
>                      cross_compile="yes"
>    ;;
>+  --cargo=*) CARGO="$optarg"
>+  ;;
>    --cc=*) CC="$optarg"
>    ;;
>    --cxx=*) CXX="$optarg"
>@@ -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}"
>  
>+cargo="${CARGO-cargo}"
>+
>  check_define() {
>  cat > $TMPC <<EOF
>  #if !defined($1)
>@@ -628,6 +635,8 @@ for opt do
>    ;;
>    --cross-prefix=*)
>    ;;
>+  --cargo=*)
>+  ;;
>    --cc=*)
>    ;;
>    --host-cc=*) host_cc="$optarg"
>@@ -755,8 +764,14 @@ for opt do
>    ;;
>    --container-engine=*) container_engine="$optarg"
>    ;;
>+  --rust-target-triple=*) rust_target_triple="$optarg"
>+  ;;
>    --gdb=*) gdb_bin="$optarg"
>    ;;
>+  --with-rust) with_rust=yes
>+  ;;
>+  --without-rust) with_rust=no
>+  ;;
>    # everything else has the same name in configure and meson
>    --*) meson_option_parse "$opt" "$optarg"
>    ;;
>@@ -854,6 +869,7 @@ $(echo Available targets: $default_target_list | \
>  Advanced options (experts only):
>    -Dmesonoptname=val       passthrough option to meson unmodified
>    --cross-prefix=PREFIX    use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
>+  --cargo=CARGO            use Cargo binary CARGO [$cargo]
>    --cc=CC                  use C compiler CC [$cc]
>    --host-cc=CC             when cross compiling, use C compiler CC for code run
>                             at build time [$host_cc]
>@@ -869,11 +885,13 @@ 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
>+  --with-rust              enable experimental Rust code
>    --enable-debug           enable common debug build options
>    --cpu=CPU                Build for host CPU [$cpu]
>    --disable-containers     don't use containers for cross-building
>@@ -1138,6 +1159,20 @@ EOF
>    fi
>  fi
>  
>+##########################################
>+# detect rust triples
>+
>+if test "$with_rust" = yes; then
>+  $CARGO -vV > "${TMPDIR1}/${TMPB}.out"
>+  if test $? != 0; then
>+    error_exit "could not execute cargo binary \"$CARGO\""
>+  fi
>+  rust_host_triple=$(sed -n 's/^host: //p' "${TMPDIR1}/${TMPB}.out")
>+  if test "$rust_target_triple" = ""; then
>+    rust_target_triple=$rust_host_triple
>+  fi
>+fi
>+
>  ##########################################
>  # functions to probe cross compilers
>  
>@@ -1604,6 +1639,10 @@ if test "$container" != no; then
>      echo "RUNC=$runc" >> $config_host_mak
>  fi
>  echo "SUBDIRS=$subdirs" >> $config_host_mak
>+if test "$with_rust" = yes; then
>+  echo "RUST_HOST_TRIPLE=$rust_host_triple" >> $config_host_mak
>+  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
>@@ -1731,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 "$with_rust" = yes; then
>+    if test "$rust_host_triple" != "$rust_target_triple"; then
>+      echo "cargo = [$(meson_quote $cargo --target "$rust_target_triple")]" >> $cross
>+    else
>+      echo "cargo = [$(meson_quote $cargo)]" >> $cross
>+    fi
>+  fi


Hm that looks better indeed, thanks!


>    echo "ar = [$(meson_quote $ar)]" >> $cross
>    echo "dlltool = [$(meson_quote $dlltool)]" >> $cross
>    echo "nm = [$(meson_quote $nm)]" >> $cross
>diff --git a/meson.build b/meson.build
>index c5360fbd299..ad7dbc0d641 100644
>--- a/meson.build
>+++ b/meson.build
>@@ -290,6 +290,11 @@ foreach lang : all_languages
>    endif
>  endforeach
>  
>+cargo = not_found
>+if 'RUST_TARGET_TRIPLE' in config_host
>+  cargo = find_program('cargo', required: true)
>+endif
>+
>  # default flags for all hosts
>  # We use -fwrapv to tell the compiler that we require a C dialect where
>  # left shift of signed integers is well defined and has the expected
>@@ -4239,6 +4244,10 @@ if 'objc' in all_languages
>  else
>    summary_info += {'Objective-C compiler': false}
>  endif
>+summary_info += {'Rust support':      cargo.found()}
>+if cargo.found() and config_host['RUST_TARGET_TRIPLE']) != config_host['RUST_HOST_TRIPLE']
>+  summary_info += {'Rust target':     config_host['RUST_TARGET_TRIPLE']}
>+endif
>  option_cflags = (get_option('debug') ? ['-g'] : [])
>  if get_option('optimization') != 'plain'
>    option_cflags += ['-O' + get_option('optimization')]
>
>


  reply	other threads:[~2024-06-20 18:14 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-19 20:13 [RFC PATCH v3 0/5] Implement ARM PL011 in Rust Manos Pitsidianakis
2024-06-19 20:13 ` [RFC PATCH v3 1/5] build-sys: Add rust feature option Manos Pitsidianakis
2024-06-20 13:21   ` Paolo Bonzini
2024-06-20 18:06     ` Manos Pitsidianakis [this message]
2024-06-20 19:44       ` Paolo Bonzini
2024-06-24  8:51     ` Zhao Liu
2024-06-24 16:35       ` Paolo Bonzini
2024-06-20 13:41   ` Alex Bennée
2024-06-20 18:14     ` Manos Pitsidianakis
2024-06-24 16:52   ` Daniel P. Berrangé
2024-06-24 17:14     ` Paolo Bonzini
2024-06-25 21:47       ` Manos Pitsidianakis
2024-06-26  9:34         ` Paolo Bonzini
2024-07-02 14:38     ` Manos Pitsidianakis
2024-07-02 15:23       ` Paolo Bonzini
2024-06-19 20:13 ` [RFC PATCH v3 2/5] rust: add bindgen step as a meson dependency Manos Pitsidianakis
2024-06-20 11:10   ` Alex Bennée
2024-06-20 12:34     ` Paolo Bonzini
2024-06-20 18:18       ` Manos Pitsidianakis
2024-06-20 12:32   ` Alex Bennée
2024-06-20 18:22     ` Manos Pitsidianakis
2024-06-24 19:52       ` Stefan Hajnoczi
2024-06-20 14:01   ` Richard Henderson
2024-06-20 18:36     ` Manos Pitsidianakis
2024-06-20 19:30       ` Richard Henderson
2024-06-24 10:12   ` Zhao Liu
2024-06-24 10:02     ` Manos Pitsidianakis
2024-06-25 16:00       ` Zhao Liu
2024-06-25 18:08         ` Manos Pitsidianakis
2024-06-27 23:47           ` Pierrick Bouvier
2024-06-28 19:12             ` Pierrick Bouvier
2024-06-28 21:50               ` Paolo Bonzini
2024-07-01 18:53                 ` Pierrick Bouvier
2024-06-29  8:06               ` Manos Pitsidianakis
2024-07-01 18:54                 ` Pierrick Bouvier
2024-07-02 12:25                   ` Manos Pitsidianakis
2024-07-02 16:07                     ` Pierrick Bouvier
2024-06-19 20:14 ` [RFC PATCH v3 3/5] rust: add PL011 device model Manos Pitsidianakis
2024-06-19 20:14 ` [RFC PATCH v3 4/5] DO NOT MERGE: add rustdoc build for gitlab pages Manos Pitsidianakis
2024-06-19 20:14 ` [RFC PATCH v3 5/5] DO NOT MERGE: replace TYPE_PL011 with x-pl011-rust in arm virt machine Manos Pitsidianakis
2024-06-25 16:18   ` Zhao Liu
2024-06-25 18:23     ` Manos Pitsidianakis
2024-06-25 19:15     ` Daniel P. Berrangé
2024-06-25 20:43       ` Peter Maydell

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=fe5ah.cugg8hrhlzn0@linaro.org \
    --to=manos.pitsidianakis@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=crosa@redhat.com \
    --cc=gustavo.romero@linaro.org \
    --cc=jsnow@redhat.com \
    --cc=mads@ynddal.dk \
    --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=rowan.hart@intel.com \
    --cc=stefanha@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.