Skip to content

Commit a04260b

Browse files
committed
[Driver] Disable PCH validation in batch mode, too.
When building in batch mode with a precompiled bridging header, tell the frontends to disable PCH validation. We have always done this for incremental, non-batch builds, but forgot to update this check when we added batch mode. Fixes SR-11986 / rdar://problem/58455465
1 parent 75bad90 commit a04260b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/Driver/ToolChains.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,19 @@ ToolChain::constructInvocation(const CompileJobAction &job,
403403
}
404404
if (usePersistentPCH) {
405405
context.Args.AddLastArg(Arguments, options::OPT_pch_output_dir);
406-
if (context.OI.CompilerMode == OutputInfo::Mode::StandardCompile) {
406+
switch (context.OI.CompilerMode) {
407+
case OutputInfo::Mode::StandardCompile:
408+
case OutputInfo::Mode::BatchModeCompile:
407409
// In the 'multiple invocations for each file' mode we don't need to
408410
// validate the PCH every time, it has been validated with the initial
409411
// -emit-pch invocation.
410412
Arguments.push_back("-pch-disable-validation");
413+
break;
414+
415+
case OutputInfo::Mode::Immediate:
416+
case OutputInfo::Mode::REPL:
417+
case OutputInfo::Mode::SingleCompile:
418+
break;
411419
}
412420
}
413421
}

test/Driver/bridging-pch.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
// PERSISTENT-DISABLED-YESPCHJOB-NOT: -pch-output-dir
4949

5050
// RUN: %target-build-swift -typecheck -driver-print-jobs -import-objc-header %S/Inputs/bridging-header.h -pch-output-dir %t/pch %s 2>&1 | %FileCheck %s -check-prefix=PERSISTENT-YESPCHJOB
51+
// RUN: %target-build-swift -typecheck -driver-print-jobs -import-objc-header %S/Inputs/bridging-header.h -pch-output-dir %t/pch %s %S/Inputs/error.swift -driver-batch-count 2 -enable-batch-mode 2>&1 | %FileCheck %s -check-prefix=PERSISTENT-YESPCHJOB
5152
// PERSISTENT-YESPCHJOB: {{.*}}swift{{c?(\.exe)?"?}} -frontend {{.*}} -emit-pch -pch-output-dir {{.*}}/pch
5253
// PERSISTENT-YESPCHJOB: {{.*}}swift{{c?(\.exe)?"?}} -frontend {{.*}} -import-objc-header {{.*}}bridging-header.h{{"?}} -pch-output-dir {{.*}}/pch{{"?}} -pch-disable-validation
5354

0 commit comments

Comments
 (0)