@@ -918,9 +918,6 @@ namespace driver {
918
918
for (const auto cmd :
919
919
collectExternallyDependentJobsFromDependencyGraph ())
920
920
jobsToSchedule.insert (cmd);
921
- for (const auto cmd :
922
- collectIncrementalExternallyDependentJobsFromDependencyGraph ())
923
- jobsToSchedule.insert (cmd);
924
921
925
922
// The merge-modules job is special: it *must* be scheduled if any other
926
923
// job has been scheduled because any other job can influence the
@@ -1073,103 +1070,6 @@ namespace driver {
1073
1070
return ExternallyDependentJobs;
1074
1071
}
1075
1072
1076
- using ChangeSet = fine_grained_dependencies::ModuleDepGraph::Changes::value_type;
1077
- static void
1078
- pruneChangeSetFromExternalDependency (ChangeSet &changes) {
1079
- // The changeset includes detritus from the graph that gets consed up
1080
- // in \c writePriorDependencyGraph. We need to ignore the fake
1081
- // source file provides nodes and the fake incremental external
1082
- // dependencies linked to them.
1083
- swift::erase_if (
1084
- changes, [&](fine_grained_dependencies::ModuleDepGraphNode *node) {
1085
- if (node->getKey ().getKind () ==
1086
- fine_grained_dependencies::NodeKind::sourceFileProvide ||
1087
- node->getKey ().getKind () ==
1088
- fine_grained_dependencies::NodeKind::
1089
- incrementalExternalDepend) {
1090
- return true ;
1091
- }
1092
- if (node->getKey ().getAspect () ==
1093
- fine_grained_dependencies::DeclAspect::implementation) {
1094
- return true ;
1095
- }
1096
- return !node->getIsProvides ();
1097
- });
1098
- }
1099
-
1100
- SmallVector<const Job *, 16 >
1101
- collectIncrementalExternallyDependentJobsFromDependencyGraph () {
1102
- SmallVector<const Job *, 16 > ExternallyDependentJobs;
1103
- auto fallbackToExternalBehavior = [&](StringRef external) {
1104
- for (const auto cmd :
1105
- markIncrementalExternalInDepGraph (external)) {
1106
- ExternallyDependentJobs.push_back (cmd);
1107
- }
1108
- };
1109
-
1110
- for (auto external : getFineGrainedDepGraph ()
1111
- .getIncrementalExternalDependencies ()) {
1112
- llvm::sys::fs::file_status depStatus;
1113
- // Can't `stat` this dependency? Treat it as a plain external
1114
- // dependency and drop schedule all of its consuming jobs to run.
1115
- if (llvm::sys::fs::status (external, depStatus)) {
1116
- fallbackToExternalBehavior (external);
1117
- continue ;
1118
- }
1119
-
1120
- // Is this module out of date? If not, just keep searching.
1121
- if (Comp.getLastBuildTime () >= depStatus.getLastModificationTime ())
1122
- continue ;
1123
-
1124
- // Can we run a cross-module incremental build at all?
1125
- // If not, fall back.
1126
- if (!Comp.getEnableCrossModuleIncrementalBuild ()) {
1127
- fallbackToExternalBehavior (external);
1128
- continue ;
1129
- }
1130
-
1131
- // If loading the buffer fails, the user may have deleted this external
1132
- // dependency or it could have become corrupted. We need to
1133
- // pessimistically schedule a rebuild to get dependent jobs to drop
1134
- // this dependency from their swiftdeps files if possible.
1135
- auto buffer = llvm::MemoryBuffer::getFile (external);
1136
- if (!buffer) {
1137
- fallbackToExternalBehavior (external);
1138
- continue ;
1139
- }
1140
-
1141
- // Cons up a fake `Job` to satisfy the incremental job tracing
1142
- // code's internal invariants.
1143
- const auto *externalJob = Comp.addExternalJob (
1144
- std::make_unique<Job>(Comp.getDerivedOutputFileMap (), external));
1145
- auto maybeChanges =
1146
- getFineGrainedDepGraph ().loadFromSwiftModuleBuffer (
1147
- externalJob, *buffer.get (), Comp.getDiags ());
1148
-
1149
- // If the incremental dependency graph failed to load, fall back to
1150
- // treating this as plain external job.
1151
- if (!maybeChanges.hasValue ()) {
1152
- fallbackToExternalBehavior (external);
1153
- continue ;
1154
- }
1155
-
1156
- // Prune away the detritus from the build record.
1157
- auto &changes = maybeChanges.getValue ();
1158
- pruneChangeSetFromExternalDependency (changes);
1159
-
1160
- for (auto *CMD : getFineGrainedDepGraph ()
1161
- .findJobsToRecompileWhenNodesChange (changes)) {
1162
- if (CMD == externalJob) {
1163
- continue ;
1164
- }
1165
- ExternallyDependentJobs.push_back (CMD);
1166
- }
1167
- }
1168
- noteBuildingJobs (ExternallyDependentJobs,
1169
- " because of incremental external dependencies" );
1170
- return ExternallyDependentJobs;
1171
- }
1172
-
1173
1073
// / Insert all jobs in \p Cmds (of descriptive name \p Kind) to the \c
1174
1074
// / TaskQueue, and clear \p Cmds.
1175
1075
template <typename Container>
@@ -1628,24 +1528,12 @@ namespace driver {
1628
1528
return getFineGrainedDepGraph ().getExternalDependencies ();
1629
1529
}
1630
1530
1631
- std::vector<StringRef>
1632
- getIncrementalExternalDependencies () const {
1633
- return getFineGrainedDepGraph ()
1634
- .getIncrementalExternalDependencies ();
1635
- }
1636
-
1637
1531
std::vector<const Job*>
1638
1532
markExternalInDepGraph (StringRef externalDependency) {
1639
1533
return getFineGrainedDepGraph ()
1640
1534
.findExternallyDependentUntracedJobs (externalDependency);
1641
1535
}
1642
1536
1643
- std::vector<const Job *>
1644
- markIncrementalExternalInDepGraph (StringRef externalDependency) {
1645
- return getFineGrainedDepGraph ()
1646
- .findIncrementalExternallyDependentUntracedJobs (externalDependency);
1647
- }
1648
-
1649
1537
std::vector<const Job *> findJobsToRecompileWhenWholeJobChanges (const Job *Cmd) {
1650
1538
return getFineGrainedDepGraph ()
1651
1539
.findJobsToRecompileWhenWholeJobChanges (Cmd);
@@ -1771,76 +1659,6 @@ static void writeCompilationRecord(StringRef path, StringRef argsHash,
1771
1659
}
1772
1660
}
1773
1661
1774
- using SourceFileDepGraph = swift::fine_grained_dependencies::SourceFileDepGraph;
1775
-
1776
- // / Render out the unified module dependency graph to the given \p path, which
1777
- // / is expected to be a path relative to the build record.
1778
- static void withPriorDependencyGraph (StringRef path,
1779
- const Compilation::Result &result,
1780
- llvm::function_ref<void (SourceFileDepGraph &&)> cont) {
1781
- // Building a source file dependency graph from the module dependency graph
1782
- // is a strange task on its face because a source file dependency graph is
1783
- // usually built for exactly one file. However, the driver is going to use
1784
- // some encoding tricks to get the dependencies for each incremental external
1785
- // dependency into one big file. Note that these tricks
1786
- // are undone in \c pruneChangeSetFromExternalDependency, so if you modify
1787
- // this you need to go fix that algorithm up as well. This is a diagrammatic
1788
- // view of the structure of the dependencies this function builds:
1789
- //
1790
- // SourceFile => interface <BUILD_RECORD>.external
1791
- // | - Incremetal External Dependency => interface <MODULE_1>.swiftmodule
1792
- // | | - <dependency> ...
1793
- // | | - <dependency> ...
1794
- // | | - <dependency> ...
1795
- // | - Incremetal External Dependency => interface <MODULE_2>.swiftmodule
1796
- // | | - <dependency> ...
1797
- // | | - <dependency> ...
1798
- // | - Incremetal External Dependency => interface <MODULE_3>.swiftmodule
1799
- // | - ...
1800
- //
1801
- // Where each <dependency> node has an arc back to its parent swiftmodule.
1802
- // That swiftmodule, in turn, takes the form of as an incremental external
1803
- // dependency. This formulation allows us to easily discern the original
1804
- // swiftmodule that a <dependency> came from just by examining that arc. This
1805
- // is used in integrate to "move" the <dependency> from the build record to
1806
- // the swiftmodule by swapping the key it uses.
1807
- using namespace swift ::fine_grained_dependencies;
1808
- SourceFileDepGraph g;
1809
- const auto &resultModuleGraph = result.depGraph ;
1810
- // Create the key for the entire external build record.
1811
- auto fileKey =
1812
- DependencyKey::createKeyForWholeSourceFile (DeclAspect::interface, path);
1813
- auto fileNodePair = g.findExistingNodePairOrCreateAndAddIfNew (fileKey, None);
1814
- for (StringRef incrExternalDep :
1815
- resultModuleGraph.getIncrementalExternalDependencies ()) {
1816
- // Now make a node for each incremental external dependency.
1817
- auto interfaceKey =
1818
- DependencyKey (NodeKind::incrementalExternalDepend,
1819
- DeclAspect::interface, " " , incrExternalDep.str ());
1820
- auto ifaceNode = g.findExistingNodeOrCreateIfNew (interfaceKey, None,
1821
- false /* = !isProvides */ );
1822
- resultModuleGraph.forEachNodeInJob (incrExternalDep, [&](const auto *node) {
1823
- // Reject
1824
- // 1) Implementation nodes: We don't care about the interface nodes
1825
- // for cross-module dependencies because the client cannot observe it
1826
- // by definition.
1827
- // 2) Source file nodes: we're about to define our own.
1828
- if (!node->getKey ().isInterface () ||
1829
- node->getKey ().getKind () == NodeKind::sourceFileProvide) {
1830
- return ;
1831
- }
1832
- assert (node->getIsProvides () &&
1833
- " Found a node in module depdendencies that is not a provides!" );
1834
- auto *newNode = new SourceFileDepGraphNode (
1835
- node->getKey (), node->getFingerprint (), /* isProvides*/ true );
1836
- g.addNode (newNode);
1837
- g.addArc (ifaceNode, newNode);
1838
- });
1839
- g.addArc (fileNodePair.getInterface (), ifaceNode);
1840
- }
1841
- return cont (std::move (g));
1842
- }
1843
-
1844
1662
static void writeInputJobsToFilelist (llvm::raw_fd_ostream &out, const Job *job,
1845
1663
const file_types::ID infoType) {
1846
1664
// FIXME: Duplicated from ToolChains.cpp.
@@ -1937,22 +1755,10 @@ Compilation::performJobsImpl(std::unique_ptr<TaskQueue> &&TQ) {
1937
1755
State.populateInputInfoMap (InputInfo);
1938
1756
checkForOutOfDateInputs (Diags, InputInfo);
1939
1757
1940
- auto result = std::move (State).takeResult ();
1941
1758
writeCompilationRecord (CompilationRecordPath, ArgsHash, BuildStartTime,
1942
1759
InputInfo);
1943
- if (EnableCrossModuleIncrementalBuild) {
1944
- // Write out our priors adjacent to the build record so we can pick
1945
- // the up in a subsequent build.
1946
- withPriorDependencyGraph (getExternalSwiftDepsFilePath (), result,
1947
- [&](SourceFileDepGraph &&g) {
1948
- writeFineGrainedDependencyGraphToPath (
1949
- Diags, getExternalSwiftDepsFilePath (), g);
1950
- });
1951
- }
1952
- return result;
1953
- } else {
1954
- return std::move (State).takeResult ();
1955
1760
}
1761
+ return std::move (State).takeResult ();
1956
1762
}
1957
1763
1958
1764
Compilation::Result Compilation::performSingleCommand (const Job *Cmd) {
0 commit comments