From: Paolo Bonzini <pbonzini@redhat.com>
To: 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 18:43:01 +0200 [thread overview]
Message-ID: <1c53f8d2-3b33-404c-bb1c-38475087d7ae@redhat.com> (raw)
In-Reply-To: <0841ddd2-d962-4f1d-a818-be9a1ec4d9bf@linaro.org>
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
(*) these have to be generated to change the package name, so
configure_file() seems like a good match for it.
This is suspiciously similar to what tests/tcg/ looks like, except that
tests/tcg/*/Makefile is just a symbolic link. I tried creating a
similar directory structure in a toy project, and it seemed to work...
> Second silly question: does this really need to be committed to the
> repository? It *appears* to be specific to the host+os-version of the
> build. It is certainly very specific about versions and checksums...
Generally the idea is that libraries should not commit it, while
applications should commit it. The idea is that the Cargo.lock file
reproduces a working configuration, and dependencies are updated to
known-good releases when CI passes. I don't think I like this, but it
is what it is. I ascribe it to me being from the Jurassic.
But for now I would consider not committing Cargo.lock, because we don't
have the infrastructure to do that automatic dependency update (assuming
we want it). But we could generate it at release time so that it is
included in tarballs, and create the symlink from
srctree/rust/Cargo.lock into build/rust/ only if the file is present in
the source tree.
>> diff --git a/rust/pl011/Cargo.toml b/rust/pl011/Cargo.toml
>> [...]
>> +# bilge deps included here to include them with docs
>> +[dependencies]
>> +arbitrary-int = { version = "1.2.7" }
>> +bilge = { version = "0.2.0" }
>> +bilge-impl = { version = "0.2.0" }
This one has to be included, but it is less restrictive than it seems.
It is equivalent to
arbitrary-int = { version = ">=1.2.7, <2.0.0" }
bilge = { version = ">=0.2.0, <0.3.0" }
bilge-impl = { version = ">=0.2.0, <0.3.0" }
That is, it assumes an API breakage when the first nonzero component
changes in the version. It is also possible to put a caret in front of
the version, so that it's clearer that this is a range; but the behavior
is the same.
Paolo
next prev parent reply other threads:[~2024-06-19 16:44 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 [this message]
2024-06-19 16:54 ` Daniel P. Berrangé
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=1c53f8d2-3b33-404c-bb1c-38475087d7ae@redhat.com \
--to=pbonzini@redhat.com \
--cc=manos.pitsidianakis@linaro.org \
--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 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).