Skip to content

Commit c9b42dc

Browse files
author
David Ungar
authored
Merge pull request #16583 from davidungar/batch-remark
[Batch Mode] Output a remark from the driver when in batch mode
2 parents 77c8e24 + 96bcc18 commit c9b42dc

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

include/swift/AST/DiagnosticsDriver.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
DIAG(NOTE,ID,Options,Text,Signature)
3838
#endif
3939

40+
#ifndef REMARK
41+
# define REMARK(ID,Options,Text,Signature) \
42+
DIAG(REMARK,ID,Options,Text,Signature)
43+
#endif
4044

4145
WARNING(warning_parallel_execution_not_supported,none,
4246
"parallel execution not supported; falling back to serial execution",
@@ -151,6 +155,8 @@ WARNING(warn_use_filelists_deprecated, none,
151155
"the option '-driver-use-filelists' is deprecated; use "
152156
"'-driver-filelist-threshold=0' instead", ())
153157

158+
REMARK(remark_using_batch_mode,none, "using batch mode", ())
159+
154160
#ifndef DIAG_NO_UNDEF
155161
# if defined(DIAG)
156162
# undef DIAG

lib/Driver/Driver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,11 @@ Driver::buildCompilation(const ToolChain &TC,
716716
const bool ContinueBuildingAfterErrors =
717717
BatchMode || ArgList->hasArg(options::OPT_continue_building_after_errors);
718718

719+
// Issue a remark to facilitate recognizing the use of batch mode in the build
720+
// log.
721+
if (BatchMode)
722+
Diags.diagnose(SourceLoc(), diag::remark_using_batch_mode);
723+
719724
if (Diags.hadAnyError())
720725
return nullptr;
721726

test/Driver/batch_mode_force_one_batch_repartition.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
// RUN: touch %t/file-01.swift %t/file-02.swift %t/file-03.swift
33
// RUN: echo 'public func main() {}' >%t/main.swift
44
//
5-
// RUN: %swiftc_driver -enable-batch-mode -c -emit-module -module-name main -j 2 -driver-force-one-batch-repartition %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/main.swift -### 2>%t/shouldBeEmpty2 | %FileCheck %s -check-prefix=CHECK-COMBINED
6-
// RUN: test -z "`cat %t/shouldBeEmpty1`"
7-
// RUN: test -z "`cat %t/shouldBeEmpty2`"
8-
//
5+
// RUN: %swiftc_driver -enable-batch-mode -c -emit-module -module-name main -j 2 -driver-force-one-batch-repartition %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/main.swift -### 2>%t/stderr | %FileCheck %s -check-prefix=CHECK-COMBINED
6+
97
// CHECK-COMBINED: -primary-file {{.*}}/file-01.swift
108
// CHECK-COMBINED-NEXT: -primary-file {{.*}}/file-02.swift
119
// CHECK-COMBINED-NEXT: -primary-file {{.*}}/file-03.swift

test/Driver/batch_mode_print_jobs.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
// RUN: touch %t/file-01.swift %t/file-02.swift %t/file-03.swift
1111
// RUN: echo 'public func main() {}' >%t/main.swift
1212
//
13-
// RUN: %swiftc_driver -enable-batch-mode -c -emit-module -module-name main -j 2 %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/main.swift -driver-print-jobs 2>%t/shouldBeEmpty1 | %FileCheck %s -check-prefix=CHECK-COMBINED
14-
// RUN: %swiftc_driver -enable-batch-mode -c -emit-module -module-name main -j 2 %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/main.swift -### 2>%t/shouldBeEmpty2 | %FileCheck %s -check-prefix=CHECK-COMBINED
15-
// RUN: test -z "`cat %t/shouldBeEmpty1`"
16-
// RUN: test -z "`cat %t/shouldBeEmpty2`"
13+
// RUN: %swiftc_driver -enable-batch-mode -c -emit-module -module-name main -j 2 %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/main.swift -driver-print-jobs 2>%t/stderr1 | %FileCheck %s -check-prefix=CHECK-COMBINED
14+
// RUN: %swiftc_driver -enable-batch-mode -c -emit-module -module-name main -j 2 %t/file-01.swift %t/file-02.swift %t/file-03.swift %t/main.swift -### 2>%t/stderr2 | %FileCheck %s -check-prefix=CHECK-COMBINED
15+
// RUN: %FileCheck %s -check-prefix=NEGATIVE-CHECK-COMBINED <%t/stderr1
16+
// RUN: %FileCheck %s -check-prefix=NEGATIVE-CHECK-COMBINED <%t/stderr2
1717
//
1818
// CHECK-COMBINED: -primary-file {{.*}}/file-01.swift -primary-file {{.*}}/file-02.swift {{.*}}/file-03.swift {{.*}}/main.swift
19+
// NEGATIVE-CHECK-COMBINED-NOT: -primary-file {{.*}}/file-01.swift -primary-file {{.*}}/file-02.swift {{.*}}/file-03.swift {{.*}}/main.swift

test/Driver/batch_mode_remark.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Ensure that driver issues a remark iff in batch mode.
2+
//
3+
// RUN: %swiftc_driver -whole-module-optimization -enable-batch-mode %S/../Inputs/empty.swift -### 2>&1 >/dev/null | %FileCheck %s
4+
// RUN: %swiftc_driver %S/../Inputs/empty.swift -### 2>&1 >/dev/null | %FileCheck -allow-empty %s
5+
// RUN: %swiftc_driver -enable-batch-mode -disable-batch-mode %S/../Inputs/empty.swift -### 2>&1 >/dev/null | %FileCheck -allow-empty %s
6+
//
7+
// CHECK-NOT: remark: using batch mode
8+
//
9+
//
10+
// RUN: %swiftc_driver -enable-batch-mode %S/../Inputs/empty.swift -### 2>&1 | %FileCheck %s -check-prefix USING-BATCH-MODE
11+
//
12+
// USING-BATCH-MODE: remark: using batch mode

0 commit comments

Comments
 (0)