DependencyScanner: add a new extraPcmArgs field for each Swift module

Building each Swift module explicitly requires dependency PCMs to be built
with the exactly same deployment target version. This means we may need to
build a Clang module multiple times with different target triples.

This patch removes the -target arguments from the reported PCM build
arguments and inserts extraPcmArgs fields to each Swift module.
swift-driver can combine the generic PCM arguments with these extra arguments
to get the command suitable for building a PCM specifically for
that loading Swift module.
This commit is contained in:
Xi Ge
2020-06-10 16:12:01 -07:00
parent ecaf9afdb3
commit 00872ba53e
9 changed files with 77 additions and 10 deletions

View File

@@ -1323,10 +1323,12 @@ bool InterfaceSubContextDelegateImpl::runInSubContext(StringRef moduleName,
StringRef interfacePath,
StringRef outputPath,
SourceLoc diagLoc,
llvm::function_ref<bool(ASTContext&, ArrayRef<StringRef>, StringRef)> action) {
llvm::function_ref<bool(ASTContext&, ArrayRef<StringRef>,
ArrayRef<StringRef>, StringRef)> action) {
return runInSubCompilerInstance(moduleName, interfacePath, outputPath, diagLoc,
[&](SubCompilerInstanceInfo &info){
return action(info.Instance->getASTContext(), info.BuildArguments,
info.ExtraPCMArgs,
info.Hash);
});
}
@@ -1398,6 +1400,10 @@ bool InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleN
}
info.BuildArguments = BuildArgs;
info.Hash = CacheHash;
std::array<StringRef, 4> ExtraPCMArgs = {"-Xcc", "-target", "-Xcc",
// PCMs should use the target tripe the interface will be using to build
*(std::find(BuildArgs.rbegin(), BuildArgs.rend(), "-target") - 1)};
info.ExtraPCMArgs = ExtraPCMArgs;
// Run the action under the sub compiler instance.
return action(info);
}