[NFC] Support many runtime library import paths

Replaces SearchPathOptions::RuntimeLibraryImportPath with an equivalent std::vector of paths. Also reimplements SearchPathOptions::SkipRuntimeLibraryImportPaths to cause the list of runtime library import paths to be empty, rather than exiting early from SerializedModuleLoader::findModule().
This commit is contained in:
Brent Royal-Gordon
2019-03-07 18:31:51 -08:00
parent d6eb168733
commit 46ddb2a607
4 changed files with 52 additions and 30 deletions

View File

@@ -278,24 +278,35 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
}
}
// If we're not allowed to look in the runtime library import path, stop.
if (Ctx.SearchPathOpts.SkipRuntimeLibraryImportPath)
return false;
// Search the runtime import path.
// Search the runtime import paths.
isFramework = false;
currPath = Ctx.SearchPathOpts.RuntimeLibraryImportPath;
if (Ctx.LangOpts.Target.isOSDarwin()) {
// Apple platforms always use architecture-specific files within a
// .swiftmodule directory for the stdlib.
llvm::sys::path::append(currPath, fileNames.module.str());
return findTargetSpecificModuleFiles().getValueOr(false);
// Apple platforms always use target-specific files within a
// .swiftmodule directory for the stdlib; non-Apple platforms
// always use single-architecture swiftmodules.
// We could move the `if` outside of the `for` instead of inside,
// but I/O will be so slow that we won't notice the difference,
// so it's not worth the code duplication.
bool hasTargetSpecificRuntimeModules = Ctx.LangOpts.Target.isOSDarwin();
for (auto RuntimeLibraryImportPath :
Ctx.SearchPathOpts.RuntimeLibraryImportPaths) {
currPath = RuntimeLibraryImportPath;
if (hasTargetSpecificRuntimeModules) {
llvm::sys::path::append(currPath, fileNames.module.str());
if (auto outcome = findTargetSpecificModuleFiles())
return *outcome;
} else {
auto result = findModuleFilesInDirectory(moduleID, currPath,
fileNames.module.str(),
fileNames.moduleDoc.str(),
moduleBuffer, moduleDocBuffer);
if (!result)
return true;
}
}
// Non-Apple platforms always use single-architecture swiftmodules.
return !findModuleFilesInDirectory(moduleID, currPath,
fileNames.module.str(),
fileNames.moduleDoc.str(),
moduleBuffer, moduleDocBuffer);
return false;
}
static std::pair<StringRef, clang::VersionTuple>