Skip to content

[Driver] -enable-batch-mode implies -continue-building-after-errors #16521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/Driver/Compilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,11 @@ namespace driver {
ReturnCode);
}

// See how ContinueBuildingAfterErrors gets set up in Driver.cpp for
// more info.
assert((Comp.ContinueBuildingAfterErrors || !Comp.EnableBatchMode) &&
"batch mode diagnostics require ContinueBuildingAfterErrors");

return Comp.ContinueBuildingAfterErrors ?
TaskFinishedResponse::ContinueExecution :
TaskFinishedResponse::StopExecution;
Expand Down
17 changes: 15 additions & 2 deletions lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,6 @@ Driver::buildCompilation(const ToolChain &TC,
}

bool SaveTemps = ArgList->hasArg(options::OPT_save_temps);
bool ContinueBuildingAfterErrors =
ArgList->hasArg(options::OPT_continue_building_after_errors);
bool ShowDriverTimeCompilation =
ArgList->hasArg(options::OPT_driver_time_compilation);

Expand Down Expand Up @@ -703,6 +701,21 @@ Driver::buildCompilation(const ToolChain &TC,
OI.CompilerMode = computeCompilerMode(*TranslatedArgList, Inputs, BatchMode);
buildOutputInfo(TC, *TranslatedArgList, BatchMode, Inputs, OI);

// Note: Batch mode handling of serialized diagnostics requires that all
// batches get to run, in order to make sure that all diagnostics emitted
// during the compilation end up in at least one serialized diagnostic file.
// Therefore, treat batch mode as implying -continue-building-after-errors.
// (This behavior could be limited to only when serialized diagnostics are
// being emitted, but this seems more consistent and less surprising for
// users.)
// FIXME: We don't really need (or want) a full ContinueBuildingAfterErrors.
// If we fail to precompile a bridging header, for example, there's no need
// to go on to compilation of source files, and if compilation of source files
// fails, we shouldn't try to link. Instead, we'd want to let all jobs finish
// but not schedule any new ones.
const bool ContinueBuildingAfterErrors =
BatchMode || ArgList->hasArg(options::OPT_continue_building_after_errors);

if (Diags.hadAnyError())
return nullptr;

Expand Down
6 changes: 6 additions & 0 deletions test/Driver/continue-building-after-errors.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
// RUN: not %target-build-swift %S/Inputs/error.swift %s 2>&1 | %FileCheck %s
// RUN: not %target-build-swift -continue-building-after-errors %S/Inputs/error.swift %s 2>&1 | %FileCheck -check-prefix=CHECK-CONTINUE %s

// Check that batch mode implies -continue-building-after-errors.
// RUN: touch %t.empty.swift
// RUN: not %target-build-swift -enable-batch-mode -j2 %S/Inputs/error.swift %S/../Inputs/empty.swift %s %t.empty.swift 2>&1 | %FileCheck -check-prefix=CHECK-BATCH %s

// CHECK: self.bar = self.bar
// CHECK-NOT: self.baz = self.baz
// CHECK-CONTINUE: self.bar = self.bar
// CHECK-CONTINUE: self.baz = self.baz
// CHECK-BATCH-DAG: self.bar = self.bar
// CHECK-BATCH-DAG: self.baz = self.baz
struct Bar {
let baz: Int
init() {
Expand Down