Commit c169b66
authored
feat(build-dir): Reorganize build-dir layout (#15947)
### What does this PR try to resolve?
This PR re-organizes the `build-dir` file layout structure to a layout
organized by "build unit" when `-Zbuild-dir-new-layout` is enabled.
See #15010 for the motivations and design discussions.
Below is file structure generated for a `foo` crate with a single
dependency on `syn`.
```
$ tree -a target
target
├── CACHEDIR.TAG
├── debug
│ ├── build
│ │ ├── foo
│ │ │ └── 9f7d8db454c2e3a0
│ │ │ ├── deps
│ │ │ │ ├── foo-9f7d8db454c2e3a0
│ │ │ │ └── foo-9f7d8db454c2e3a0.d
│ │ │ └── fingerprint
│ │ │ ├── bin-foo
│ │ │ ├── bin-foo.json
│ │ │ ├── dep-bin-foo
│ │ │ └── invoked.timestamp
│ │ ├── proc-macro2
│ │ │ ├── 39344080ec273066
│ │ │ │ ├── deps
│ │ │ │ │ ├── libproc_macro2-39344080ec273066.rlib
│ │ │ │ │ ├── libproc_macro2-39344080ec273066.rmeta
│ │ │ │ │ └── proc_macro2-39344080ec273066.d
│ │ │ │ └── fingerprint
│ │ │ │ ├── dep-lib-proc_macro2
│ │ │ │ ├── invoked.timestamp
│ │ │ │ ├── lib-proc_macro2
│ │ │ │ └── lib-proc_macro2.json
│ │ │ ├── 8fc259c340d09182
│ │ │ │ ├── build-script
│ │ │ │ │ ├── build-script-build
│ │ │ │ │ ├── build_script_build-8fc259c340d09182
│ │ │ │ │ └── build_script_build-8fc259c340d09182.d
│ │ │ │ ├── deps
│ │ │ │ └── fingerprint
│ │ │ │ ├── build-script-build-script-build
│ │ │ │ ├── build-script-build-script-build.json
│ │ │ │ ├── dep-build-script-build-script-build
│ │ │ │ └── invoked.timestamp
│ │ │ └── a6c299e456bc1663
│ │ │ ├── build-script-execution
│ │ │ │ ├── invoked.timestamp
│ │ │ │ ├── out
│ │ │ │ ├── output
│ │ │ │ ├── root-output
│ │ │ │ └── stderr
│ │ │ ├── deps
│ │ │ └── fingerprint
│ │ │ ├── run-build-script-build-script-build
│ │ │ └── run-build-script-build-script-build.json
│ │ ├── quote
│ │ │ └── e95944fa29b3b7d5
│ │ │ ├── deps
│ │ │ │ ├── libquote-e95944fa29b3b7d5.rlib
│ │ │ │ ├── libquote-e95944fa29b3b7d5.rmeta
│ │ │ │ └── quote-e95944fa29b3b7d5.d
│ │ │ └── fingerprint
│ │ │ ├── dep-lib-quote
│ │ │ ├── invoked.timestamp
│ │ │ ├── lib-quote
│ │ │ └── lib-quote.json
│ │ ├── syn
│ │ │ └── a0dd360a8d0d85f9
│ │ │ ├── deps
│ │ │ │ ├── libsyn-a0dd360a8d0d85f9.rlib
│ │ │ │ ├── libsyn-a0dd360a8d0d85f9.rmeta
│ │ │ │ └── syn-a0dd360a8d0d85f9.d
│ │ │ └── fingerprint
│ │ │ ├── dep-lib-syn
│ │ │ ├── invoked.timestamp
│ │ │ ├── lib-syn
│ │ │ └── lib-syn.json
│ │ └── unicode-ident
│ │ └── 90d3c33eeb6b75ae
│ │ ├── deps
│ │ │ ├── libunicode_ident-90d3c33eeb6b75ae.rlib
│ │ │ ├── libunicode_ident-90d3c33eeb6b75ae.rmeta
│ │ │ └── unicode_ident-90d3c33eeb6b75ae.d
│ │ └── fingerprint
│ │ ├── dep-lib-unicode_ident
│ │ ├── invoked.timestamp
│ │ ├── lib-unicode_ident
│ │ └── lib-unicode_ident.json
│ ├── .cargo-lock
│ ├── examples
│ ├── foo
│ ├── foo.d
│ └── incremental
│ └── foo-2476dro80nq0n
│ ├── s-hbvjw5x5fa-1d58onh-7sam1xj7vrwy85uyr70f3vu2p
│ │ ├── 1z96gpvj66dpsd06phiqkocsr.o
│ │ ├── 8jaqpsn916x4kajeuk1b7rl12.o
│ │ ├── 8sv45ek5gkoxjdcr3b6nbgu2o.o
│ │ ├── 9yqg9fn9x870xvia9frlvvazg.o
│ │ ├── a5v36uvuoyp00oyvscfno2pce.o
│ │ ├── c2q7ff0mmsk4s1yg7s5ei1ryr.o
│ │ ├── dep-graph.bin
│ │ ├── query-cache.bin
│ │ └── work-products.bin
│ └── s-hbvjw5x5fa-1d58onh.lock
└── .rustc_info.json
36 directories, 62 files
```
For why incremental is where it is, see
#15947 (comment)
As a side effect, we pass a lot more parameters to rustc, likely making
`cargo -v` more annoying, similar to #13941.
### How to test and review this PR?
This PR still needs to be more thoroughly tested. Thus far I have been
testing on simple test crates.
Also see #15874 for potential test harness improvements that could be
used by this PR.
### Follow up actions
- [ ] Remove redundant `-Cextra-filename` in files where possible.
- [ ] See if we can drop `<platform>/<profile>` after #4282
- [ ] Re-evaluate if we want platform to be unconditionally included in
the build-dir layout
- [ ] Is `<pkgname>/<hash>` good enough or do we need to go with
prefixes to reduce the number of items within a directory, see
#15947 (comment)
- [ ] Can we simplify how fingerpritns are stored, reducing pressure on
path lenghts
- [ ] Under the new layout, should `cargo clean -p` also cleans old
layout paths? See
#15947 (comment)File tree
9 files changed
+1537
-182
lines changed- crates/cargo-test-support/src
- src/cargo
- core/compiler
- build_runner
- ops
- tests/testsuite
9 files changed
+1537
-182
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
238 | 241 | | |
239 | 242 | | |
240 | 243 | | |
| |||
Lines changed: 21 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
238 | 242 | | |
239 | 243 | | |
240 | 244 | | |
241 | | - | |
| 245 | + | |
242 | 246 | | |
243 | | - | |
| 247 | + | |
244 | 248 | | |
245 | 249 | | |
246 | 250 | | |
| |||
255 | 259 | | |
256 | 260 | | |
257 | 261 | | |
258 | | - | |
259 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
260 | 265 | | |
261 | 266 | | |
262 | 267 | | |
263 | 268 | | |
264 | | - | |
265 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
266 | 272 | | |
267 | 273 | | |
268 | 274 | | |
269 | 275 | | |
270 | 276 | | |
271 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
272 | 283 | | |
273 | 284 | | |
274 | 285 | | |
| |||
303 | 314 | | |
304 | 315 | | |
305 | 316 | | |
306 | | - | |
| 317 | + | |
307 | 318 | | |
308 | 319 | | |
309 | 320 | | |
| |||
337 | 348 | | |
338 | 349 | | |
339 | 350 | | |
340 | | - | |
| 351 | + | |
341 | 352 | | |
342 | 353 | | |
343 | 354 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
401 | 402 | | |
402 | 403 | | |
403 | 404 | | |
404 | | - | |
405 | | - | |
406 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
407 | 416 | | |
408 | 417 | | |
409 | 418 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
| 160 | + | |
159 | 161 | | |
160 | 162 | | |
161 | 163 | | |
| |||
212 | 214 | | |
213 | 215 | | |
214 | 216 | | |
| 217 | + | |
215 | 218 | | |
216 | 219 | | |
217 | 220 | | |
218 | 221 | | |
219 | 222 | | |
220 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
221 | 227 | | |
222 | | - | |
223 | 228 | | |
224 | 229 | | |
225 | 230 | | |
| |||
232 | 237 | | |
233 | 238 | | |
234 | 239 | | |
235 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
236 | 249 | | |
237 | 250 | | |
238 | 251 | | |
| |||
256 | 269 | | |
257 | 270 | | |
258 | 271 | | |
259 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
260 | 281 | | |
261 | 282 | | |
262 | | - | |
| 283 | + | |
263 | 284 | | |
264 | 285 | | |
265 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
266 | 303 | | |
267 | 304 | | |
268 | 305 | | |
269 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
270 | 311 | | |
271 | 312 | | |
272 | 313 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
1356 | 1357 | | |
1357 | 1358 | | |
1358 | 1359 | | |
1359 | | - | |
1360 | | - | |
1361 | | - | |
1362 | | - | |
1363 | | - | |
1364 | | - | |
| 1360 | + | |
| 1361 | + | |
1365 | 1362 | | |
1366 | 1363 | | |
1367 | 1364 | | |
| |||
1671 | 1668 | | |
1672 | 1669 | | |
1673 | 1670 | | |
1674 | | - | |
1675 | | - | |
1676 | | - | |
1677 | | - | |
1678 | | - | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
1679 | 1693 | | |
1680 | 1694 | | |
1681 | 1695 | | |
1682 | 1696 | | |
1683 | 1697 | | |
1684 | 1698 | | |
1685 | | - | |
| 1699 | + | |
1686 | 1700 | | |
1687 | 1701 | | |
1688 | 1702 | | |
| |||
1758 | 1772 | | |
1759 | 1773 | | |
1760 | 1774 | | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
1761 | 1790 | | |
1762 | 1791 | | |
1763 | 1792 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
230 | 234 | | |
| 235 | + | |
231 | 236 | | |
232 | 237 | | |
233 | 238 | | |
| |||
236 | 241 | | |
237 | 242 | | |
238 | 243 | | |
239 | | - | |
240 | | - | |
| 244 | + | |
| 245 | + | |
241 | 246 | | |
242 | 247 | | |
243 | 248 | | |
| |||
0 commit comments