Commit 834df35
authored
Do not cache rustc info in deps resolver (#3107)
The cargo_tree_resolver discovers dependencies by executing `cargo tree`
for different host and target triples. This procedure breaks when cargo
successfully but incorrectly caches rustc info. Incorrect cache hit may
happen because cache key does not take into account HOST_TRIPLE env
variable used by `rules_rust` to force rustc to report it's built for
different host.
The caching may happen if one has target/ directory in repo, or it was
created through running some commands outside of bazel.
# Details
- After recent fixes to support properly bzlmod
(#3034) noticed issues
under windows when building bazel-lsp:
cameron-martin/bazel-lsp#92
- Cargo may cache rustc info in target/.rustc_info.json :
https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L163
- The rules_rust hacks rustc by setting HOST_TRIPLE:
https://github.com/bazelbuild/rules_rust/blob/3aecdbedba0c001d0660ff631aeccb35d94ff3a7/crate_universe/src/metadata/cargo_tree_resolver.rs#L152
- The HOST_TRIPLE env variable is not taken into account by cargo when
checking whether cached rustc info is valid:
https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L3201 parent fae114c commit 834df35
File tree
2 files changed
+16
-7
lines changed- crate_universe
- src/metadata
- tests
2 files changed
+16
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
529 | 543 | | |
530 | 544 | | |
531 | 545 | | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
| 546 | + | |
539 | 547 | | |
540 | 548 | | |
541 | 549 | | |
| |||
0 commit comments