Skip to content

Commit 1877d76

Browse files
committed
Revert "[clang][deps] Split translation units into individual -cc1 or other commands"
Failing on some bots, reverting until I can fix it. This reverts commit f80a0ea.
1 parent 2fdf963 commit 1877d76

27 files changed

+207
-650
lines changed

clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,8 @@ struct FullDependencies {
4949
/// determined that the differences are benign for this compilation.
5050
std::vector<ModuleID> ClangModuleDeps;
5151

52-
/// The sequence of commands required to build the translation unit. Commands
53-
/// should be executed in order.
54-
///
55-
/// FIXME: If we add support for multi-arch builds in clang-scan-deps, we
56-
/// should make the dependencies between commands explicit to enable parallel
57-
/// builds of each architecture.
58-
std::vector<Command> Commands;
59-
60-
/// Deprecated driver command-line. This will be removed in a future version.
61-
std::vector<std::string> DriverCommandLine;
52+
/// The command line of the TU (excluding the compiler executable).
53+
std::vector<std::string> CommandLine;
6254
};
6355

6456
struct FullDependenciesResult {
@@ -107,12 +99,6 @@ class DependencyScanningTool {
10799
LookupModuleOutputCallback LookupModuleOutput,
108100
llvm::Optional<StringRef> ModuleName = None);
109101

110-
llvm::Expected<FullDependenciesResult> getFullDependenciesLegacyDriverCommand(
111-
const std::vector<std::string> &CommandLine, StringRef CWD,
112-
const llvm::StringSet<> &AlreadySeen,
113-
LookupModuleOutputCallback LookupModuleOutput,
114-
llvm::Optional<StringRef> ModuleName = None);
115-
116102
private:
117103
DependencyScanningWorker Worker;
118104
};
@@ -125,10 +111,6 @@ class FullDependencyConsumer : public DependencyConsumer {
125111
: AlreadySeen(AlreadySeen), LookupModuleOutput(LookupModuleOutput),
126112
EagerLoadModules(EagerLoadModules) {}
127113

128-
void handleBuildCommand(Command Cmd) override {
129-
Commands.push_back(std::move(Cmd));
130-
}
131-
132114
void handleDependencyOutputOpts(const DependencyOutputOptions &) override {}
133115

134116
void handleFileDependency(StringRef File) override {
@@ -152,17 +134,14 @@ class FullDependencyConsumer : public DependencyConsumer {
152134
return LookupModuleOutput(ID, Kind);
153135
}
154136

155-
FullDependenciesResult getFullDependenciesLegacyDriverCommand(
137+
FullDependenciesResult getFullDependencies(
156138
const std::vector<std::string> &OriginalCommandLine) const;
157139

158-
FullDependenciesResult takeFullDependencies();
159-
160140
private:
161141
std::vector<std::string> Dependencies;
162142
std::vector<PrebuiltModuleDep> PrebuiltModuleDeps;
163143
llvm::MapVector<std::string, ModuleDeps, llvm::StringMap<unsigned>>
164144
ClangModuleDeps;
165-
std::vector<Command> Commands;
166145
std::string ContextHash;
167146
std::vector<std::string> OutputPaths;
168147
const llvm::StringSet<> &AlreadySeen;

clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,10 @@ namespace dependencies {
2828

2929
class DependencyScanningWorkerFilesystem;
3030

31-
/// A command-line tool invocation that is part of building a TU.
32-
///
33-
/// \see FullDependencies::Commands.
34-
struct Command {
35-
std::string Executable;
36-
std::vector<std::string> Arguments;
37-
};
38-
3931
class DependencyConsumer {
4032
public:
4133
virtual ~DependencyConsumer() {}
4234

43-
virtual void handleBuildCommand(Command Cmd) = 0;
44-
4535
virtual void
4636
handleDependencyOutputOpts(const DependencyOutputOptions &Opts) = 0;
4737

clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,12 @@ class ModuleDepCollector final : public DependencyCollector {
181181
public:
182182
ModuleDepCollector(std::unique_ptr<DependencyOutputOptions> Opts,
183183
CompilerInstance &ScanInstance, DependencyConsumer &C,
184-
CompilerInvocation OriginalCI, bool OptimizeArgs,
184+
CompilerInvocation &&OriginalCI, bool OptimizeArgs,
185185
bool EagerLoadModules);
186186

187187
void attachToPreprocessor(Preprocessor &PP) override;
188188
void attachToASTReader(ASTReader &R) override;
189189

190-
/// Apply any changes implied by the discovered dependencies to the given
191-
/// invocation, (e.g. disable implicit modules, add explicit module paths).
192-
void applyDiscoveredDependencies(CompilerInvocation &CI);
193-
194190
private:
195191
friend ModuleDepCollectorPP;
196192

clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ llvm::Expected<std::string> DependencyScanningTool::getDependencyFile(
4545
/// Prints out all of the gathered dependencies into a string.
4646
class MakeDependencyPrinterConsumer : public DependencyConsumer {
4747
public:
48-
void handleBuildCommand(Command) override {}
49-
5048
void
5149
handleDependencyOutputOpts(const DependencyOutputOptions &Opts) override {
5250
this->Opts = std::make_unique<DependencyOutputOptions>(Opts);
@@ -122,74 +120,34 @@ DependencyScanningTool::getFullDependencies(
122120
Worker.computeDependencies(CWD, CommandLine, Consumer, ModuleName);
123121
if (Result)
124122
return std::move(Result);
125-
return Consumer.takeFullDependencies();
126-
}
127-
128-
llvm::Expected<FullDependenciesResult>
129-
DependencyScanningTool::getFullDependenciesLegacyDriverCommand(
130-
const std::vector<std::string> &CommandLine, StringRef CWD,
131-
const llvm::StringSet<> &AlreadySeen,
132-
LookupModuleOutputCallback LookupModuleOutput,
133-
llvm::Optional<StringRef> ModuleName) {
134-
FullDependencyConsumer Consumer(AlreadySeen, LookupModuleOutput,
135-
Worker.shouldEagerLoadModules());
136-
llvm::Error Result =
137-
Worker.computeDependencies(CWD, CommandLine, Consumer, ModuleName);
138-
if (Result)
139-
return std::move(Result);
140-
return Consumer.getFullDependenciesLegacyDriverCommand(CommandLine);
141-
}
142-
143-
FullDependenciesResult FullDependencyConsumer::takeFullDependencies() {
144-
FullDependenciesResult FDR;
145-
FullDependencies &FD = FDR.FullDeps;
146-
147-
FD.ID.ContextHash = std::move(ContextHash);
148-
FD.FileDeps = std::move(Dependencies);
149-
FD.PrebuiltModuleDeps = std::move(PrebuiltModuleDeps);
150-
FD.Commands = std::move(Commands);
151-
152-
for (auto &&M : ClangModuleDeps) {
153-
auto &MD = M.second;
154-
if (MD.ImportedByMainFile)
155-
FD.ClangModuleDeps.push_back(MD.ID);
156-
// TODO: Avoid handleModuleDependency even being called for modules
157-
// we've already seen.
158-
if (AlreadySeen.count(M.first))
159-
continue;
160-
FDR.DiscoveredModules.push_back(std::move(MD));
161-
}
162-
163-
return FDR;
123+
return Consumer.getFullDependencies(CommandLine);
164124
}
165125

166-
FullDependenciesResult
167-
FullDependencyConsumer::getFullDependenciesLegacyDriverCommand(
126+
FullDependenciesResult FullDependencyConsumer::getFullDependencies(
168127
const std::vector<std::string> &OriginalCommandLine) const {
169128
FullDependencies FD;
170129

171-
FD.DriverCommandLine = makeTUCommandLineWithoutPaths(
130+
FD.CommandLine = makeTUCommandLineWithoutPaths(
172131
ArrayRef<std::string>(OriginalCommandLine).slice(1));
173132

174133
FD.ID.ContextHash = std::move(ContextHash);
175134

176135
FD.FileDeps.assign(Dependencies.begin(), Dependencies.end());
177136

178137
for (const PrebuiltModuleDep &PMD : PrebuiltModuleDeps)
179-
FD.DriverCommandLine.push_back("-fmodule-file=" + PMD.PCMFile);
138+
FD.CommandLine.push_back("-fmodule-file=" + PMD.PCMFile);
180139

181140
for (auto &&M : ClangModuleDeps) {
182141
auto &MD = M.second;
183142
if (MD.ImportedByMainFile) {
184143
FD.ClangModuleDeps.push_back(MD.ID);
185144
auto PCMPath = LookupModuleOutput(MD.ID, ModuleOutputKind::ModuleFile);
186145
if (EagerLoadModules) {
187-
FD.DriverCommandLine.push_back("-fmodule-file=" + PCMPath);
146+
FD.CommandLine.push_back("-fmodule-file=" + PCMPath);
188147
} else {
189-
FD.DriverCommandLine.push_back("-fmodule-map-file=" +
190-
MD.ClangModuleMapFile);
191-
FD.DriverCommandLine.push_back("-fmodule-file=" + MD.ID.ModuleName +
192-
"=" + PCMPath);
148+
FD.CommandLine.push_back("-fmodule-map-file=" + MD.ClangModuleMapFile);
149+
FD.CommandLine.push_back("-fmodule-file=" + MD.ID.ModuleName + "=" +
150+
PCMPath);
193151
}
194152
}
195153
}

0 commit comments

Comments
 (0)