mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user