From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <richard.henderson@linaro.org>,
Manos Pitsidianakis <manos.pitsidianakis@linaro.org>,
qemu-devel@nongnu.org
Subject: Re: [RFC PATCH v2 3/5] rust: add PL011 device model
Date: Wed, 19 Jun 2024 17:54:24 +0100 [thread overview]
Message-ID: <ZnMNQJ23hC2OyGtT@redhat.com> (raw)
In-Reply-To: <1c53f8d2-3b33-404c-bb1c-38475087d7ae@redhat.com>
On Wed, Jun 19, 2024 at 06:43:01PM +0200, Paolo Bonzini wrote:
> On 6/19/24 07:34, Richard Henderson wrote:
> > First silly question: how much of this is boiler plate that gets moved
> > the moment that the second rust subdirectory is added?
>
> If my suggestion at https://lore.kernel.org/qemu-devel/CABgObfaP7DRD8dbSKNmUzhZNyxeHWO0MztaW3_EFYt=vf6SbzA@mail.gmail.com/
> works, we'd have only two directories that have a Cargo.toml in it. For
> example it could be rust/qemu/ (common code) and rust/hw/ (code that depends
> on Kconfig).
>
> I think we can also have a rust/Cargo.toml file as in
> https://doc.rust-lang.org/cargo/reference/workspaces.html#virtual-workspace,
> and then the various configuration files under rust/ will be valid for all
> subpackages.
>
> > > +[build]
> > > +rustflags = ["-Crelocation-model=pic", "-Ctarget-feature=+crt-static"]
> >
> > It seems certain that this is not specific to pl011, and will be commot
> > to other rust subdirectories. Or, given the .cargo directory name, is
> > this generated by cargo and committed by mistake?
>
> -Crelocation-mode should be pie. But also, I am not sure it works because I
> think it's always going to be overridden by cargo_wrapper.py? See
> https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags.
>
> (I'm not sure what +crt-static is for).
>
> I think the generate_cfg_flags() mechanism of cargo_wrapper.py has to be
> rewritten from Python to Rust and moved to build.rs (using
> cargo::rustc-cfg). By doing this, the cfg flags are added to whatever is in
> .cargo/config.toml, rather than replaced.
>
> > > diff --git a/rust/pl011/.gitignore b/rust/pl011/.gitignore
> > > new file mode 100644
> > > index 0000000000..28a02c847f
> > > --- /dev/null
> > > +++ b/rust/pl011/.gitignore
> > > @@ -0,0 +1,2 @@
> > > +target
> > > +src/generated.rs.inc
> >
> > Is this a symptom of generating files into the source directory and not
> > build directory?
>
> If I understand correctly, Manos considered two possible ways to invoke
> cargo on the Rust code:
>
> - directly, in which case you need to copy the generated source file to
> rust/pl011/src/generated.rs.inc, because cargo does not know where the build
> tree
>
> - do everything through meson, which does the right thing because
> cargo_wrapper.py knows about the build tree and passes the information.
>
> To avoid this, the first workflow could be adjusted so that cargo can still
> be invoked directly, _but from the build tree_, not the source tree. For
> example configure could generate a .../build/.cargo/config.toml with
>
> [env]
> MESON_BUILD_ROOT = ".../build"
>
> (extra advantage: -Crelocation-model=pie can be added based on
> --enable-pie/--disable-pie). configure can also create symlinks in the
> build tree for the source tree's rust/, Cargo.toml and Cargo.lock.
>
> This allows rust/pl011/src/generated.rs (which probably will become
> something like rust/common/src/generated.rs) to be:
>
> include!(concat!(env!("MESON_BUILD_ROOT"), "/generated.rs.inc"));
>
> when cargo is invoked from the build tree.
>
> Putting everything together you'd have
>
> build/
> rust/
> .cargo/
> config.toml # generated by configure or meson.build
> Cargo.toml # workspace generated by configure or meson.build
> Cargo.lock # can be either linked to srctree or generated
> qemu/ # symlink to srctree/rust/qemu
> aarch64-softmmu-hw/
> Cargo.toml # generated by meson.build (*)
> src/ # symlink to srctree/rust/hw/
> i386-softmmu-hw/
> Cargo.toml # generated by meson.build
> src/ # symlink to srctree/rust/hw/
> generated/ # files generated by rust/generated/meson.build
If we're generating a build tree to invoke cargo on, can we then
avoid creating a completely separate dir hierarchy in the source
tree rooted at /rust, and just have rust source within our existing
hierarchy.
eg
aarch64-softmmu-hw/
Cargo.toml # generated by meson.build (*)
src/
pl011/ # symlink to srctree/hw/p1011/
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 :|
next prev parent reply other threads:[~2024-06-19 16:54 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-11 10:33 [RFC PATCH v2 0/5] Implement ARM PL011 in Rust Manos Pitsidianakis
2024-06-11 10:33 ` [RFC PATCH v2 1/5] build-sys: Add rust feature option Manos Pitsidianakis
2024-06-19 4:44 ` Richard Henderson
2024-06-19 16:52 ` Richard Henderson
2024-06-19 17:32 ` Manos Pitsidianakis
2024-06-11 10:33 ` [RFC PATCH v2 2/5] rust: add bindgen step as a meson dependency Manos Pitsidianakis
2024-06-17 21:01 ` Paolo Bonzini
2024-06-11 10:33 ` [RFC PATCH v2 3/5] rust: add PL011 device model Manos Pitsidianakis
2024-06-12 12:29 ` Paolo Bonzini
2024-06-12 14:14 ` Manos Pitsidianakis
2024-06-12 15:20 ` Paolo Bonzini
2024-06-12 16:06 ` Daniel P. Berrangé
2024-06-12 20:57 ` Manos Pitsidianakis
2024-06-12 21:27 ` Paolo Bonzini
2024-06-13 5:09 ` Manos Pitsidianakis
2024-06-13 7:13 ` Daniel P. Berrangé
2024-06-13 7:56 ` Paolo Bonzini
2024-06-13 8:49 ` Manos Pitsidianakis
2024-06-13 9:16 ` Daniel P. Berrangé
2024-06-13 20:57 ` Paolo Bonzini
2024-06-14 6:38 ` Manos Pitsidianakis
2024-06-14 17:50 ` Paolo Bonzini
2024-06-17 8:45 ` Manos Pitsidianakis
2024-06-17 11:32 ` Paolo Bonzini
2024-06-17 13:54 ` Manos Pitsidianakis
2024-06-17 14:32 ` Paolo Bonzini
2024-06-17 21:04 ` Manos Pitsidianakis
2024-06-17 23:33 ` Pierrick Bouvier
2024-06-18 6:00 ` Paolo Bonzini
2024-06-18 6:00 ` Paolo Bonzini
2024-06-17 23:18 ` Pierrick Bouvier
2024-06-18 9:13 ` Daniel P. Berrangé
2024-06-18 9:29 ` Paolo Bonzini
2024-06-18 9:49 ` Peter Maydell
2024-06-13 16:20 ` Zhao Liu
2024-06-13 17:56 ` Paolo Bonzini
2024-06-13 8:30 ` Zhao Liu
2024-06-13 8:41 ` Manos Pitsidianakis
2024-06-13 8:53 ` Daniel P. Berrangé
2024-06-13 8:59 ` Manos Pitsidianakis
2024-06-13 9:20 ` Daniel P. Berrangé
2024-06-19 5:34 ` Richard Henderson
2024-06-19 16:43 ` Paolo Bonzini
2024-06-19 16:54 ` Daniel P. Berrangé [this message]
2024-06-19 17:23 ` Paolo Bonzini
2024-07-11 4:21 ` Zhao Liu
2024-07-11 5:35 ` Manos Pitsidianakis
2024-06-11 10:33 ` [RFC PATCH v2 4/5] DO NOT MERGE: add rustdoc build for gitlab pages Manos Pitsidianakis
2024-06-11 10:33 ` [RFC PATCH v2 5/5] DO NOT MERGE: replace TYPE_PL011 with x-pl011-rust in arm virt machine Manos Pitsidianakis
2024-06-12 8:37 ` [RFC PATCH v2 0/5] Implement ARM PL011 in Rust Daniel P. Berrangé
2024-06-13 5:13 ` Manos Pitsidianakis
2024-06-13 7:56 ` Daniel P. Berrangé
2024-06-19 3:31 ` Richard Henderson
2024-06-19 17:36 ` Manos Pitsidianakis
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=ZnMNQJ23hC2OyGtT@redhat.com \
--to=berrange@redhat.com \
--cc=manos.pitsidianakis@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/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.