Skip to content

Commit 7535426

Browse files
committed
WIP: implement the fix described in the previous commit message
1 parent 005763e commit 7535426

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/compiler/compiler.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,27 @@ where
503503
stdout: entry.get_stdout(),
504504
stderr: entry.get_stderr(),
505505
};
506+
507+
let filtered_outputs =
508+
if compilation.is_preprocessed_for_distribution() { // TODO probably rename that getter
509+
// In this mode, cache entries are exclusively distinguished by their preprocessed
510+
// source contents. But two files may differ in their names and /or the names of
511+
// included files while still producing the same preprocessed output, so they get
512+
// the same cache entry. That entry will have the names of dependencies wrong for
513+
// at least one of the source files that produced it.
514+
// Since we did local preprocessing, that should already have produced the dependency
515+
// file - just leave that one alone and don't overwrite it from the cache.
516+
outputs.iter().filter(|fobj_source| fobj_source.key != "d").cloned().collect()
517+
} else {
518+
// In this mode, no local preprocessing was done, so the dependency file (if any)
519+
// has not been created. But in this mode, the cache key also includes a lot of
520+
// information about filenames (and less relevant here, file hashes), so it *is* safe
521+
// to restore the dependency file from the cache.
522+
outputs.clone()
523+
};
524+
506525
let hit = CompileResult::CacheHit(duration);
507-
match entry.extract_objects(outputs.clone(), &pool).await {
526+
match entry.extract_objects(filtered_outputs, &pool).await {
508527
Ok(()) => Ok(CacheLookupResult::Success(hit, output)),
509528
Err(e) => {
510529
if e.downcast_ref::<DecompressionFailure>().is_some() {

0 commit comments

Comments
 (0)