Swift/Ninja: Set copy-if-different on output-file-map.json

Avoid bumping the file's mtime on every configure when its content
hasn't changed.  Otherwise ninja sees it as modified and re-runs every
Swift compile edge that depends on it.

Observed in the Swift toolchain build (LLVM monorepo with swift as an
external project): a no-op reconfigure cascaded into hundreds of
unnecessary edges via per-target output-file-map.json mtime bumps.

Issue: #27748
This commit is contained in:
Roman Lavrov
2026-04-29 09:19:48 -04:00
parent bd40a31c51
commit feb5275c7a
+1
View File
@@ -1438,6 +1438,7 @@ void cmNinjaTargetGenerator::GenerateSwiftOutputFileMap(
this->Configs[config].SwiftOutputMap[""] = deps;
cmGeneratedFileStream output(mapFilePath);
output.SetCopyIfDifferent(true);
output << this->Configs[config].SwiftOutputMap;
// Add flag