Skip to content

Commit 005763e

Browse files
committed
Partially revert "Don't cache dep file (#2322)"
This reverts the "main" code changes of commit c0a0b6e but keeps the added test. A better fix will work as follows: - Always store the dep file in the cache - In non-preprocessor cache mode, which doesn't consider things like file name and included file names, so it can confuse cache entries with same preprocessed content but different dep files: do not restore the dep file. It is not necessary anyway because local preprocessing will produce the file. - In preprocessor cache mode, which uses input file names and hashes to distinguish cache entries, but does not run the preprocessor: *do* restore the dep file.
1 parent 55a1a6f commit 005763e

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

src/compiler/gcc.rs

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ where
290290
let mut language_extensions = true; // by default, GCC allows extensions
291291
let mut split_dwarf = false;
292292
let mut need_explicit_dep_target = false;
293+
let mut dep_path = None;
293294
enum DepArgumentRequirePath {
294295
NotNeeded,
295296
Missing,
@@ -381,8 +382,9 @@ where
381382
dep_flag = OsString::from(arg.flag_str().expect("Dep target flag expected"));
382383
dep_target = Some(s.clone());
383384
}
384-
Some(DepArgumentPath(_)) => {
385+
Some(DepArgumentPath(path)) => {
385386
need_explicit_dep_argument_path = DepArgumentRequirePath::Provided;
387+
dep_path = Some(path.clone());
386388
}
387389
Some(SerializeDiagnostics(path)) => {
388390
serialize_diagnostics = Some(path.clone());
@@ -642,6 +644,16 @@ where
642644
dependency_args.push(Path::new(&output).with_extension("d").into_os_string());
643645
}
644646

647+
if let Some(path) = dep_path {
648+
outputs.insert(
649+
"d",
650+
ArtifactDescriptor {
651+
path: path.clone(),
652+
optional: false,
653+
},
654+
);
655+
}
656+
645657
if let Some(path) = serialize_diagnostics {
646658
outputs.insert(
647659
"dia",
@@ -1450,6 +1462,13 @@ mod test {
14501462
path: "foo.o".into(),
14511463
optional: false
14521464
}
1465+
),
1466+
(
1467+
"d",
1468+
ArtifactDescriptor {
1469+
path: "foo.o.d".into(),
1470+
optional: false
1471+
}
14531472
)
14541473
);
14551474
assert_eq!(ovec!["-MF", "foo.o.d"], dependency_args);
@@ -1543,6 +1562,13 @@ mod test {
15431562
path: "foo.o".into(),
15441563
optional: false
15451564
}
1565+
),
1566+
(
1567+
"d",
1568+
ArtifactDescriptor {
1569+
path: "foo.o.d".into(),
1570+
optional: false
1571+
}
15461572
)
15471573
);
15481574
assert_eq!(ovec!["-MF", "foo.o.d"], dependency_args);
@@ -1578,6 +1604,13 @@ mod test {
15781604
path: "foo.o".into(),
15791605
optional: false
15801606
}
1607+
),
1608+
(
1609+
"d",
1610+
ArtifactDescriptor {
1611+
path: "foo.o.d".into(),
1612+
optional: false
1613+
}
15811614
)
15821615
);
15831616
assert_eq!(
@@ -1617,6 +1650,13 @@ mod test {
16171650
path: "foo.o".into(),
16181651
optional: false
16191652
}
1653+
),
1654+
(
1655+
"d",
1656+
ArtifactDescriptor {
1657+
path: "foo.o.d".into(),
1658+
optional: false
1659+
}
16201660
)
16211661
);
16221662
assert_eq!(
@@ -1857,6 +1897,13 @@ mod test {
18571897
path: "foo.o".into(),
18581898
optional: false
18591899
}
1900+
),
1901+
(
1902+
"d",
1903+
ArtifactDescriptor {
1904+
path: "foo.o.d".into(),
1905+
optional: false
1906+
}
18601907
)
18611908
);
18621909
assert_eq!(

src/compiler/nvcc.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,6 +1809,13 @@ mod test {
18091809
path: "foo.o".into(),
18101810
optional: false
18111811
}
1812+
),
1813+
(
1814+
"d",
1815+
ArtifactDescriptor {
1816+
path: "foo.o.d".into(),
1817+
optional: false
1818+
}
18121819
)
18131820
);
18141821
assert_eq!(

src/compiler/nvhpc.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,13 @@ mod test {
352352
path: "foo.o".into(),
353353
optional: false
354354
}
355+
),
356+
(
357+
"d",
358+
ArtifactDescriptor {
359+
path: "foo.o.d".into(),
360+
optional: false
361+
}
355362
)
356363
);
357364
assert_eq!(

0 commit comments

Comments
 (0)