[Buildroot] [git commit branch/next] package/pkg-cargo: move CARGO_HOME into DL_DIR
Yann E. MORIN
yann.morin.1998 at free.fr
Mon Nov 7 17:31:50 UTC 2022
commit: https://git.buildroot.net/buildroot/commit/?id=8450b769187087751f83cbefcf0a88f70d9da670
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/next
CARGO_HOME is where Cargo stores its downloaded artefacts. See
https://doc.rust-lang.org/cargo/reference/environment-variables.html:
CARGO_HOME â Cargo maintains a local cache of the registry index and
of git checkouts of crates. By default these are stored under
$HOME/.cargo (%USERPROFILE%\.cargo on Windows), but this variable
overrides the location of this directory. Once a crate is cached it
is not removed by the clean command. For more details refer to the
guide.
We currently make it point to $(HOST_DIR)/share/cargo, but this has a
number of drawbacks:
(1) It is not shared between Buildroot builds. Each Buildroot build
will re-download the crates index, and the crates themselves,
unless of course the final vendored tarball is already there.
(2) With BR2_PER_PACKAGE_DIRECTORIES=y, it is even worse: CARGO_HOME
is not even shared between packages, as $(HOST_DIR)/share/cargo
is per package. So each package in the build that needs vendoring
of Cargo crates will download the crates index and the crates in
its own CARGO_HOME location.
To solve this, this commit moves CARGO_HOME into $(DL_DIR), so that it
is shared between builds and packages.
Even though not the best/most authoritative source,
https://github.com/rust-lang/cargo/issues/6930 indicates that there is
a lock when accessing CARGO_HOME, because a user even complains that
this lock has even become more coarse-grained than it used to be
(which for us is fine, it just means that two Cargo fetch operations
from two different packages will be serialized, not a big deal).
Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
Tested-by: Moritz Bitsch <moritz at h6t.eu>
[yann.morin.1998 at free.fr: rename directory: s/\.cargo/br-cargo-home/]
Signed-off-by: Yann E. MORIN <yann.morin.1998 at free.fr>
---
package/pkg-cargo.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package/pkg-cargo.mk b/package/pkg-cargo.mk
index 5923725f5e..666c5ac971 100644
--- a/package/pkg-cargo.mk
+++ b/package/pkg-cargo.mk
@@ -20,7 +20,7 @@
#
################################################################################
-BR_CARGO_HOME = $(HOST_DIR)/share/cargo
+BR_CARGO_HOME = $(DL_DIR)/br-cargo-home
PKG_COMMON_CARGO_ENV = \
CARGO_HOME=$(BR_CARGO_HOME)
More information about the buildroot
mailing list