Compiling cargo binaries from build script deadlocks #8938
Labels
A-build-scripts
Area: build.rs scripts
C-bug
Category: bug
S-triage
Status: This issue is waiting on initial triage.
Problem
deadlock with .cargo-lock file lock when using build.rs (build script) with cargo crate/
usecase
A workspace with 2 binary packages Pa, Pb.
Pb wants to compile Pa as a binary dependency. Both Pa and Pb are rust packages.
Currently, IMO this can only be done using a build script for Pb which compiles Pa as a binary. I am using the cargo crate to programmatically invoke the compilation of Pa, This compilation blocks on locking TARGET_DIR/.cargo.lock file. The file is locked by the parent cargo process.
(attaching link to sample workspace for repro)
Steps
Workspace layout
https://drive.google.com/file/d/19Ab4TQcy0pl90o8keN42h8Y-e05dCiSP/view?usp=sharing
▶ tree
.
├── Cargo.lock
├── Cargo.toml
├── sub1
│ ├── Cargo.toml
│ └── src
│ └── main.rs
└── sub2
├── build.rs << Compiles sub1 using the cargo crate.
├── Cargo.toml
├── op.txt
└── src
└── main.rs
Possible Solution(s)
I cannot think of a reason why .cargo.lock has to lock during the invocation of the build script.
Maybe this can be relaxed.
Notes
Output of
cargo version
:cargo --version
cargo 1.47.0 (f3c7e06 2020-08-28)
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
Workaround
Code snippet
The text was updated successfully, but these errors were encountered: