[Driver/ClangImporter] Changes for the driver to recognize -pch-output-dir and propagate to the frontend invocations

For the multiple-files mode -emit-pch is still invoked in separate frontend invocation but with using a persistent PCH.
Subsequent frontend invocations use the persistent PCH but they don't need to validate it.

For all-files mode (e.g. WMO) the frontend invocation uses a persistent PCH that it also validates.
This commit is contained in:
Argyrios Kyrtzidis
2017-05-11 11:44:12 -07:00
parent cbc35f03d3
commit c4b5b60d00
18 changed files with 151 additions and 38 deletions

View File

@@ -459,6 +459,15 @@ static bool performCompile(CompilerInstance &Instance,
if (Action == FrontendOptions::EmitPCH) {
auto clangImporter = static_cast<ClangImporter *>(
Instance.getASTContext().getClangModuleLoader());
auto &ImporterOpts = Invocation.getClangImporterOptions();
auto &PCHOutDir = ImporterOpts.PrecompiledHeaderOutputDir;
if (!PCHOutDir.empty()) {
ImporterOpts.BridgingHeader = Invocation.getInputFilenames()[0];
// Create or validate a persistent PCH.
auto SwiftPCHHash = Invocation.getPCHHash();
auto PCH = clangImporter->getOrCreatePCH(ImporterOpts, SwiftPCHHash);
return !PCH.hasValue();
}
return clangImporter->emitBridgingPCH(
Invocation.getInputFilenames()[0],
opts.getSingleOutputFilename());