Commit 2dc9c20
authored
perf(package): Always reuse the workspace's target-dir (#15783)
### What does this PR try to resolve?
While preparing to stabilize `build-dir`, [it was
discovered](#14125 (comment))
that `cargo package` will sometimes use the build cache for dependency
crates if `CARGO_TARGET_DIR` is explicitly set.
If target-dir is not set, the build will be preformed in an "inner
target dir" at `target/package/{name}-{version}/target` and rebuild
everything.
This PR changes the default behavior to always use the build cache,
matching the behavior of having `target-dir` set.
### How to test and review this PR?
Added a dedicated test to verify the previous behavior (cargo recompiled
non-workspace crates) in the first commit.
Then updated it to verify the new behavior.
### Related links/notes
* I did some Git archaeology and I _think_ this behavior was introduced
in #2912
* While searching through the commit/pr history was never able to find
any explicit reason why the behavior is the way it is.
* Even if it was intentional, it has been 9 years since and Cargo's
fingerprinting/rebuild detection is much more mature now so I believe
its worth revisiting if this is still the desired behavior.
* Would help mitigate #14941File tree
4 files changed
+43
-7
lines changed- src/cargo/ops/cargo_package
- tests/testsuite
4 files changed
+43
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
72 | | - | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1827 | 1827 | | |
1828 | 1828 | | |
1829 | 1829 | | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
1830 | 1869 | | |
1831 | 1870 | | |
1832 | 1871 | | |
| |||
5705 | 5744 | | |
5706 | 5745 | | |
5707 | 5746 | | |
5708 | | - | |
5709 | 5747 | | |
5710 | 5748 | | |
5711 | 5749 | | |
| |||
6614 | 6652 | | |
6615 | 6653 | | |
6616 | 6654 | | |
6617 | | - | |
6618 | 6655 | | |
6619 | 6656 | | |
6620 | 6657 | | |
| |||
6997 | 7034 | | |
6998 | 7035 | | |
6999 | 7036 | | |
7000 | | - | |
7001 | 7037 | | |
7002 | 7038 | | |
7003 | 7039 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1341 | 1341 | | |
1342 | 1342 | | |
1343 | 1343 | | |
1344 | | - | |
1345 | 1344 | | |
1346 | 1345 | | |
1347 | 1346 | | |
| |||
3746 | 3745 | | |
3747 | 3746 | | |
3748 | 3747 | | |
3749 | | - | |
3750 | 3748 | | |
3751 | 3749 | | |
3752 | 3750 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
563 | 563 | | |
564 | 564 | | |
565 | 565 | | |
566 | | - | |
567 | 566 | | |
568 | 567 | | |
569 | 568 | | |
| |||
0 commit comments