From: "Paul Barker" <paul@pbarker.dev>
To: "Marco Felsch" <m.felsch@pengutronix.de>,
<openembedded-core@lists.openembedded.org>
Cc: <peter.kjellerstedt@axis.com>, <yocto@pengutronix.de>
Subject: Re: [PATCH v4 3/3] classes/cargo-update-recipe-crates: support multiple Cargo.lock search directories
Date: Mon, 30 Nov 2026 21:24:42 +0000 [thread overview]
Message-ID: <DN8V1YTLDUAY.175K5IM80O2V3@pbarker.dev> (raw)
In-Reply-To: <20261130-mfe-multi-cargo-lock-files-v4-3-a3ebce5cc283@pengutronix.de>
Hi Marco,
Thanks for the v4 series, patches 1/3 & 2/3 are good, I have a couple of
comments on this one.
On Mon Nov 30, 2026 at 8:40 PM GMT, Marco Felsch wrote:
> Recipes using cargo's -Z build-std must also vendor the standard
> library's dependencies. The std sources staged by rust-native
> (.../rustlib/src/rust/library) ship a Cargo.lock but no vendor
> directory, so those crates need crate:// entries in SRC_URI as well.
> Until now only a single directory could be scanned (CARGO_LOCK_SRC_DIR),
> which forced the std crate list to be maintained by hand and go stale on
> toolchain upgrades, breaking do_compile with:
>
> error: failed to select a version for the requirement
> `cfg-if = "^1.0"` (locked to 1.0.4)
>
> Keep the existing CARGO_LOCK_SRC_DIR and extend it to support a
> space-separated list of directories, to allow:
>
> CARGO_LOCK_SRC_DIR = "${S} ${STAGING_LIBDIR_NATIVE}/rustlib/src/rust/library"
In this example you'd need to ensure ${STAGING_LIBDIR_NATIVE} is
populated before do_update_crates runs. It's probably worth modifying
the `addtask` line so do_update_crates always runs after
do_prepare_recipe_sysroot.
We should also consider what should happen if one of these directories
is missing or doesn't contain a Cargo.lock file. Should that cause an
error?
>
> This way the behavior can be backported.
>
> Crates found in multiple lockfiles are listed only once, in the section
> of the first Cargo.lock containing them; conflicting checksums for the
> same crate version now fail the task. The crates.io warning now names the
> lockfile it came from. Output for recipes with a single lockfile is
> unchanged.
The "first" Cargo.lock file mentioning a particular crate will depend on
the order in which Cargo.lock files are parsed. I don't think os.walk()
explores subdirectories in a deterministic order, can we modify this so
that the output is deterministic?
>
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
> .../cargo-update-recipe-crates.bbclass | 53 ++++++++++++++--------
> 1 file changed, 33 insertions(+), 20 deletions(-)
>
> diff --git a/meta/classes-recipe/cargo-update-recipe-crates.bbclass b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
> index 9f92f0a522979fde8f0b88abdefb9a03c0c651ee..449a1c5d81b92c686e9aea76648a55e88ec77efc 100644
> --- a/meta/classes-recipe/cargo-update-recipe-crates.bbclass
> +++ b/meta/classes-recipe/cargo-update-recipe-crates.bbclass
> @@ -23,12 +23,12 @@ do_update_crates[doc] = "Update the recipe by reading Cargo.lock and write in ${
>
> RECIPE_UPGRADE_EXTRA_TASKS += "do_update_crates"
>
> -# The directory where to search for Cargo.lock files
> +# Space-separated list of directories where to search for Cargo.lock files.
> +# Crates found in multiple Cargo.lock files are listed only once, in the
> +# section of the first Cargo.lock file that contains them.
> CARGO_LOCK_SRC_DIR ??= "${S}"
>
> python do_update_crates() {
> - cargo_lock_src_dir = d.getVar("CARGO_LOCK_SRC_DIR")
> -
> def get_legacy_checksums(crates, filename):
> # Old (v1) Cargo.lock files do not carry a 'checksum' field per
> # [[package]]; instead they are collected in the [metadata] table:
> @@ -48,13 +48,13 @@ python do_update_crates() {
> checksums[(name, version, source)] = value
> return checksums
>
> - def get_crates(filename):
> + def get_crates(filename, src_dir, seen):
> try:
> import tomllib
> except ImportError:
> import bb._vendor.tomli as tomllib
>
> - c_list = '# from %s' % os.path.relpath(filename, cargo_lock_src_dir)
> + c_list = '# from %s' % os.path.relpath(filename, src_dir)
If there are two entries in CARGO_LOCK_SRC_DIR, each path containing a
Cargo.toml file, this will just say `# from Cargo.lock` for each. Is
there a better way to differentiate them without embedding absolute
paths in the output?
Best regards,
--
Paul Barker
next prev parent reply other threads:[~2026-11-30 21:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 20:40 [PATCH v4 0/3] Add support for multi Cargo.lock files Marco Felsch
2026-11-30 20:40 ` [PATCH v4 1/3] classes/cargo-update-recipe-crates: use bb.warn() instead of print() Marco Felsch
2026-11-30 20:40 ` [PATCH v4 2/3] classes/cargo-update-recipe-crates: support v1 Cargo.lock format Marco Felsch
2026-11-30 20:40 ` [PATCH v4 3/3] classes/cargo-update-recipe-crates: support multiple Cargo.lock search directories Marco Felsch
2026-11-30 21:24 ` Paul Barker [this message]
2026-12-01 9:37 ` [OE-core] " Marco Felsch
[not found] ` <18ED17AB19C3015E.2226965@lists.openembedded.org>
2026-12-01 16:25 ` Marco Felsch
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=DN8V1YTLDUAY.175K5IM80O2V3@pbarker.dev \
--to=paul@pbarker.dev \
--cc=m.felsch@pengutronix.de \
--cc=openembedded-core@lists.openembedded.org \
--cc=peter.kjellerstedt@axis.com \
--cc=yocto@pengutronix.de \
/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