Skip to content

Commit ec5d4f3

Browse files
committed
[Driver] Put new job-lifecycle diagnostic chatter behind another option.
1 parent 99df208 commit ec5d4f3

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

include/swift/Driver/Compilation.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ class Compilation {
138138
/// rebuilt.
139139
bool ShowIncrementalBuildDecisions = false;
140140

141+
/// When true, traces the lifecycle of each driver job. Provides finer
142+
/// detail than ShowIncrementalBuildDecisions.
143+
bool ShowJobLifecycle = false;
144+
141145
static const Job *unwrap(const std::unique_ptr<const Job> &p) {
142146
return p.get();
143147
}
@@ -196,6 +200,10 @@ class Compilation {
196200
ShowIncrementalBuildDecisions = value;
197201
}
198202

203+
void setShowJobLifecycle(bool value = true) {
204+
ShowJobLifecycle = value;
205+
}
206+
199207
void setCompilationRecordPath(StringRef path) {
200208
assert(CompilationRecordPath.empty() && "already set");
201209
CompilationRecordPath = path;

include/swift/Option/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ def driver_use_frontend_path : Separate<["-"], "driver-use-frontend-path">,
9191
def driver_show_incremental : Flag<["-"], "driver-show-incremental">,
9292
InternalDebugOpt,
9393
HelpText<"With -v, dump information about why files are being rebuilt">;
94+
def driver_show_job_lifecycle : Flag<["-"], "driver-show-job-lifecycle">,
95+
InternalDebugOpt,
96+
HelpText<"Show every step in the lifecycle of driver jobs">;
9497
def driver_use_filelists : Flag<["-"], "driver-use-filelists">,
9598
InternalDebugOpt, HelpText<"Pass input files as filelists whenever possible">;
9699

lib/Driver/Compilation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ namespace driver {
191191
/// its inputs are in FinishedCommands.
192192
void scheduleCommandIfNecessaryAndPossible(const Job *Cmd) {
193193
if (ScheduledCommands.count(Cmd)) {
194-
if (Comp.ShowIncrementalBuildDecisions) {
194+
if (Comp.ShowJobLifecycle) {
195195
llvm::outs() << "Already scheduled: " << LogJob(Cmd) << "\n";
196196
}
197197
return;
198198
}
199199

200200
if (auto Blocking = findUnfinishedJob(Cmd->getInputs())) {
201201
BlockingCommands[Blocking].push_back(Cmd);
202-
if (Comp.ShowIncrementalBuildDecisions) {
202+
if (Comp.ShowJobLifecycle) {
203203
llvm::outs() << "Blocked by: " << LogJob(Blocking)
204204
<< ", now blocking jobs: "
205205
<< LogJobArray(BlockingCommands[Blocking]) << "\n";
@@ -215,15 +215,15 @@ namespace driver {
215215
assert(Cmd->getExtraEnvironment().empty() &&
216216
"not implemented for compilations with multiple jobs");
217217
ScheduledCommands.insert(Cmd);
218-
if (Comp.ShowIncrementalBuildDecisions)
218+
if (Comp.ShowJobLifecycle)
219219
llvm::outs() << "Added to TaskQueue: " << LogJob(Cmd) << "\n";
220220
TQ->addTask(Cmd->getExecutable(), Cmd->getArguments(), llvm::None,
221221
(void *)Cmd);
222222
}
223223

224224
/// When a task finishes, check other Jobs that may be blocked.
225225
void markFinished(const Job *Cmd, bool Skipped=false) {
226-
if (Comp.ShowIncrementalBuildDecisions) {
226+
if (Comp.ShowJobLifecycle) {
227227
llvm::outs() << "Job "
228228
<< (Skipped ? "skipped" : "finished")
229229
<< ": " << LogJob(Cmd) << "\n";
@@ -233,7 +233,7 @@ namespace driver {
233233
auto BlockedIter = BlockingCommands.find(Cmd);
234234
if (BlockedIter != BlockingCommands.end()) {
235235
auto AllBlocked = std::move(BlockedIter->second);
236-
if (Comp.ShowIncrementalBuildDecisions) {
236+
if (Comp.ShowJobLifecycle) {
237237
llvm::outs() << "Scheduling maybe-unblocked jobs: "
238238
<< LogJobArray(AllBlocked) << "\n";
239239
}

lib/Driver/Driver.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,8 @@ std::unique_ptr<Compilation> Driver::buildCompilation(
470470
ArgList->hasArg(options::OPT_driver_skip_execution);
471471
bool ShowIncrementalBuildDecisions =
472472
ArgList->hasArg(options::OPT_driver_show_incremental);
473+
bool ShowJobLifecycle =
474+
ArgList->hasArg(options::OPT_driver_show_job_lifecycle);
473475

474476
bool Incremental = ArgList->hasArg(options::OPT_incremental);
475477
if (ArgList->hasArg(options::OPT_whole_module_optimization)) {
@@ -642,9 +644,12 @@ std::unique_ptr<Compilation> Driver::buildCompilation(
642644
ContinueBuildingAfterErrors)
643645
C->setContinueBuildingAfterErrors();
644646

645-
if (ShowIncrementalBuildDecisions)
647+
if (ShowIncrementalBuildDecisions || ShowJobLifecycle)
646648
C->setShowsIncrementalBuildDecisions();
647649

650+
if (ShowJobLifecycle)
651+
C->setShowJobLifecycle();
652+
648653
// This has to happen after building jobs, because otherwise we won't even
649654
// emit .swiftdeps files for the next build.
650655
if (rebuildEverything)

test/Driver/Dependencies/only-skip-once.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: rm -rf %t && cp -r %S/Inputs/only-skip-once/ %t
33
// RUN: touch -t 201401240005 %t/*
44

5-
// RUN: cd %t && %swiftc_driver -driver-show-incremental -output-file-map %t/output-file-map.json -incremental main.swift file1.swift file2.swift -j1 2>&1 | %FileCheck -check-prefix=CHECK-INITIAL %s
5+
// RUN: cd %t && %swiftc_driver -driver-show-job-lifecycle -output-file-map %t/output-file-map.json -incremental main.swift file1.swift file2.swift -j1 2>&1 | %FileCheck -check-prefix=CHECK-INITIAL %s
66

77
// CHECK-INITIAL-NOT: warning
88
// CHECK-INITIAL: Job finished: {compile: main.o <= main.swift}
@@ -11,7 +11,7 @@
1111
// CHECK-INITIAL: Job finished: {link: main <= main.o file1.o file2.o}
1212

1313
// RUN: touch -t 201401240006 %t/file2.swift
14-
// RUN: cd %t && %swiftc_driver -driver-show-incremental -output-file-map %t/output-file-map.json -incremental main.swift file1.swift file2.swift -j1 2>&1 | %FileCheck -check-prefix=CHECK-REBUILD %s
14+
// RUN: cd %t && %swiftc_driver -driver-show-job-lifecycle -output-file-map %t/output-file-map.json -incremental main.swift file1.swift file2.swift -j1 2>&1 | %FileCheck -check-prefix=CHECK-REBUILD %s
1515

1616
// We should skip the main and file1 rebuilds here, but we should only note skipping them _once_
1717
// CHECK-REBUILD: Job finished: {compile: file2.o <= file2.swift}

0 commit comments

Comments
 (0)