ModuleInterface: remark potential version differences between SDK and prebuilt modules

Prebuilt-module directory now contains a SystemVersion.plist file copied from the SDK
it's built from. This patch teaches the compiler to remark this version and the SDK version
when -Rmodule-interface-rebuild is specified. The difference between these versions could
help us debug unusable prebuilt modules.
This commit is contained in:
Xi Ge
2020-09-04 11:12:12 -07:00
parent 9d908ec4dc
commit 028a75572c
10 changed files with 85 additions and 48 deletions

View File

@@ -286,10 +286,18 @@ struct ModuleRebuildInfo {
/// Emits a diagnostic for all out-of-date compiled or forwarding modules
/// encountered while trying to load a module.
void diagnose(ASTContext &ctx, SourceLoc loc, StringRef moduleName,
StringRef interfacePath) {
StringRef interfacePath, StringRef prebuiltCacheDir) {
ctx.Diags.diagnose(loc, diag::rebuilding_module_from_interface,
moduleName, interfacePath);
auto SDKVer = getSDKBuildVersion(ctx.SearchPathOpts.SDKPath);
llvm::SmallString<64> buffer = prebuiltCacheDir;
llvm::sys::path::append(buffer, "SystemVersion.plist");
auto PBMVer = getSDKBuildVersionFromPlist(buffer.str());
if (!SDKVer.empty() && !PBMVer.empty()) {
// Remark the potential version difference.
ctx.Diags.diagnose(loc, diag::sdk_version_pbm_version, SDKVer,
PBMVer);
}
// We may have found multiple failing modules, that failed for different
// reasons. Emit a note for each of them.
for (auto &mod : outOfDateModules) {
@@ -911,7 +919,7 @@ class ModuleInterfaceLoaderImpl {
// Diagnose that we didn't find a loadable module, if we were asked to.
auto remarkRebuild = [&]() {
rebuildInfo.diagnose(ctx, diagnosticLoc, moduleName,
interfacePath);
interfacePath, prebuiltCacheDir);
};
// If we found an out-of-date .swiftmodule, we still want to add it as
// a dependency of the .swiftinterface. That way if it's updated, but