mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #21513 from jrose-apple/cachet
[ParseableInterface] Pass prebuilt cache path down to sub-invocations And several other fixes that got folded into this PR.
This commit is contained in:
@@ -792,6 +792,30 @@ inline T accumulate(const Container &C, T init, BinaryOperation op) {
|
||||
return std::accumulate(C.begin(), C.end(), init, op);
|
||||
}
|
||||
|
||||
/// Returns true if the range defined by \p mainBegin ..< \p mainEnd starts with
|
||||
/// the same elements as the range defined by \p prefixBegin ..< \p prefixEnd.
|
||||
///
|
||||
/// This includes cases where the prefix range is empty, as well as when the two
|
||||
/// ranges are the same length and contain the same elements.
|
||||
template <typename MainInputIterator, typename PrefixInputIterator>
|
||||
inline bool hasPrefix(MainInputIterator mainBegin,
|
||||
const MainInputIterator mainEnd,
|
||||
PrefixInputIterator prefixBegin,
|
||||
const PrefixInputIterator prefixEnd) {
|
||||
while (prefixBegin != prefixEnd) {
|
||||
// If "main" is shorter than "prefix", it does not start with "prefix".
|
||||
if (mainBegin == mainEnd)
|
||||
return false;
|
||||
// If there's a mismatch, "main" does not start with "prefix".
|
||||
if (*mainBegin != *prefixBegin)
|
||||
return false;
|
||||
++prefixBegin;
|
||||
++mainBegin;
|
||||
}
|
||||
// If we checked every element of "prefix", "main" does start with "prefix".
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Provides default implementations of !=, <=, >, and >= based on == and <.
|
||||
template <typename T>
|
||||
class RelationalOperationsBase {
|
||||
|
||||
@@ -72,6 +72,10 @@ public:
|
||||
/// The path to which we should store indexing data, if any.
|
||||
std::string IndexStorePath;
|
||||
|
||||
/// The path to look in when loading a parseable interface file, to see if a
|
||||
/// binary module has already been built for use by the compiler.
|
||||
std::string PrebuiltModuleCachePath;
|
||||
|
||||
/// Emit index data for imported serialized swift system modules.
|
||||
bool IndexSystemModules = false;
|
||||
|
||||
|
||||
@@ -61,13 +61,15 @@ getModuleCachePathFromClang(const clang::CompilerInstance &Instance);
|
||||
/// directory, and loading the serialized .swiftmodules from there.
|
||||
class ParseableInterfaceModuleLoader : public SerializedModuleLoaderBase {
|
||||
explicit ParseableInterfaceModuleLoader(ASTContext &ctx, StringRef cacheDir,
|
||||
StringRef prebuiltCacheDir,
|
||||
DependencyTracker *tracker,
|
||||
ModuleLoadingMode loadMode)
|
||||
: SerializedModuleLoaderBase(ctx, tracker, loadMode),
|
||||
CacheDir(cacheDir)
|
||||
CacheDir(cacheDir), PrebuiltCacheDir(prebuiltCacheDir)
|
||||
{}
|
||||
|
||||
std::string CacheDir;
|
||||
std::string PrebuiltCacheDir;
|
||||
|
||||
/// Wire up the SubInvocation's InputsAndOutputs to contain both input and
|
||||
/// output filenames.
|
||||
@@ -77,20 +79,25 @@ class ParseableInterfaceModuleLoader : public SerializedModuleLoaderBase {
|
||||
static void configureSubInvocationInputsAndOutputs(
|
||||
CompilerInvocation &SubInvocation, StringRef InPath, StringRef OutPath);
|
||||
|
||||
std::error_code
|
||||
openModuleFiles(AccessPathElem ModuleID, StringRef DirName,
|
||||
StringRef ModuleFilename, StringRef ModuleDocFilename,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
|
||||
llvm::SmallVectorImpl<char> &Scratch) override;
|
||||
static bool buildSwiftModuleFromSwiftInterface(
|
||||
clang::vfs::FileSystem &FS, DiagnosticEngine &Diags, SourceLoc DiagLoc,
|
||||
CompilerInvocation &SubInvocation, StringRef InPath, StringRef OutPath,
|
||||
StringRef ModuleCachePath, DependencyTracker *OuterTracker,
|
||||
bool ShouldSerializeDeps);
|
||||
|
||||
std::error_code findModuleFilesInDirectory(
|
||||
AccessPathElem ModuleID, StringRef DirPath, StringRef ModuleFilename,
|
||||
StringRef ModuleDocFilename,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer) override;
|
||||
|
||||
public:
|
||||
static std::unique_ptr<ParseableInterfaceModuleLoader>
|
||||
create(ASTContext &ctx, StringRef cacheDir,
|
||||
DependencyTracker *tracker,
|
||||
ModuleLoadingMode loadMode) {
|
||||
create(ASTContext &ctx, StringRef cacheDir, StringRef prebuiltCacheDir,
|
||||
DependencyTracker *tracker, ModuleLoadingMode loadMode) {
|
||||
return std::unique_ptr<ParseableInterfaceModuleLoader>(
|
||||
new ParseableInterfaceModuleLoader(ctx, cacheDir, tracker, loadMode));
|
||||
new ParseableInterfaceModuleLoader(ctx, cacheDir, prebuiltCacheDir,
|
||||
tracker, loadMode));
|
||||
}
|
||||
|
||||
/// Unconditionally build \p InPath (a swiftinterface file) to \p OutPath (as
|
||||
@@ -100,6 +107,7 @@ public:
|
||||
/// testing purposes.
|
||||
static bool buildSwiftModuleFromSwiftInterface(ASTContext &Ctx,
|
||||
StringRef CacheDir,
|
||||
StringRef PrebuiltCacheDir,
|
||||
StringRef ModuleName,
|
||||
StringRef InPath,
|
||||
StringRef OutPath);
|
||||
|
||||
@@ -515,6 +515,13 @@ def build_module_from_parseable_interface :
|
||||
HelpText<"Treat the (single) input as a swiftinterface and produce a module">,
|
||||
ModeOpt;
|
||||
|
||||
def prebuilt_module_cache_path :
|
||||
Separate<["-"], "prebuilt-module-cache-path">,
|
||||
HelpText<"Directory of prebuilt modules for loading parseable interfaces">;
|
||||
def prebuilt_module_cache_path_EQ :
|
||||
Joined<["-"], "prebuilt-module-cache-path=">,
|
||||
Alias<prebuilt_module_cache_path>;
|
||||
|
||||
def enable_resilience_bypass : Flag<["-"], "enable-resilience-bypass">,
|
||||
HelpText<"Completely bypass resilience when accessing types in resilient frameworks">;
|
||||
|
||||
|
||||
@@ -51,12 +51,17 @@ protected:
|
||||
std::unique_ptr<llvm::MemoryBuffer> *moduleDocBuffer,
|
||||
bool &isFramework);
|
||||
|
||||
virtual std::error_code
|
||||
openModuleFiles(AccessPathElem ModuleID, StringRef DirName,
|
||||
StringRef ModuleFilename, StringRef ModuleDocFilename,
|
||||
virtual std::error_code findModuleFilesInDirectory(
|
||||
AccessPathElem ModuleID, StringRef DirPath, StringRef ModuleFilename,
|
||||
StringRef ModuleDocFilename,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer) = 0;
|
||||
|
||||
std::error_code
|
||||
openModuleFiles(AccessPathElem ModuleID,
|
||||
StringRef ModulePath, StringRef ModuleDocPath,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
|
||||
llvm::SmallVectorImpl<char> &Scratch);
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer);
|
||||
|
||||
/// If the module loader subclass knows that all options have been tried for
|
||||
/// loading an architecture-specific file out of a swiftmodule bundle, try
|
||||
@@ -128,12 +133,11 @@ class SerializedModuleLoader : public SerializedModuleLoaderBase {
|
||||
: SerializedModuleLoaderBase(ctx, tracker, loadMode)
|
||||
{}
|
||||
|
||||
std::error_code
|
||||
openModuleFiles(AccessPathElem ModuleID, StringRef DirName,
|
||||
StringRef ModuleFilename, StringRef ModuleDocFilename,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
|
||||
llvm::SmallVectorImpl<char> &Scratch) override;
|
||||
std::error_code findModuleFilesInDirectory(
|
||||
AccessPathElem ModuleID, StringRef DirPath, StringRef ModuleFilename,
|
||||
StringRef ModuleDocFilename,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer) override;
|
||||
|
||||
bool maybeDiagnoseArchitectureMismatch(SourceLoc sourceLocation,
|
||||
StringRef moduleName,
|
||||
|
||||
Reference in New Issue
Block a user