Cargo doesn't rebuild package when changing local toolchains
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
Description
Problem
Cargo doesn't detect that it needs to do a fresh build when switching from one local toolchain to another, or when updating a local toolchain, at least under some circumstances.
Steps
(I haven't verified the correctness of the steps below, but they should give an idea of the issue.)
# Build rustc.
./x.py build library/std
# Create a toolchain from it.
cp -r build/x86_64-unknown-linux-gnu/stage1/ ../toolchains/toolchain-a
rustup toolchain link toolchain-a /path/to/toolchain-a
# Make a change to rustc code.
# Build rustc.
./x.py build library/std
# Create a toolchain from it.
cp -r build/x86_64-unknown-linux-gnu/stage1/ ../toolchains/toolchain-b
rustup toolchain link toolchain-b /path/to/toolchain-b
# Build something with toolchain-a, then try to build it with toolchain-b.
cd ..
cargo new foo
cd foo
cargo +toolchain-a build
# This does not build anything.
cargo +toolchain-b build
A similar issue occurs with just one toolchain, and you want to rebuild after updating it, though this is somewhat less surprising.
# Build rustc.
./x.py build library/std
# Create a toolchain from it.
cp -r build/x86_64-unknown-linux-gnu/stage1/ ../toolchains/toolchain-a
rustup toolchain link toolchain-a /path/to/toolchain-a
# Build something with toolchain-a.
cd ..
cargo new foo
cd foo
cargo +toolchain-a build
cd -
# Make a change to rustc code.
# Build rustc.
./x.py build library/std
# Update toolchain.
cp -r build/x86_64-unknown-linux-gnu/stage1/ ../toolchains/toolchain-a
cd -
# This does not build anything.
cargo +toolchain-a build
Possible Solution(s)
No response
Notes
No response
Version
cargo 1.55.0 (32da73ab1 2021-08-23)
release: 1.55.0
commit-hash: 32da73ab19417aa89686e1d85c1440b72fdf877d
commit-date: 2021-08-23
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two command sequences using ./x.py build library/std, linked rustup toolchains, and cargo +toolchain-a/toolchain-b build. Trace Cargo's build invalidation behavior when switching between or updating local toolchains. Done means Cargo rebuilds the package when the selected local toolchain has changed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100