Skip to content

Commit 7981714

Browse files
committed
[BatchMode] Make driver report exits per-batch, not per-constituent.
1 parent 204e517 commit 7981714

File tree

1 file changed

+20
-47
lines changed

1 file changed

+20
-47
lines changed

lib/Driver/Compilation.cpp

Lines changed: 20 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ namespace driver {
419419
/// TaskFinishedResponse::ContinueExecution from any of the constituent
420420
/// calls.
421421
TaskFinishedResponse
422-
unpackAndFinishBatch(ProcessId Pid, int ReturnCode, StringRef Output,
422+
unpackAndFinishBatch(int ReturnCode, StringRef Output,
423423
StringRef Errors, const BatchJob *B) {
424424
if (Comp.ShowJobLifecycle)
425425
llvm::outs() << "Batch job finished: " << LogJob(B) << "\n";
@@ -428,7 +428,8 @@ namespace driver {
428428
if (Comp.ShowJobLifecycle)
429429
llvm::outs() << " ==> Unpacked batch constituent finished: "
430430
<< LogJob(J) << "\n";
431-
auto r = taskFinished(Pid, ReturnCode, Output, Errors, (void *)J);
431+
auto r = taskFinished(llvm::sys::ProcessInfo::InvalidPid, ReturnCode, Output,
432+
Errors, (void *)J);
432433
if (r != TaskFinishedResponse::ContinueExecution)
433434
res = r;
434435
}
@@ -443,26 +444,29 @@ namespace driver {
443444
StringRef Errors, void *Context) {
444445
const Job *FinishedCmd = (const Job *)Context;
445446

446-
if (Comp.ShowDriverTimeCompilation) {
447-
DriverTimers[FinishedCmd]->stopTimer();
447+
if (Pid != llvm::sys::ProcessInfo::InvalidPid) {
448+
449+
if (Comp.ShowDriverTimeCompilation) {
450+
DriverTimers[FinishedCmd]->stopTimer();
451+
}
452+
453+
if (Comp.Level == OutputLevel::Parseable) {
454+
// Parseable output was requested.
455+
parseable_output::emitFinishedMessage(llvm::errs(), *FinishedCmd, Pid,
456+
ReturnCode, Output);
457+
} else {
458+
// Otherwise, send the buffered output to stderr, though only if we
459+
// support getting buffered output.
460+
if (TaskQueue::supportsBufferingOutput())
461+
llvm::errs() << Output;
462+
}
448463
}
449464

450465
if (BatchJobs.count(FinishedCmd) != 0) {
451-
return unpackAndFinishBatch(Pid, ReturnCode, Output, Errors,
466+
return unpackAndFinishBatch(ReturnCode, Output, Errors,
452467
static_cast<const BatchJob *>(FinishedCmd));
453468
}
454469

455-
if (Comp.Level == OutputLevel::Parseable) {
456-
// Parseable output was requested.
457-
parseable_output::emitFinishedMessage(llvm::errs(), *FinishedCmd, Pid,
458-
ReturnCode, Output);
459-
} else {
460-
// Otherwise, send the buffered output to stderr, though only if we
461-
// support getting buffered output.
462-
if (TaskQueue::supportsBufferingOutput())
463-
llvm::errs() << Output;
464-
}
465-
466470
// In order to handle both old dependencies that have disappeared and new
467471
// dependencies that have arisen, we need to reload the dependency file.
468472
// Do this whether or not the build succeeded.
@@ -505,30 +509,6 @@ namespace driver {
505509
return TaskFinishedResponse::ContinueExecution;
506510
}
507511

508-
/// Unpack a \c BatchJob that has finished into its constituent \c Job
509-
/// members, and call \c taskSignalled on each, propagating any \c
510-
/// TaskFinishedResponse other than \c
511-
/// TaskFinishedResponse::ContinueExecution from any of the constituent
512-
/// calls.
513-
TaskFinishedResponse
514-
unpackAndSignalBatch(ProcessId Pid, StringRef ErrorMsg, StringRef Output,
515-
StringRef Errors, const BatchJob *B,
516-
Optional<int> Signal) {
517-
if (Comp.ShowJobLifecycle)
518-
llvm::outs() << "Batch job signalled: " << LogJob(B) << "\n";
519-
auto res = TaskFinishedResponse::ContinueExecution;
520-
for (const Job *J : B->getCombinedJobs()) {
521-
if (Comp.ShowJobLifecycle)
522-
llvm::outs() << " ==> Unpacked batch constituent signalled: "
523-
<< LogJob(J) << "\n";
524-
auto r = taskSignalled(Pid, ErrorMsg, Output, Errors,
525-
(void *)J, Signal);
526-
if (r != TaskFinishedResponse::ContinueExecution)
527-
res = r;
528-
}
529-
return res;
530-
}
531-
532512
TaskFinishedResponse
533513
taskSignalled(ProcessId Pid, StringRef ErrorMsg, StringRef Output,
534514
StringRef Errors, void *Context, Optional<int> Signal) {
@@ -538,12 +518,6 @@ namespace driver {
538518
DriverTimers[SignalledCmd]->stopTimer();
539519
}
540520

541-
if (BatchJobs.count(SignalledCmd) != 0) {
542-
return unpackAndSignalBatch(Pid, ErrorMsg, Output, Errors,
543-
static_cast<const BatchJob *>(SignalledCmd),
544-
Signal);
545-
}
546-
547521
if (Comp.Level == OutputLevel::Parseable) {
548522
// Parseable output was requested.
549523
parseable_output::emitSignalledMessage(llvm::errs(), *SignalledCmd,
@@ -554,7 +528,6 @@ namespace driver {
554528
if (TaskQueue::supportsBufferingOutput())
555529
llvm::errs() << Output;
556530
}
557-
558531
if (!ErrorMsg.empty())
559532
Comp.Diags.diagnose(SourceLoc(), diag::error_unable_to_execute_command,
560533
ErrorMsg);

0 commit comments

Comments
 (0)