DependenciesScanner: move -fapinotes-swift-version to extra PCM arguments

Swift interface files may specify the effective language version to use. When building
a PCM loadable for these textual interface files, we should respect the language
version. This patch moves -fapinotes-swift-version from the generic PCM
commands to the extra PCM arguments owned by each loading Swift module.
This commit is contained in:
Xi Ge
2020-06-16 11:38:25 -07:00
parent 0aa6918a24
commit b6a8af599e
4 changed files with 37 additions and 9 deletions

View File

@@ -1050,6 +1050,13 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
GenericArgs.push_back(triple);
}
// Inherit the Swift language version
subInvocation.getLangOptions().EffectiveLanguageVersion =
LangOpts.EffectiveLanguageVersion;
GenericArgs.push_back("-swift-version");
GenericArgs.push_back(ArgSaver.save(subInvocation.getLangOptions()
.EffectiveLanguageVersion.asAPINotesVersionString()));
subInvocation.setImportSearchPaths(SearchPathOpts.ImportSearchPaths);
llvm::for_each(SearchPathOpts.ImportSearchPaths,
[&](const std::string &path) {
@@ -1400,9 +1407,15 @@ 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)};
auto target = *(std::find(BuildArgs.rbegin(), BuildArgs.rend(), "-target") - 1);
auto langVersion = *(std::find(BuildArgs.rbegin(), BuildArgs.rend(),
"-swift-version") - 1);
std::array<StringRef, 6> ExtraPCMArgs = {
// PCMs should use the target triple the interface will be using to build
"-Xcc", "-target", "-Xcc", target,
// PCMs should use the effective Swift language version for apinotes.
"-Xcc", ArgSaver.save((llvm::Twine("-fapinotes-swift-version=") + langVersion).str())
};
info.ExtraPCMArgs = ExtraPCMArgs;
// Run the action under the sub compiler instance.
return action(info);