Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not cache rustc info in deps resolver #3107

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crate_universe/src/metadata/cargo_tree_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ impl TreeResolver {
// host triple instead of the host triple detected by rustc.
.env("RUSTC_WRAPPER", rustc_wrapper)
.env("HOST_TRIPLE", host_triple)
.env("CARGO_CACHE_RUSTC_INFO", "0")
.current_dir(manifest_path.parent().expect("All manifests should have a valid parent."))
.arg("tree")
.arg("--manifest-path")
Expand Down
22 changes: 15 additions & 7 deletions crate_universe/tests/cargo_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,24 @@ fn host_specific_build_deps() {
}

let r = runfiles::Runfiles::create().unwrap();

let src_cargo_toml = runfiles::rlocation!(
r,
"rules_rust/crate_universe/test_data/metadata/host_specific_build_deps/Cargo.toml"
)
.unwrap();

// Put Cargo.toml into writable directory structure and create target/ directory to verify that
// cargo does not incorrectly cache rustc info in target/.rustc_info.json file.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be an assert that this file was never created?

let scratch = tempfile::tempdir().unwrap();
let cargo_toml = scratch.path().join("Cargo.toml");
fs::copy(src_cargo_toml, &cargo_toml).unwrap();
fs::create_dir(scratch.path().join("target")).unwrap();

let metadata = run(
"host_specific_build_deps",
HashMap::from([(
runfiles::rlocation!(
r,
"rules_rust/crate_universe/test_data/metadata/host_specific_build_deps/Cargo.toml"
)
.unwrap()
.to_string_lossy()
.to_string(),
cargo_toml.to_string_lossy().to_string(),
"//:test_input".to_string(),
)]),
"rules_rust/crate_universe/test_data/metadata/host_specific_build_deps/Cargo.lock",
Expand Down
Loading