aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/Compilation.cpp
diff options
context:
space:
mode:
authorJustin Lebar <jlebar@google.com>2016-02-24 21:49:28 +0000
committerJustin Lebar <jlebar@google.com>2016-02-24 21:49:28 +0000
commit8671c441c37bcd288b8a613a0fcd599daa005932 (patch)
tree9f69468755d1f3e78010a73d0ad03fb0417c5dfb /clang/lib/Driver/Compilation.cpp
parent0e41fa7666028ce54c04926168d015b3ab060f0b (diff)
downloadllvm-8671c441c37bcd288b8a613a0fcd599daa005932.zip
llvm-8671c441c37bcd288b8a613a0fcd599daa005932.tar.gz
llvm-8671c441c37bcd288b8a613a0fcd599daa005932.tar.bz2
Bail on compilation as soon as a job fails.
Summary: (Re-land of r260448, which was reverted in r260522 due to a test failure in Driver/output-file-cleanup.c that only showed up in fresh builds.) Previously we attempted to be smart; if one job failed, we'd run all jobs that didn't depend on the failing job. Problem is, this doesn't work well for e.g. CUDA compilation without -save-temps. In this case, the device-side and host-side Assemble actions (which actually are responsible for preprocess, compile, backend, and assemble, since we're not saving temps) are necessarily distinct. So our clever heuristic doesn't help us, and we repeat every error message once for host and once for each device arch. The main effect of this change, other than fixing CUDA, is that if you pass multiple cc files to one instance of clang and you get a compile error, we'll stop when the first cc1 job fails. Reviewers: echristo Subscribers: cfe-commits, jhen, echristo, tra, rafael Differential Revision: http://reviews.llvm.org/D17217 llvm-svn: 261774
Diffstat (limited to 'clang/lib/Driver/Compilation.cpp')
-rw-r--r--clang/lib/Driver/Compilation.cpp38
1 files changed, 8 insertions, 30 deletions
diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp
index 71bccfa..b24d381 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -163,39 +163,17 @@ int Compilation::ExecuteCommand(const Command &C,
return ExecutionFailed ? 1 : Res;
}
-typedef SmallVectorImpl< std::pair<int, const Command *> > FailingCommandList;
-
-static bool ActionFailed(const Action *A,
- const FailingCommandList &FailingCommands) {
-
- if (FailingCommands.empty())
- return false;
-
- for (FailingCommandList::const_iterator CI = FailingCommands.begin(),
- CE = FailingCommands.end(); CI != CE; ++CI)
- if (A == &(CI->second->getSource()))
- return true;
-
- for (const Action *AI : A->inputs())
- if (ActionFailed(AI, FailingCommands))
- return true;
-
- return false;
-}
-
-static bool InputsOk(const Command &C,
- const FailingCommandList &FailingCommands) {
- return !ActionFailed(&C.getSource(), FailingCommands);
-}
-
-void Compilation::ExecuteJobs(const JobList &Jobs,
- FailingCommandList &FailingCommands) const {
+void Compilation::ExecuteJobs(
+ const JobList &Jobs,
+ SmallVectorImpl<std::pair<int, const Command *>> &FailingCommands) const {
for (const auto &Job : Jobs) {
- if (!InputsOk(Job, FailingCommands))
- continue;
const Command *FailingCommand = nullptr;
- if (int Res = ExecuteCommand(Job, FailingCommand))
+ if (int Res = ExecuteCommand(Job, FailingCommand)) {
FailingCommands.push_back(std::make_pair(Res, FailingCommand));
+ // Bail as soon as one command fails, so we don't output duplicate error
+ // messages if we die on e.g. the same file.
+ return;
+ }
}
}