[SR-3164] Save previous swiftdeps files during a build #45752
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler itself
good first issue
Good for newcomers
legacy driver
Area → compiler: the integrated C++ legacy driver. Succeeded by the swift-driver project
Additional Detail from JIRA
md5: 39ac8470de717c1a23eb228c5bf25162
Issue Description:
The Swift compiler uses files with an extension of ".swiftdeps" to store information about cross-file dependencies within a single module, plus an extra "swiftdeps" file for the "build record" (information about the whole compilation). These files are read in at the start of compilation to compute a dependency graph, and updated (and re-read) as compilation proceeds. However, because these files are updated on every build, an issue with dependency analysis is hard to reproduce—the inputs have been lost.
A simple answer for this that will help in the common case is to move the previous swiftdeps file aside just before writing the new one. I'd suggest just renaming them from "foo.swiftdeps" to "foo.swiftdeps~". If this fails for any reason, just ignore the failure and continue on. (Maybe the directory isn't writable, only the one file. Maybe this is the first build. Maybe the user write-protected the previous "foo.swiftdeps~" for some reason.)
The LLVM APIs to mess with the filesystem are in "llvm/Support/FileSystem.h"; the one I'd expect to use is
llvm::sys::fs::rename
.The text was updated successfully, but these errors were encountered: