Skip to content

Commit 88f12a5

Browse files
authored
Merge pull request #10680 from swiftlang/jan_svoboda/thread-safe-output-backend
[clang] Enable making `CompilerInstance` output backend thread-safe
2 parents cf2bcc4 + 0a827eb commit 88f12a5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,10 +1418,15 @@ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompileImpl(
14181418
auto WrapGenModuleAction = getGenModuleActionWrapper();
14191419
Instance.setGenModuleActionWrapper(WrapGenModuleAction);
14201420

1421-
// Share an output manager.
14221421
assert(hasOutputBackend() &&
14231422
"Expected an output manager to already be set up");
1424-
Instance.setOutputBackend(&getOutputBackend());
1423+
if (ThreadSafeConfig) {
1424+
// Create a clone of the existing output (pointing to the same destination).
1425+
Instance.setOutputBackend(getOutputBackend().clone());
1426+
} else {
1427+
// Share the existing output manager.
1428+
Instance.setOutputBackend(&getOutputBackend());
1429+
}
14251430

14261431
if (ThreadSafeConfig) {
14271432
Instance.setModuleDepCollector(ThreadSafeConfig->getModuleDepCollector());

0 commit comments

Comments
 (0)