mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Caching] Remove CASFS clang module implemenation
Remove the CASFS based clang module implemenation as it is not longer used.
This commit is contained in:
@@ -520,7 +520,7 @@ REMARK(matching_output_produced,none,
|
||||
|
||||
// Caching related diagnostics
|
||||
ERROR(error_caching_no_cas_fs, none,
|
||||
"caching is enabled without -cas-fs option, input is not immutable", ())
|
||||
"caching is enabled without CAS file-system options, input is not immutable", ())
|
||||
ERROR(error_prefix_mapping, none, "cannot create scanner prefix mapping: '%0'", (StringRef))
|
||||
|
||||
REMARK(replay_output, none, "replay output file '%0': key '%1'", (StringRef, StringRef))
|
||||
|
||||
@@ -1000,7 +1000,7 @@ using ModuleDependenciesKindMap =
|
||||
/// Track swift dependency
|
||||
class SwiftDependencyTracker {
|
||||
public:
|
||||
SwiftDependencyTracker(llvm::cas::CachingOnDiskFileSystem &FS,
|
||||
SwiftDependencyTracker(std::shared_ptr<llvm::cas::ObjectStore> CAS,
|
||||
llvm::PrefixMapper *Mapper,
|
||||
const CompilerInvocation &CI);
|
||||
|
||||
@@ -1009,7 +1009,8 @@ public:
|
||||
llvm::Expected<llvm::cas::ObjectProxy> createTreeFromDependencies();
|
||||
|
||||
private:
|
||||
llvm::IntrusiveRefCntPtr<llvm::cas::CachingOnDiskFileSystem> FS;
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS;
|
||||
std::shared_ptr<llvm::cas::ObjectStore> CAS;
|
||||
llvm::PrefixMapper *Mapper;
|
||||
|
||||
struct FileEntry {
|
||||
@@ -1035,10 +1036,7 @@ class SwiftDependencyScanningService {
|
||||
ClangScanningService;
|
||||
|
||||
/// CachingOnDiskFileSystem for dependency tracking.
|
||||
llvm::IntrusiveRefCntPtr<llvm::cas::CachingOnDiskFileSystem> CacheFS;
|
||||
|
||||
/// If use clang include tree.
|
||||
bool UseClangIncludeTree = false;
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> CacheFS;
|
||||
|
||||
/// CAS Instance.
|
||||
std::shared_ptr<llvm::cas::ObjectStore> CAS;
|
||||
@@ -1076,8 +1074,8 @@ public:
|
||||
return *SharedFilesystemCache;
|
||||
}
|
||||
|
||||
llvm::cas::CachingOnDiskFileSystem &getSharedCachingFS() const {
|
||||
assert(CacheFS && "Expect CachingOnDiskFileSystem");
|
||||
llvm::vfs::FileSystem &getSharedCachingFS() const {
|
||||
assert(CacheFS && "Expect a CASFileSystem");
|
||||
return *CacheFS;
|
||||
}
|
||||
|
||||
@@ -1088,20 +1086,17 @@ public:
|
||||
|
||||
std::optional<SwiftDependencyTracker>
|
||||
createSwiftDependencyTracker(const CompilerInvocation &CI) {
|
||||
if (!CacheFS)
|
||||
if (!CAS)
|
||||
return std::nullopt;
|
||||
|
||||
return SwiftDependencyTracker(*CacheFS, Mapper.get(), CI);
|
||||
return SwiftDependencyTracker(CAS, Mapper.get(), CI);
|
||||
}
|
||||
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> getClangScanningFS() const {
|
||||
if (UseClangIncludeTree)
|
||||
if (CAS)
|
||||
return llvm::cas::createCASProvidingFileSystem(
|
||||
CAS, llvm::vfs::createPhysicalFileSystem());
|
||||
|
||||
if (CacheFS)
|
||||
return CacheFS->createProxyFS();
|
||||
|
||||
return llvm::vfs::createPhysicalFileSystem();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +37,6 @@ public:
|
||||
/// CASOptions
|
||||
clang::CASOptions CASOpts;
|
||||
|
||||
/// CASFS Root.
|
||||
std::vector<std::string> CASFSRootIDs;
|
||||
|
||||
/// Clang Include Trees.
|
||||
std::string ClangIncludeTree;
|
||||
|
||||
@@ -62,9 +59,8 @@ public:
|
||||
/// Check to see if a CASFileSystem is required.
|
||||
bool requireCASFS() const {
|
||||
return EnableCaching &&
|
||||
(!CASFSRootIDs.empty() || !ClangIncludeTree.empty() ||
|
||||
!ClangIncludeTreeFileList.empty() || !InputFileKey.empty() ||
|
||||
!BridgingHeaderPCHCacheKey.empty());
|
||||
(!ClangIncludeTree.empty() || !ClangIncludeTreeFileList.empty() ||
|
||||
!InputFileKey.empty() || !BridgingHeaderPCHCacheKey.empty());
|
||||
}
|
||||
|
||||
/// Return a hash code of any components from these options that should
|
||||
|
||||
@@ -1094,12 +1094,6 @@ namespace swift {
|
||||
/// built and provided to the compiler invocation.
|
||||
bool DisableImplicitClangModules = false;
|
||||
|
||||
/// Enable ClangIncludeTree for explicit module builds scanning.
|
||||
bool UseClangIncludeTree = false;
|
||||
|
||||
/// Using ClangIncludeTreeRoot for compilation.
|
||||
bool HasClangIncludeTreeRoot = false;
|
||||
|
||||
/// Whether the dependency scanner should construct all swift-frontend
|
||||
/// invocations directly from clang cc1 args.
|
||||
bool ClangImporterDirectCC1Scan = false;
|
||||
|
||||
@@ -70,7 +70,7 @@ std::unique_ptr<llvm::MemoryBuffer> loadCachedCompileResultFromCacheKey(
|
||||
llvm::StringRef Filename = "");
|
||||
|
||||
llvm::Expected<llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>>
|
||||
createCASFileSystem(llvm::cas::ObjectStore &CAS, ArrayRef<std::string> FSRoots,
|
||||
createCASFileSystem(llvm::cas::ObjectStore &CAS,
|
||||
const std::string &IncludeTreeRoot,
|
||||
const std::string &IncludeTreeFileList);
|
||||
|
||||
|
||||
@@ -1454,9 +1454,6 @@ def bridging_header_pch_key : Separate<["-"], "bridging-header-pch-key">,
|
||||
def no_clang_include_tree: Flag<["-"], "no-clang-include-tree">,
|
||||
HelpText<"Do not use clang include tree, fallback to use CAS filesystem to build clang modules">;
|
||||
|
||||
def cas_fs: Separate<["-"], "cas-fs">,
|
||||
HelpText<"Root CASID for CAS FileSystem">, MetaVarName<"<cas-id>">;
|
||||
|
||||
def clang_include_tree_root: Separate<["-"], "clang-include-tree-root">,
|
||||
HelpText<"Clang Include Tree CASID">, MetaVarName<"<cas-id>">;
|
||||
def clang_include_tree_filelist: Separate<["-"], "clang-include-tree-filelist">,
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "swift/Strings.h"
|
||||
#include "clang/CAS/IncludeTree.h"
|
||||
#include "llvm/CAS/CASProvidingFileSystem.h"
|
||||
#include "llvm/CAS/CachingOnDiskFileSystem.h"
|
||||
#include "llvm/Config/config.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
@@ -602,13 +601,16 @@ swift::dependencies::registerBackDeployLibraries(
|
||||
}
|
||||
|
||||
SwiftDependencyTracker::SwiftDependencyTracker(
|
||||
llvm::cas::CachingOnDiskFileSystem &FS, llvm::PrefixMapper *Mapper,
|
||||
std::shared_ptr<llvm::cas::ObjectStore> CAS, llvm::PrefixMapper *Mapper,
|
||||
const CompilerInvocation &CI)
|
||||
: FS(FS.createProxyFS()), Mapper(Mapper) {
|
||||
: CAS(CAS), Mapper(Mapper) {
|
||||
auto &SearchPathOpts = CI.getSearchPathOptions();
|
||||
|
||||
FS = llvm::cas::createCASProvidingFileSystem(
|
||||
CAS, llvm::vfs::createPhysicalFileSystem());
|
||||
|
||||
auto addCommonFile = [&](StringRef path) {
|
||||
auto file = FS.openFileForRead(path);
|
||||
auto file = FS->openFileForRead(path);
|
||||
if (!file)
|
||||
return;
|
||||
auto status = (*file)->status();
|
||||
@@ -679,7 +681,7 @@ SwiftDependencyTracker::createTreeFromDependencies() {
|
||||
llvm::SmallVector<clang::cas::IncludeTree::FileList::FileEntry> Files;
|
||||
for (auto &file : TrackedFiles) {
|
||||
auto includeTreeFile = clang::cas::IncludeTree::File::create(
|
||||
FS->getCAS(), file.first, file.second.FileRef);
|
||||
*CAS, file.first, file.second.FileRef);
|
||||
if (!includeTreeFile) {
|
||||
return llvm::createStringError("CASFS createTree failed for " +
|
||||
file.first + ": " +
|
||||
@@ -691,7 +693,7 @@ SwiftDependencyTracker::createTreeFromDependencies() {
|
||||
}
|
||||
|
||||
auto includeTreeList =
|
||||
clang::cas::IncludeTree::FileList::create(FS->getCAS(), Files, {});
|
||||
clang::cas::IncludeTree::FileList::create(*CAS, Files, {});
|
||||
if (!includeTreeList)
|
||||
return llvm::createStringError("casfs include-tree filelist error: " +
|
||||
toString(includeTreeList.takeError()));
|
||||
@@ -719,14 +721,8 @@ bool SwiftDependencyScanningService::setupCachingDependencyScanningService(
|
||||
CAS = Instance.getSharedCASInstance();
|
||||
ActionCache = Instance.getSharedCacheInstance();
|
||||
|
||||
auto CachingFS =
|
||||
llvm::cas::createCachingOnDiskFileSystem(Instance.getObjectStore());
|
||||
if (!CachingFS) {
|
||||
Instance.getDiags().diagnose(SourceLoc(), diag::error_cas_fs_creation,
|
||||
toString(CachingFS.takeError()));
|
||||
return true;
|
||||
}
|
||||
CacheFS = std::move(*CachingFS);
|
||||
CacheFS = llvm::cas::createCASProvidingFileSystem(
|
||||
CAS, llvm::vfs::createPhysicalFileSystem());
|
||||
|
||||
// Setup prefix mapping.
|
||||
auto &ScannerPrefixMapper =
|
||||
@@ -744,19 +740,14 @@ bool SwiftDependencyScanningService::setupCachingDependencyScanningService(
|
||||
Mapper->sort();
|
||||
}
|
||||
|
||||
UseClangIncludeTree =
|
||||
Instance.getInvocation().getClangImporterOptions().UseClangIncludeTree;
|
||||
const clang::tooling::dependencies::ScanningOutputFormat ClangScanningFormat =
|
||||
UseClangIncludeTree
|
||||
? clang::tooling::dependencies::ScanningOutputFormat::FullIncludeTree
|
||||
: clang::tooling::dependencies::ScanningOutputFormat::FullTree;
|
||||
clang::tooling::dependencies::ScanningOutputFormat::FullIncludeTree;
|
||||
|
||||
ClangScanningService.emplace(
|
||||
clang::tooling::dependencies::ScanningMode::DependencyDirectivesScan,
|
||||
ClangScanningFormat,
|
||||
Instance.getInvocation().getCASOptions().CASOpts,
|
||||
ClangScanningFormat, Instance.getInvocation().getCASOptions().CASOpts,
|
||||
Instance.getSharedCASInstance(), Instance.getSharedCacheInstance(),
|
||||
UseClangIncludeTree ? nullptr : CacheFS,
|
||||
/*CachingOnDiskFileSystem=*/nullptr,
|
||||
// The current working directory optimization (off by default)
|
||||
// should not impact CAS. We set the optization to all to be
|
||||
// consistent with the non-CAS case.
|
||||
|
||||
@@ -1186,7 +1186,7 @@ std::optional<std::vector<std::string>> ClangImporter::getClangCC1Arguments(
|
||||
clang::frontend::ActionKind::GenerateModule ||
|
||||
CI->getFrontendOpts().ProgramAction ==
|
||||
clang::frontend::ActionKind::GeneratePCH) &&
|
||||
ctx.ClangImporterOpts.HasClangIncludeTreeRoot) {
|
||||
!ctx.CASOpts.ClangIncludeTree.empty()) {
|
||||
CI->getFrontendOpts().CASIncludeTreeID = ctx.CASOpts.ClangIncludeTree;
|
||||
CI->getFrontendOpts().Inputs.clear();
|
||||
}
|
||||
@@ -1246,7 +1246,7 @@ std::optional<std::vector<std::string>> ClangImporter::getClangCC1Arguments(
|
||||
|
||||
std::vector<std::string> FilteredModuleMapFiles;
|
||||
for (auto ModuleMapFile : CI->getFrontendOpts().ModuleMapFiles) {
|
||||
if (ctx.ClangImporterOpts.UseClangIncludeTree) {
|
||||
if (ctx.CASOpts.HasImmutableFileSystem) {
|
||||
// There is no need to add any module map file here. Issue a warning and
|
||||
// drop the option.
|
||||
Impl.diagnose(SourceLoc(), diag::module_map_ignored, ModuleMapFile);
|
||||
@@ -2731,7 +2731,6 @@ ClangImporter::Implementation::Implementation(
|
||||
!ctx.ClangImporterOpts.BridgingHeader.empty()),
|
||||
DisableOverlayModules(ctx.ClangImporterOpts.DisableOverlayModules),
|
||||
EnableClangSPI(ctx.ClangImporterOpts.EnableClangSPI),
|
||||
UseClangIncludeTree(ctx.ClangImporterOpts.UseClangIncludeTree),
|
||||
IsReadingBridgingPCH(false),
|
||||
CurrentVersion(ImportNameVersion::fromOptions(ctx.LangOpts)),
|
||||
Walker(DiagnosticWalker(*this)), BuffersForDiagnostics(ctx.SourceMgr),
|
||||
@@ -4258,11 +4257,9 @@ ClangImporter::getSwiftExplicitModuleDirectCC1Args() const {
|
||||
auto &CGOpts = instance.getCodeGenOpts();
|
||||
CGOpts.DebugCompilationDir.clear();
|
||||
|
||||
if (Impl.SwiftContext.ClangImporterOpts.UseClangIncludeTree) {
|
||||
// FileSystemOptions.
|
||||
auto &FSOpts = instance.getFileSystemOpts();
|
||||
FSOpts.WorkingDir.clear();
|
||||
}
|
||||
|
||||
if (!Impl.SwiftContext.SearchPathOpts.ScannerPrefixMapper.empty()) {
|
||||
// Remap all the paths if requested.
|
||||
|
||||
@@ -147,8 +147,8 @@ ModuleDependencyVector ClangImporter::bridgeClangModuleDependencies(
|
||||
// Swift frontend option for input file path (Foo.modulemap).
|
||||
swiftArgs.push_back(remapPath(clangModuleDep.ClangModuleMapFile));
|
||||
|
||||
// Handle VFSOverlay. If include tree is used, there is no need for overlay.
|
||||
if (!ctx.ClangImporterOpts.UseClangIncludeTree) {
|
||||
// Handle VFSOverlay. If caching is enabled, there is no need for overlay.
|
||||
if (!ctx.CASOpts.EnableCaching) {
|
||||
for (auto &overlay : ctx.SearchPathOpts.VFSOverlayFiles) {
|
||||
swiftArgs.push_back("-vfsoverlay");
|
||||
swiftArgs.push_back(remapPath(overlay));
|
||||
@@ -217,12 +217,6 @@ ModuleDependencyVector ClangImporter::bridgeClangModuleDependencies(
|
||||
ctx.CASOpts.enumerateCASConfigurationFlags(
|
||||
[&](StringRef Arg) { swiftArgs.push_back(Arg.str()); });
|
||||
|
||||
if (!RootID.empty()) {
|
||||
swiftArgs.push_back("-no-clang-include-tree");
|
||||
swiftArgs.push_back("-cas-fs");
|
||||
swiftArgs.push_back(RootID);
|
||||
}
|
||||
|
||||
if (!IncludeTree.empty()) {
|
||||
swiftArgs.push_back("-clang-include-tree-root");
|
||||
swiftArgs.push_back(IncludeTree);
|
||||
@@ -324,11 +318,6 @@ void ClangImporter::getBridgingHeaderOptions(
|
||||
swiftArgs.push_back("-clang-include-tree-root");
|
||||
swiftArgs.push_back(*Tree);
|
||||
}
|
||||
if (auto CASFS = deps.CASFileSystemRootID) {
|
||||
swiftArgs.push_back("-no-clang-include-tree");
|
||||
swiftArgs.push_back("-cas-fs");
|
||||
swiftArgs.push_back(*CASFS);
|
||||
}
|
||||
}
|
||||
|
||||
ModuleDependencyVector
|
||||
|
||||
@@ -478,7 +478,6 @@ public:
|
||||
const bool BridgingHeaderExplicitlyRequested;
|
||||
const bool DisableOverlayModules;
|
||||
const bool EnableClangSPI;
|
||||
const bool UseClangIncludeTree;
|
||||
|
||||
bool IsReadingBridgingPCH;
|
||||
llvm::SmallVector<clang::serialization::SubmoduleID, 2> PCHImportedSubmodules;
|
||||
|
||||
@@ -316,8 +316,6 @@ private:
|
||||
}
|
||||
|
||||
// Collect CAS deppendencies from clang modules.
|
||||
if (!clangDepDetails.CASFileSystemRootID.empty())
|
||||
rootIDs.push_back(clangDepDetails.CASFileSystemRootID);
|
||||
if (!clangDepDetails.CASClangIncludeTreeRootID.empty()) {
|
||||
if (addIncludeTree(clangDepDetails.CASClangIncludeTreeRootID))
|
||||
return true;
|
||||
@@ -521,11 +519,6 @@ private:
|
||||
if (resolvingDepInfo.isSwiftInterfaceModule() ||
|
||||
resolvingDepInfo.isSwiftSourceModule()) {
|
||||
// Update with casfs option.
|
||||
for (auto rootID : rootIDs) {
|
||||
commandline.push_back("-cas-fs");
|
||||
commandline.push_back(rootID);
|
||||
}
|
||||
|
||||
if (computeCASFileSystem(dependencyInfoCopy))
|
||||
return true;
|
||||
}
|
||||
@@ -679,7 +672,6 @@ private:
|
||||
const ModuleDependencyInfo &resolvingDepInfo;
|
||||
|
||||
std::optional<SwiftDependencyTracker> tracker;
|
||||
std::vector<std::string> rootIDs;
|
||||
std::vector<llvm::cas::ObjectRef> fileListRefs;
|
||||
std::vector<std::string> commandline;
|
||||
std::vector<std::string> bridgingHeaderBuildCmd;
|
||||
|
||||
@@ -449,44 +449,12 @@ static llvm::Error createCASObjectNotFoundError(const llvm::cas::CASID &ID) {
|
||||
"CASID missing from Object Store " + ID.toString());
|
||||
}
|
||||
|
||||
static Expected<ObjectRef> mergeCASFileSystem(ObjectStore &CAS,
|
||||
ArrayRef<std::string> FSRoots) {
|
||||
llvm::cas::HierarchicalTreeBuilder Builder;
|
||||
for (auto &Root : FSRoots) {
|
||||
auto ID = CAS.parseID(Root);
|
||||
if (!ID)
|
||||
return ID.takeError();
|
||||
|
||||
auto Ref = CAS.getReference(*ID);
|
||||
if (!Ref)
|
||||
return createCASObjectNotFoundError(*ID);
|
||||
Builder.pushTreeContent(*Ref, "");
|
||||
}
|
||||
|
||||
auto NewRoot = Builder.create(CAS);
|
||||
if (!NewRoot)
|
||||
return NewRoot.takeError();
|
||||
|
||||
return NewRoot->getRef();
|
||||
}
|
||||
|
||||
Expected<IntrusiveRefCntPtr<vfs::FileSystem>>
|
||||
createCASFileSystem(ObjectStore &CAS, ArrayRef<std::string> FSRoots,
|
||||
const std::string &IncludeTree,
|
||||
createCASFileSystem(ObjectStore &CAS, const std::string &IncludeTree,
|
||||
const std::string &IncludeTreeFileList) {
|
||||
assert(!FSRoots.empty() || !IncludeTree.empty() ||
|
||||
assert(!IncludeTree.empty() ||
|
||||
!IncludeTreeFileList.empty() && "no root ID provided");
|
||||
|
||||
auto NewRoot = mergeCASFileSystem(CAS, FSRoots);
|
||||
if (!NewRoot)
|
||||
return NewRoot.takeError();
|
||||
|
||||
auto FS = createCASFileSystem(CAS, CAS.getID(*NewRoot));
|
||||
if (!FS)
|
||||
return FS.takeError();
|
||||
|
||||
auto CASFS = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(std::move(*FS));
|
||||
|
||||
if (!IncludeTree.empty()) {
|
||||
auto ID = CAS.parseID(IncludeTree);
|
||||
if (!ID)
|
||||
@@ -507,7 +475,7 @@ createCASFileSystem(ObjectStore &CAS, ArrayRef<std::string> FSRoots,
|
||||
if (!ITFS)
|
||||
return ITFS.takeError();
|
||||
|
||||
CASFS->pushOverlay(*ITFS);
|
||||
return *ITFS;
|
||||
}
|
||||
|
||||
if (!IncludeTreeFileList.empty()) {
|
||||
@@ -526,10 +494,10 @@ createCASFileSystem(ObjectStore &CAS, ArrayRef<std::string> FSRoots,
|
||||
if (!ITFS)
|
||||
return ITFS.takeError();
|
||||
|
||||
CASFS->pushOverlay(std::move(*ITFS));
|
||||
return *ITFS;
|
||||
}
|
||||
|
||||
return CASFS;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<std::string> remapPathsFromCommandLine(
|
||||
|
||||
@@ -792,8 +792,6 @@ static bool ParseCASArgs(CASOptions &Opts, ArgList &Args,
|
||||
std::string(Value));
|
||||
}
|
||||
|
||||
for (const auto &A : Args.getAllArgValues(OPT_cas_fs))
|
||||
Opts.CASFSRootIDs.emplace_back(A);
|
||||
if (auto *A = Args.getLastArg(OPT_clang_include_tree_root))
|
||||
Opts.ClangIncludeTree = A->getValue();
|
||||
if (auto *A = Args.getLastArg(OPT_clang_include_tree_filelist))
|
||||
@@ -805,8 +803,7 @@ static bool ParseCASArgs(CASOptions &Opts, ArgList &Args,
|
||||
if (const Arg*A = Args.getLastArg(OPT_bridging_header_pch_key))
|
||||
Opts.BridgingHeaderPCHCacheKey = A->getValue();
|
||||
|
||||
if (!Opts.CASFSRootIDs.empty() || !Opts.ClangIncludeTree.empty() ||
|
||||
!Opts.ClangIncludeTreeFileList.empty())
|
||||
if (!Opts.ClangIncludeTree.empty() || !Opts.ClangIncludeTreeFileList.empty())
|
||||
Opts.HasImmutableFileSystem = true;
|
||||
|
||||
return false;
|
||||
@@ -2161,10 +2158,6 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts, ArgList &Args,
|
||||
// Forward the FrontendOptions to clang importer option so it can be
|
||||
// accessed when creating clang module compilation invocation.
|
||||
if (CASOpts.EnableCaching) {
|
||||
// Only set UseClangIncludeTree when caching is enabled since it is not
|
||||
// useful in non-caching context.
|
||||
Opts.UseClangIncludeTree |= !Args.hasArg(OPT_no_clang_include_tree);
|
||||
Opts.HasClangIncludeTreeRoot |= Args.hasArg(OPT_clang_include_tree_root);
|
||||
// Caching requires direct clang import cc1 scanning.
|
||||
Opts.ClangImporterDirectCC1Scan = true;
|
||||
}
|
||||
|
||||
@@ -630,11 +630,9 @@ bool CompilerInstance::setUpVirtualFileSystemOverlays() {
|
||||
}
|
||||
|
||||
if (Invocation.getCASOptions().requireCASFS()) {
|
||||
if (!CASOpts.CASFSRootIDs.empty() || !CASOpts.ClangIncludeTree.empty() ||
|
||||
!CASOpts.ClangIncludeTreeFileList.empty()) {
|
||||
if (Invocation.getCASOptions().HasImmutableFileSystem) {
|
||||
// Set up CASFS as BaseFS.
|
||||
auto FS = createCASFileSystem(*CAS, CASOpts.CASFSRootIDs,
|
||||
CASOpts.ClangIncludeTree,
|
||||
auto FS = createCASFileSystem(*CAS, CASOpts.ClangIncludeTree,
|
||||
CASOpts.ClangIncludeTreeFileList);
|
||||
if (!FS) {
|
||||
Diagnostics.diagnose(SourceLoc(), diag::error_cas_fs_creation,
|
||||
@@ -682,8 +680,8 @@ bool CompilerInstance::setUpVirtualFileSystemOverlays() {
|
||||
}
|
||||
}
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayVFS =
|
||||
new llvm::vfs::OverlayFileSystem(SourceMgr.getFileSystem());
|
||||
OverlayVFS->pushOverlay(MemFS);
|
||||
new llvm::vfs::OverlayFileSystem(MemFS);
|
||||
OverlayVFS->pushOverlay(SourceMgr.getFileSystem());
|
||||
SourceMgr.setFileSystem(std::move(OverlayVFS));
|
||||
}
|
||||
|
||||
@@ -967,10 +965,10 @@ std::string CompilerInstance::getBridgingHeaderPath() const {
|
||||
}
|
||||
|
||||
bool CompilerInstance::setUpInputs() {
|
||||
// There is no input file when building PCM using ClangIncludeTree.
|
||||
// There is no input file when building PCM using Caching.
|
||||
if (Invocation.getFrontendOptions().RequestedAction ==
|
||||
FrontendOptions::ActionType::EmitPCM &&
|
||||
Invocation.getClangImporterOptions().HasClangIncludeTreeRoot)
|
||||
Invocation.getCASOptions().EnableCaching)
|
||||
return false;
|
||||
|
||||
// Adds to InputSourceCodeBufferIDs, so may need to happen before the
|
||||
|
||||
@@ -1815,13 +1815,6 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
|
||||
casOpts.HasImmutableFileSystem;
|
||||
casOpts.enumerateCASConfigurationFlags(
|
||||
[&](StringRef Arg) { GenericArgs.push_back(ArgSaver.save(Arg)); });
|
||||
// ClangIncludeTree is default on when caching is enabled.
|
||||
genericSubInvocation.getClangImporterOptions().UseClangIncludeTree = true;
|
||||
}
|
||||
|
||||
if (!clangImporterOpts.UseClangIncludeTree) {
|
||||
genericSubInvocation.getClangImporterOptions().UseClangIncludeTree = false;
|
||||
GenericArgs.push_back("-no-clang-include-tree");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2521,8 +2514,7 @@ struct ExplicitCASModuleLoader::Implementation {
|
||||
};
|
||||
for (auto &entry : ExplicitClangModuleMap) {
|
||||
const auto &moduleMapPath = entry.getValue().moduleMapPath;
|
||||
if (!moduleMapPath.empty() &&
|
||||
!Ctx.ClangImporterOpts.UseClangIncludeTree &&
|
||||
if (!moduleMapPath.empty() && !Ctx.CASOpts.EnableCaching &&
|
||||
moduleMapsSeen.find(moduleMapPath) == moduleMapsSeen.end()) {
|
||||
moduleMapsSeen.insert(moduleMapPath);
|
||||
extraClangArgs.push_back(
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: mkdir -p %t/empty
|
||||
// RUN: mkdir -p %t/cas
|
||||
|
||||
// RUN: llvm-cas --cas %t/cas --ingest %t/empty > %t/empty.casid
|
||||
// RUN: not %target-swift-frontend -typecheck -cache-compile-job -cas-fs @%t/empty.casid -cas-path %t/cas %s 2>&1 | %FileCheck %s --check-prefix NO-INPUTS
|
||||
// NO-INPUTS: error: error opening input file
|
||||
|
||||
// RUN: llvm-cas --cas %t/cas --ingest %s > %t/source.casid
|
||||
// RUN: not %target-swift-frontend -typecheck -cache-compile-job -cas-fs @%t/source.casid -cas-path %t/cas %s 2>&1 | %FileCheck %s --check-prefix NO-RESOURCES
|
||||
// NO-RESOURCES: error: unable to load standard library
|
||||
|
||||
/// Ingest the resource directory to satisfy the file system requirement. Also switch CWD to resource dir.
|
||||
// RUN: llvm-cas --cas %t/cas --merge @%t/source.casid %test-resource-dir > %t/full.casid
|
||||
// RUN: cd %test-resource-dir
|
||||
// RUN: %target-swift-frontend -typecheck -cache-compile-job -cas-fs @%t/full.casid -cas-path %t/cas %s
|
||||
|
||||
/// Try clang importer.
|
||||
// RUN: not %target-swift-frontend -typecheck -cache-compile-job -cas-fs @%t/full.casid -cas-path %t/cas %s -import-objc-header %S/Inputs/objc.h 2>&1 | %FileCheck %s --check-prefix NO-BRIDGING-HEADER
|
||||
// NO-BRIDGING-HEADER: error: bridging header
|
||||
|
||||
// RUN: llvm-cas --cas %t/cas --merge @%t/full.casid %S/Inputs/objc.h > %t/bridging_header.casid
|
||||
// RUN: %target-swift-frontend -typecheck -cache-compile-job -cas-fs @%t/bridging_header.casid -cas-path %t/cas %s -import-objc-header %S/Inputs/objc.h
|
||||
|
||||
/// Clean the CAS to save space.
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
func testFunc() {}
|
||||
@@ -2,7 +2,7 @@
|
||||
// RUN: mkdir -p %t/cas
|
||||
|
||||
// RUN: not %target-swift-frontend -c -cache-compile-job -cas-path %t/cas %s -o %t/test.o 2>&1 | %FileCheck %s --check-prefix=NO-CASFS
|
||||
// NO-CASFS: caching is enabled without -cas-fs option
|
||||
// NO-CASFS: caching is enabled without CAS file-system options
|
||||
|
||||
// RUN: %target-swift-frontend -scan-dependencies -module-name Test -O \
|
||||
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -parse-stdlib \
|
||||
|
||||
@@ -1,197 +0,0 @@
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: mkdir -p %t/clang-module-cache
|
||||
// RUN: mkdir -p %t/cas
|
||||
|
||||
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -enable-cross-import-overlays -cache-compile-job -cas-path %t/cas -no-clang-include-tree -scanner-output-dir %t -auto-bridging-header-chaining
|
||||
// Check the contents of the JSON output
|
||||
// RUN: %validate-json %t/deps.json &>/dev/null
|
||||
// RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK_NO_CLANG_TARGET %s < %t/deps.json
|
||||
|
||||
// Check the contents of the JSON output
|
||||
// RUN: %FileCheck %s -check-prefix CHECK -check-prefix CHECK-NO-SEARCH-PATHS < %t/deps.json
|
||||
|
||||
// Check the make-style dependencies file
|
||||
// RUN: %FileCheck %s -check-prefix CHECK-MAKE-DEPS < %t/deps.d
|
||||
|
||||
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -test-dependency-scan-cache-serialization -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -enable-cross-import-overlays -cache-compile-job -cas-path %t/cas -no-clang-include-tree -scanner-output-dir %t -auto-bridging-header-chaining
|
||||
// RUN: %validate-json %t/deps.json &>/dev/null
|
||||
// RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK_NO_CLANG_TARGET %s < %t/deps.json
|
||||
|
||||
// Ensure that scanning with `-clang-target` makes sure that Swift modules' respective PCM-dependency-build-argument sets do not contain target triples.
|
||||
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -module-cache-path %t/clang-module-cache %s -o %t/deps_clang_target.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -enable-cross-import-overlays -clang-target %target-cpu-apple-macosx10.14 -cache-compile-job -cas-path %t/cas -no-clang-include-tree
|
||||
|
||||
/// check cas-fs content
|
||||
// RUN: %{python} %S/Inputs/SwiftDepsExtractor.py %t/deps.json E casFSRootID > %t/E_fs.casid
|
||||
// RUN: %cache-tool -cas-path %t/cas -cache-tool-action print-include-tree-list @%t/E_fs.casid | %FileCheck %s -check-prefix FS_ROOT_E
|
||||
// RUN: %{python} %S/Inputs/SwiftDepsExtractor.py %t/deps.json clang:F casFSRootID > %t/F_fs.casid
|
||||
// RUN: llvm-cas --cas %t/cas --ls-tree-recursive @%t/F_fs.casid | %FileCheck %s -check-prefix FS_ROOT_F
|
||||
|
||||
// RUN: %{python} %S/Inputs/SwiftDepsExtractor.py %t/deps.json deps commandLine > %t/deps.cmd
|
||||
// RUN: %FileCheck %s -check-prefix MAIN_CMD -input-file=%t/deps.cmd
|
||||
|
||||
// FS_ROOT_E-DAG: E.swiftinterface
|
||||
// FS_ROOT_E-DAG: SDKSettings.json
|
||||
|
||||
// FS_ROOT_F: CHeaders/A.h
|
||||
// FS_ROOT_F: CHeaders/B.h
|
||||
// FS_ROOT_F: CHeaders/C.h
|
||||
// FS_ROOT_F: CHeaders/D.h
|
||||
// FS_ROOT_F: CHeaders/F.h
|
||||
// FS_ROOT_F: CHeaders/G.h
|
||||
// FS_ROOT_F: CHeaders/H.h
|
||||
// FS_ROOT_F: CHeaders/I.h
|
||||
// FS_ROOT_F: CHeaders/X.h
|
||||
// FS_ROOT_F: CHeaders/module.modulemap
|
||||
|
||||
// MAIN_CMD: -direct-clang-cc1-module-build
|
||||
// MAIN_CMD: -cas-fs
|
||||
// MAIN_CMD-NOT: -clang-include-tree-root
|
||||
|
||||
import C
|
||||
import E
|
||||
import G
|
||||
import SubE
|
||||
|
||||
// CHECK: "mainModuleName": "deps"
|
||||
|
||||
/// --------Main module
|
||||
// CHECK-LABEL: "modulePath": "deps.swiftmodule",
|
||||
// CHECK-NEXT: sourceFiles
|
||||
// CHECK-NEXT: module_deps.swift
|
||||
// CHECK-NEXT: ],
|
||||
// CHECK-NEXT: "directDependencies": [
|
||||
// CHECK-DAG: "clang": "C"
|
||||
// CHECK-DAG: "swift": "E"
|
||||
// CHECK-DAG: "swift": "G"
|
||||
// CHECK-DAG: "swift": "SubE"
|
||||
// CHECK-DAG: "swift": "Swift"
|
||||
// CHECK-DAG: "swift": "SwiftOnoneSupport"
|
||||
// CHECK-DAG: "swift": "_Concurrency"
|
||||
// CHECK-DAG: "swift": "_cross_import_E"
|
||||
// CHECK: ],
|
||||
// CHECK: "commandLine":
|
||||
// CHECK: "casFSRootID":
|
||||
// CHECK-NOT: "error: cannot open Swift placeholder dependency module map from"
|
||||
// CHECK: "bridgingHeader":
|
||||
// CHECK-NEXT: "path":
|
||||
// CHECK-SAME: Bridging.h
|
||||
|
||||
// CHECK-NEXT: "sourceFiles":
|
||||
// CHECK-NEXT: ChainedBridgingHeader.h
|
||||
// CHECK-NEXT: Bridging.h
|
||||
// CHECK-NEXT: BridgingOther.h
|
||||
|
||||
// CHECK: "moduleDependencies": [
|
||||
// CHECK-NEXT: "F"
|
||||
// CHECK-NEXT: ]
|
||||
|
||||
// CHECK: "swiftOverlayDependencies": [
|
||||
// CHECK-DAG: "swift": "A"
|
||||
// CHECK-DAG: "swift": "F"
|
||||
|
||||
/// --------Clang module C
|
||||
// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}C-{{.*}}.pcm",
|
||||
|
||||
// CHECK: "sourceFiles": [
|
||||
// CHECK-DAG: module.modulemap
|
||||
// CHECK-DAG: C.h
|
||||
|
||||
// CHECK: directDependencies
|
||||
// CHECK-NEXT: {
|
||||
// CHECK-NEXT: "clang": "B"
|
||||
|
||||
// CHECK: "moduleMapPath"
|
||||
// CHECK-SAME: module.modulemap
|
||||
|
||||
// CHECK: "contextHash"
|
||||
// CHECK-SAME: "{{.*}}"
|
||||
|
||||
/// --------Clang module B
|
||||
// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}B-{{.*}}.pcm",
|
||||
// CHECK: "contextHash": "[[B_CONTEXT:.*]]",
|
||||
// CHECK: "-o"
|
||||
// CHECK-NEXT: B-{{.*}}[[B_CONTEXT]].pcm
|
||||
|
||||
// Check make-style dependencies
|
||||
// CHECK-MAKE-DEPS: module_deps.swift
|
||||
// CHECK-MAKE-DEPS-SAME: A.swiftinterface
|
||||
// CHECK-MAKE-DEPS-SAME: G.swiftinterface
|
||||
// CHECK-MAKE-DEPS-SAME: B.h
|
||||
// CHECK-MAKE-DEPS-SAME: Bridging.h
|
||||
// CHECK-MAKE-DEPS-SAME: BridgingOther.h
|
||||
// CHECK-MAKE-DEPS-SAME: module.modulemap
|
||||
|
||||
/// --------Swift module F
|
||||
// CHECK: "modulePath": "{{.*}}{{/|\\}}F-{{.*}}.swiftmodule",
|
||||
// CHECK-NEXT: "sourceFiles": [
|
||||
// CHECK-NEXT: ],
|
||||
// CHECK-NEXT: "directDependencies": [
|
||||
// CHECK-NEXT: {
|
||||
// CHECK-DAG: "clang": "F"
|
||||
// CHECK-DAG: "swift": "Swift"
|
||||
// CHECK-DAG: "swift": "SwiftOnoneSupport"
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: ],
|
||||
// CHECK: "details":
|
||||
// CHECK: "moduleCacheKey":
|
||||
|
||||
/// --------Swift module A
|
||||
// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}A-{{.*}}.swiftmodule",
|
||||
|
||||
// CHECK: directDependencies
|
||||
// CHECK-NEXT: {
|
||||
// CHECK-DAG: "clang": "A"
|
||||
// CHECK-DAG: "swift": "Swift"
|
||||
// CHECK-DAG: "swift": "SwiftOnoneSupport"
|
||||
// CHECK-NEXT: }
|
||||
// CHECK: "details":
|
||||
// CHECK: "moduleCacheKey":
|
||||
|
||||
/// --------Swift module G
|
||||
// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}G-{{.*}}.swiftmodule"
|
||||
// CHECK: "directDependencies"
|
||||
// CHECK-NEXT: {
|
||||
// CHECK-DAG: "clang": "G"
|
||||
// CHECK-DAG: "swift": "Swift"
|
||||
// CHECK-DAG: "swift": "SwiftOnoneSupport"
|
||||
// CHECK: ],
|
||||
// CHECK-NEXT: "linkLibraries": [
|
||||
// CHECK: "details": {
|
||||
|
||||
// CHECK: "commandLine": [
|
||||
// CHECK: "-compile-module-from-interface"
|
||||
// CHECK: "-target"
|
||||
// CHECK: "-cache-compile-job"
|
||||
// CHECK: "-cas-path"
|
||||
// CHECK: "-module-name"
|
||||
// CHECK: "G"
|
||||
// CHECK: "-swift-version"
|
||||
// CHECK: "5"
|
||||
// CHECK: ],
|
||||
// CHECK: "contextHash": "{{.*}}",
|
||||
|
||||
/// --------Swift module E
|
||||
// CHECK: "swift": "E"
|
||||
// CHECK-LABEL: modulePath": "{{.*}}{{/|\\}}E-{{.*}}.swiftmodule"
|
||||
// CHECK: "directDependencies"
|
||||
// CHECK-NEXT: {
|
||||
// CHECK-NEXT: "swift": "Swift"
|
||||
|
||||
// CHECK: "moduleInterfacePath"
|
||||
// CHECK-SAME: E.swiftinterface
|
||||
|
||||
/// --------Swift module Swift
|
||||
// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}Swift-{{.*}}.swiftmodule",
|
||||
|
||||
// CHECK: directDependencies
|
||||
// CHECK-NEXT: {
|
||||
// CHECK-NEXT: "clang": "SwiftShims"
|
||||
|
||||
/// --------Clang module SwiftShims
|
||||
// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}SwiftShims-{{.*}}.pcm",
|
||||
// CHECK: "contextHash": "[[SHIMS_CONTEXT:.*]]",
|
||||
// CHECK: "-o"
|
||||
// CHECK-NEXT: SwiftShims-{{.*}}[[SHIMS_CONTEXT]].pcm
|
||||
// CHECK-NO-SEARCH-PATHS-NOT: "-prebuilt-module-cache-path"
|
||||
Reference in New Issue
Block a user