Skip to content

Commit 6a35586

Browse files
committed
Set CARGO_CACHE_RUSTC_INFO=0 instead of removing .rustc_info.json.
1 parent 985cce7 commit 6a35586

File tree

1 file changed

+6
-14
lines changed
  • crates/spirv-builder/src

1 file changed

+6
-14
lines changed

crates/spirv-builder/src/lib.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -539,23 +539,15 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {
539539
// (or "default") `--target-dir`, to append `/spirv-builder` to it.
540540
let target_dir = outer_target_dir.map(|outer| outer.join("spirv-builder"));
541541
if let Some(target_dir) = target_dir {
542-
// HACK(eddyb) Cargo caches some information it got from `rustc` in
543-
// `.rustc_info.json`, and assumes it only depends on the `rustc`
544-
// binary, but in our case, `rustc_codegen_spirv` changes are also
545-
// relevant - so we remove the cache file if it may be out of date.
546-
let mtime = |path| std::fs::metadata(path)?.modified();
547-
let rustc_info = target_dir.join(".rustc_info.json");
548-
if let Ok(rustc_info_mtime) = mtime(&rustc_info) {
549-
if let Ok(rustc_codegen_spirv_mtime) = mtime(&rustc_codegen_spirv) {
550-
if rustc_codegen_spirv_mtime > rustc_info_mtime {
551-
let _ = std::fs::remove_file(rustc_info);
552-
}
553-
}
554-
}
555-
556542
cargo.arg("--target-dir").arg(target_dir);
557543
}
558544

545+
// NOTE(eddyb) Cargo caches some information it got from `rustc` in
546+
// `.rustc_info.json`, and assumes it only depends on the `rustc` binary,
547+
// but in our case, `rustc_codegen_spirv` changes are also relevant,
548+
// so we turn off that caching with an env var, just to avoid any issues.
549+
cargo.env("CARGO_CACHE_RUSTC_INFO", "0");
550+
559551
for (key, _) in env::vars_os() {
560552
let remove = key.to_str().map_or(false, |s| {
561553
s.starts_with("CARGO_FEATURES_") || s.starts_with("CARGO_CFG_")

0 commit comments

Comments
 (0)