Skip to content

[SR-3164] Save previous swiftdeps files during a build #45752

@belkadan

Description

@belkadan
Previous ID SR-3164
Radar None
Original Reporter @belkadan
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Driver, StarterBug
Assignee @modocache
Priority Medium

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.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfgood first issueGood for newcomerslegacy driverArea → compiler: the integrated C++ legacy driver. Succeeded by the swift-driver project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions