Skip to content

Commit 4022d52

Browse files
author
Justin Lebar
committedFeb 10, 2016
Bail on compilation as soon as a job fails.
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: tra, echristo Subscribers: jhen, cfe-commits Differential Revision: http://reviews.llvm.org/D16514 llvm-svn: 260448
1 parent 936db8f commit 4022d52

File tree

1 file changed

+8
-30
lines changed

1 file changed

+8
-30
lines changed
 

‎clang/lib/Driver/Compilation.cpp

+8-30
Original file line numberDiff line numberDiff line change
@@ -163,39 +163,17 @@ int Compilation::ExecuteCommand(const Command &C,
163163
return ExecutionFailed ? 1 : Res;
164164
}
165165

166-
typedef SmallVectorImpl< std::pair<int, const Command *> > FailingCommandList;
167-
168-
static bool ActionFailed(const Action *A,
169-
const FailingCommandList &FailingCommands) {
170-
171-
if (FailingCommands.empty())
172-
return false;
173-
174-
for (FailingCommandList::const_iterator CI = FailingCommands.begin(),
175-
CE = FailingCommands.end(); CI != CE; ++CI)
176-
if (A == &(CI->second->getSource()))
177-
return true;
178-
179-
for (Action::const_iterator AI = A->begin(), AE = A->end(); AI != AE; ++AI)
180-
if (ActionFailed(*AI, FailingCommands))
181-
return true;
182-
183-
return false;
184-
}
185-
186-
static bool InputsOk(const Command &C,
187-
const FailingCommandList &FailingCommands) {
188-
return !ActionFailed(&C.getSource(), FailingCommands);
189-
}
190-
191-
void Compilation::ExecuteJobs(const JobList &Jobs,
192-
FailingCommandList &FailingCommands) const {
166+
void Compilation::ExecuteJobs(
167+
const JobList &Jobs,
168+
SmallVectorImpl<std::pair<int, const Command *>> &FailingCommands) const {
193169
for (const auto &Job : Jobs) {
194-
if (!InputsOk(Job, FailingCommands))
195-
continue;
196170
const Command *FailingCommand = nullptr;
197-
if (int Res = ExecuteCommand(Job, FailingCommand))
171+
if (int Res = ExecuteCommand(Job, FailingCommand)) {
198172
FailingCommands.push_back(std::make_pair(Res, FailingCommand));
173+
// Bail as soon as one command fails, so we don't output duplicate error
174+
// messages if we die on e.g. the same file.
175+
return;
176+
}
199177
}
200178
}
201179

0 commit comments

Comments
 (0)