@@ -503,8 +503,27 @@ where
503
503
stdout : entry. get_stdout ( ) ,
504
504
stderr : entry. get_stderr ( ) ,
505
505
} ;
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
+
506
525
let hit = CompileResult :: CacheHit ( duration) ;
507
- match entry. extract_objects ( outputs . clone ( ) , & pool) . await {
526
+ match entry. extract_objects ( filtered_outputs , & pool) . await {
508
527
Ok ( ( ) ) => Ok ( CacheLookupResult :: Success ( hit, output) ) ,
509
528
Err ( e) => {
510
529
if e. downcast_ref :: < DecompressionFailure > ( ) . is_some ( ) {
0 commit comments