Skip to content

Commit e52028a

Browse files
committed
fix: revert cxx_scan restat (P2) — broke self-host smoke test
The $out.tmp + cmp -s approach for content-stable .ddi writes caused linker failures in the CI self-host smoke step. GCC's -fdeps-file= interacts with ninja's depfile tracking in ways that make the temp-file approach fragile. Revert to direct -fdeps-file=$out for now. P1 (fingerprint coherence) and P1.5 (diagnostic warning) are retained. P2 needs a different approach — possibly ninja's built-in restat alone without temp-file wrappers.
1 parent ded76aa commit e52028a

1 file changed

Lines changed: 4 additions & 19 deletions

File tree

src/build/ninja_backend.cppm

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -243,36 +243,21 @@ std::string emit_ninja_string(const BuildPlan& plan) {
243243

244244
if (dyndep) {
245245
// Scan rule: produce P1689 .ddi for one TU.
246-
// P2: write to $out.tmp first, then compare with existing $out.
247-
// If content is identical, keep old $out (preserving mtime) so
248-
// downstream dyndep/compile edges are not marked dirty.
249-
// restat = 1 tells Ninja to check if $out actually changed.
250246
// GCC: built-in -fdeps-format=p1689r5 flags during preprocessing.
251247
// Clang: external clang-scan-deps tool with -format=p1689.
252248
append("rule cxx_scan\n");
253249
if (plan.scanDepsPath.empty()) {
254250
// GCC path: compiler-integrated P1689 scanning.
255251
append(" command = $toolenv $cxx $cxxflags -fmodules "
256252
"-fdeps-format=p1689r5 "
257-
"-fdeps-file=$out.tmp -fdeps-target=$compile_target "
258-
"-M -MM -MF $out.dep -E $in -o $compile_target && "
259-
"if [ -f \"$out\" ] && cmp -s \"$out.tmp\" \"$out\"; then "
260-
"rm -f \"$out.tmp\"; "
261-
"else "
262-
"mv -f \"$out.tmp\" \"$out\"; "
263-
"fi\n");
253+
"-fdeps-file=$out -fdeps-target=$compile_target "
254+
"-M -MM -MF $out.dep -E $in -o $compile_target\n");
264255
} else {
265256
// Clang path: clang-scan-deps produces P1689 JSON to stdout.
266257
append(" command = $toolenv $scan_deps -format=p1689 -- "
267-
"$cxx $cxxflags -c $in -o $compile_target > $out.tmp && "
268-
"if [ -f \"$out\" ] && cmp -s \"$out.tmp\" \"$out\"; then "
269-
"rm -f \"$out.tmp\"; "
270-
"else "
271-
"mv -f \"$out.tmp\" \"$out\"; "
272-
"fi\n");
258+
"$cxx $cxxflags -c $in -o $compile_target > $out\n");
273259
}
274-
append(" description = SCAN $out\n");
275-
append(" restat = 1\n\n");
260+
append(" description = SCAN $out\n\n");
276261

277262
// Aggregate .ddi files into a Ninja dyndep file.
278263
append(std::format(

0 commit comments

Comments
 (0)