diff --git a/clang-tools-extra/clangd/ScanningProjectModules.cpp b/clang-tools-extra/clangd/ScanningProjectModules.cpp index a6967f376961e..7eb15de91464d 100644 --- a/clang-tools-extra/clangd/ScanningProjectModules.cpp +++ b/clang-tools-extra/clangd/ScanningProjectModules.cpp @@ -38,7 +38,7 @@ class ModuleDependencyScanner { : CDB(CDB), TFS(TFS), Service(tooling::dependencies::ScanningMode::CanonicalPreprocessing, tooling::dependencies::ScanningOutputFormat::P1689, - CASOptions(), nullptr, nullptr, nullptr) {} + CASOptions(), nullptr, nullptr) {} /// The scanned modules dependency information for a specific source file. struct ModuleDependencyInfo { diff --git a/clang/include/clang/Basic/DiagnosticCASKinds.td b/clang/include/clang/Basic/DiagnosticCASKinds.td index f37b134859ff7..d378edbe672a6 100644 --- a/clang/include/clang/Basic/DiagnosticCASKinds.td +++ b/clang/include/clang/Basic/DiagnosticCASKinds.td @@ -11,8 +11,9 @@ let Component = "CAS" in { def err_cas_cannot_be_initialized : Error< "CAS cannot be initialized from the specified '-fcas-*' options: %0">, DefaultFatal; -def err_cas_cannot_parse_root_id : Error< - "CAS cannot parse root-id '%0' specified by -fcas-fs">, DefaultFatal; +def err_cas_cannot_parse_root_id + : Error<"CAS cannot parse root-id '%0' specified by '-fcas-*' options">, + DefaultFatal; def err_cas_filesystem_cannot_be_initialized : Error< "CAS filesystem cannot be initialized from root-id '%0': %1">, DefaultFatal; def err_cas_filesystem_cannot_set_working_directory : Error< diff --git a/clang/include/clang/Basic/FileSystemOptions.h b/clang/include/clang/Basic/FileSystemOptions.h index d1c6a67884fdd..458af0c7b6592 100644 --- a/clang/include/clang/Basic/FileSystemOptions.h +++ b/clang/include/clang/Basic/FileSystemOptions.h @@ -24,14 +24,6 @@ class FileSystemOptions { /// If set, paths are resolved as if the working directory was /// set to the value of WorkingDir. std::string WorkingDir; - - /// If set, uses this root ID with \a CASFileSystem. - std::string CASFileSystemRootID; - - /// If set, used as the working directory for -fcas-fs. - /// - /// FIXME: Merge with WorkingDir? - std::string CASFileSystemWorkingDirectory; }; } // end namespace clang diff --git a/clang/include/clang/Frontend/CompileJobCacheKey.h b/clang/include/clang/Frontend/CompileJobCacheKey.h index b14aebf277ca6..f3475f9d87fe7 100644 --- a/clang/include/clang/Frontend/CompileJobCacheKey.h +++ b/clang/include/clang/Frontend/CompileJobCacheKey.h @@ -33,7 +33,6 @@ class DiagnosticsEngine; enum class CachingInputKind { IncludeTree, - FileSystemRoot, CachedCompilation, Object, }; diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index eccd22f06e115..e83a52aa28718 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -2513,23 +2513,12 @@ class Preprocessor { /// See \c FrontendOptions::CASIncludeTreeID. std::optional CASIncludeTreeID; - /// The cas-fs tree that is being built, if any. - /// See \c FileSystemOptions::CASFileSystemRootID. - std::optional CASFileSystemRootID; - public: std::optional getCASIncludeTreeID() const { return CASIncludeTreeID; } void setCASIncludeTreeID(std::string ID) { CASIncludeTreeID = std::move(ID); } - std::optional getCASFileSystemRootID() const { - return CASFileSystemRootID; - } - void setCASFileSystemRootID(std::string ID) { - CASFileSystemRootID = std::move(ID); - } - /// Allocate a new MacroInfo object with the provided SourceLocation. MacroInfo *AllocateMacroInfo(SourceLocation L); diff --git a/clang/include/clang/Options/Options.td b/clang/include/clang/Options/Options.td index eca2494c20899..7656ef20b8fbc 100644 --- a/clang/include/clang/Options/Options.td +++ b/clang/include/clang/Options/Options.td @@ -9065,40 +9065,6 @@ def fsycl_is_host : Flag<["-"], "fsycl-is-host">, // CAS Options //===----------------------------------------------------------------------===// -// Example command-lines we expect: -// -// For building against some pre-ingested, CAS-based filesystem in the builtin -// on-disk CAS: -// ``` -// % clang -fcas-path=auto -fcas-fs=llvmcas://1af12fa2afa1af2a1fa -// % clang -fcas-path=path/to/cas -fcas-fs=llvmcas://1af12fa2afa1af2a1fa -// ``` -// -// For building against some pre-ingested, CAS-based filesystem using a plugin: -// ``` -// % clang -fcas-plugin=path/to/some/cas-plugind \ -// -fcas-plugin-args=-X,-Y,-Z \ -// -fcas-fs=llvmcas://1af12fa2afa1af2a1fa -// ``` -// -// For automatically ingesting from the live filesystem into a CAS, -// canonicalizing the paths, and running the `-cc1` against the CAS tree: -// ``` -// % clang -fdepscan \ -// -fdepscan-prefix-map=/my/sources=/^src \ -// -fdepscan-prefix-map=/my/build/dir=/^build -// ``` -// -// For pruning and canonicalizing even when starting from a pre-ingested, -// CAS-based filesystem: -// ``` -// % clang -fcas-path=path/to/the/cas \ -// -fcas-fs=llvmcas://1af12fa2afa1af2a1fa \ -// -fdepscan \ -// -fdepscan-prefix-map=/my/sources=/^src \ -// -fdepscan-prefix-map=/my/build/dir=/^build -// ``` - // Driver CAS options. def fdepscan_EQ : Joined<["-"], "fdepscan=">, Group, @@ -9155,10 +9121,6 @@ def fdepscan_daemon_EQ : Joined<["-"], "fdepscan-daemon=">, Group, " daemon specified, rather than try to spawn its own based on" " parent processes.">; -def fdepscan_include_tree : Flag<["-"], "fdepscan-include-tree">, - Visibility<[ClangOption, CLOption]>, - Group, HelpText<"Set dep-scanner to produce the include tree">; - // CAS prefix map options. // // FIXME: Add DepscanOption flag. @@ -9219,20 +9181,6 @@ def fcas_plugin_option : Separate<["-"], "fcas-plugin-option">, HelpText<"Option to pass to the CAS plugin.">, MarshallingInfoStringPairVector>; -// FIXME: Add to driver once it's supported by -fdepscan. -def fcas_fs : Separate<["-"], "fcas-fs">, - Group, MetaVarName<"">, - HelpText<"Configure the filesystem to read from the provided CAS tree." - " See also -fcas-builtin-path for loading a tree.">, - MarshallingInfoString>; - -// FIXME: Remove / merge with -fworking-directory? -def fcas_fs_working_directory : Separate<["-"], "fcas-fs-working-directory">, - Group, MetaVarName<"">, - HelpText<"Working directory for -fcas-fs (if not the root).">, - ShouldParseIf, - MarshallingInfoString>; - def fcas_include_tree : Separate<["-"], "fcas-include-tree">, Group, MetaVarName<"">, HelpText<"Configure the frontend to use a CAS include tree.">, diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index 1500724060e8d..d3ea57aba4555 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -379,10 +379,6 @@ enum ControlRecordTypes { /// Record code for the (optional) \c ActionCache key for this module. MODULE_CACHE_KEY, - /// Record code for the (optional) CAS filesystem root ID for implicit modules - /// built with the dependency scanner. - CASFS_ROOT_ID, - /// Record code for the (optional) include-tree ID for implicit modules /// built with the dependency scanner. CAS_INCLUDE_TREE_ID, diff --git a/clang/include/clang/Serialization/ModuleFile.h b/clang/include/clang/Serialization/ModuleFile.h index 962ab090af5d7..1c165f32fe0e6 100644 --- a/clang/include/clang/Serialization/ModuleFile.h +++ b/clang/include/clang/Serialization/ModuleFile.h @@ -150,10 +150,6 @@ class ModuleFile { /// The \c CASID for the module, or empty. std::string CASID; - /// The CAS filesystem root ID for implicit modules built with the dependency - /// scanner, or empty. - std::string CASFileSystemRootID; - /// The include-tree root ID for implicit modules built with the dependency /// scanner, or empty. std::string IncludeTreeID; diff --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningCASFilesystem.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningCASFilesystem.h deleted file mode 100644 index b27d2c0ce9615..0000000000000 --- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningCASFilesystem.h +++ /dev/null @@ -1,122 +0,0 @@ -//===- DependencyScanningCASFilesystem.h - clang-scan-deps fs ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGCASFILESYSTEM_H -#define LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGCASFILESYSTEM_H - -#include "clang/Basic/LLVM.h" -#include "clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/ADT/StringSet.h" -#include "llvm/CAS/ActionCache.h" -#include "llvm/CAS/CASFileSystem.h" -#include "llvm/CAS/CASID.h" -#include "llvm/CAS/CASReference.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/ErrorOr.h" -#include "llvm/Support/VirtualFileSystem.h" -#include - -namespace llvm { -namespace cas { -class CachingOnDiskFileSystem; -} // namespace cas -} // namespace llvm - -namespace clang { -namespace tooling { -namespace dependencies { - -class DependencyScanningCASFilesystem - : public llvm::RTTIExtends { -public: - static const char ID; - - DependencyScanningCASFilesystem(DependencyScanningService &Service, - IntrusiveRefCntPtr WorkerFS); - - ~DependencyScanningCASFilesystem(); - - // FIXME: Make a templated version of ProxyFileSystem with a configurable - // base class. - llvm::vfs::directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override { - return FS->dir_begin(Dir, EC); - } - llvm::ErrorOr getCurrentWorkingDirectory() const override { - return FS->getCurrentWorkingDirectory(); - } - std::error_code setCurrentWorkingDirectory(const Twine &Path) override { - return FS->setCurrentWorkingDirectory(Path); - } - std::error_code getRealPath(const Twine &Path, - SmallVectorImpl &Output) override { - return FS->getRealPath(Path, Output); - } - std::error_code isLocal(const Twine &Path, bool &Result) override { - return FS->isLocal(Path, Result); - } - - IntrusiveRefCntPtr - createThreadSafeProxyFS() override; - - llvm::ErrorOr status(const Twine &Path) override; - bool exists(const Twine &Path) override; - llvm::Expected> - openCASBackedFileForRead(const Twine &Path) override; - - /// \returns The scanned preprocessor directive tokens of the file that are - /// used to speed up preprocessing, if available. - std::optional> - getDirectiveTokens(const Twine &Path); - -private: - IntrusiveRefCntPtr FS; - - struct FileEntry { - std::error_code EC; // If non-zero, caches a stat failure. - std::optional Buffer; - SmallVector DepTokens; - SmallVector DepDirectives; - llvm::vfs::Status Status; - std::optional CASContents; - }; - llvm::BumpPtrAllocator EntryAlloc; - llvm::StringMap Entries; - - struct LookupPathResult { - const FileEntry *Entry = nullptr; - - // Only filled if the Entry is nullptr. - llvm::ErrorOr Status; - }; - void scanForDirectives( - llvm::cas::ObjectRef InputDataID, StringRef Identifier, - SmallVectorImpl &DepTokens, - SmallVectorImpl &DepDirectives); - - Expected getOriginal(llvm::cas::CASID InputDataID); - - LookupPathResult lookupPath(const Twine &Path); - - llvm::cas::CachingOnDiskFileSystem &getCachingFS(); - - llvm::cas::ObjectStore &CAS; - llvm::cas::ActionCache &Cache; - /// The service associated with this VFS. - DependencyScanningService &Service; - std::optional ClangFullVersionID; - std::optional DepDirectivesID; - std::optional EmptyBlobID; -}; - -} // end namespace dependencies -} // end namespace tooling -} // end namespace clang - -#endif // LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGCASFILESYSTEM_H diff --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h index c995d7d8ebad7..7ae422ee9897b 100644 --- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h +++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h @@ -10,12 +10,10 @@ #define LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H #include "clang/CAS/CASOptions.h" -#include "clang/Tooling/DependencyScanning/DependencyScanningCASFilesystem.h" #include "clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h" #include "clang/Tooling/DependencyScanning/InProcessModuleCache.h" #include "llvm/ADT/BitmaskEnum.h" #include "llvm/CAS/ActionCache.h" -#include "llvm/CAS/CachingOnDiskFileSystem.h" #include "llvm/Support/Chrono.h" namespace clang { @@ -46,13 +44,6 @@ enum class ScanningOutputFormat { /// explicitly building modules. Full, - /// This emits the CAS ID of the scanned files. - Tree, - - /// This emits the full dependency graph but with CAS tree embedded as file - /// dependency. - FullTree, - /// This emits the CAS ID of the include tree. IncludeTree, @@ -111,7 +102,6 @@ class DependencyScanningService { ScanningMode Mode, ScanningOutputFormat Format, CASOptions CASOpts, std::shared_ptr CAS, std::shared_ptr Cache, - IntrusiveRefCntPtr SharedFS, ScanningOptimizations OptimizeArgs = ScanningOptimizations::Default, bool EagerLoadModules = false, bool TraceVFS = false, std::time_t BuildSessionTimestamp = @@ -131,9 +121,7 @@ class DependencyScanningService { bool shouldCacheNegativeStats() const { return CacheNegativeStats; } DependencyScanningFilesystemSharedCache &getSharedCache() { - assert(!SharedFS && "Expected not to have a CASFS"); - assert(SharedCache && "Expected a shared cache"); - return *SharedCache; + return SharedCache; } const CASOptions &getCASOpts() const { return CASOpts; } @@ -141,10 +129,6 @@ class DependencyScanningService { std::shared_ptr getCAS() const { return CAS; } std::shared_ptr getCache() const { return Cache; } - llvm::cas::CachingOnDiskFileSystem &getSharedFS() { return *SharedFS; } - - bool useCASFS() const { return (bool)SharedFS; } - ModuleCacheEntries &getModuleCacheEntries() { return ModCacheEntries; } std::time_t getBuildSessionTimestamp() const { return BuildSessionTimestamp; } @@ -162,11 +146,8 @@ class DependencyScanningService { /// Whether to trace VFS accesses. const bool TraceVFS; const bool CacheNegativeStats; - /// Shared CachingOnDiskFileSystem. Set to nullptr to not use CAS dependency - /// scanning. - IntrusiveRefCntPtr SharedFS; /// The global file system cache. - std::optional SharedCache; + DependencyScanningFilesystemSharedCache SharedCache; /// The global module cache entries. ModuleCacheEntries ModCacheEntries; /// The build session timestamp. diff --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h index 766e977f43cd8..b553013db442c 100644 --- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h +++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h @@ -73,9 +73,6 @@ struct TranslationUnitDeps { /// includes both direct and transitive module dependencies. std::vector VisibleModules; - /// The CASID for input file dependency tree. - std::optional CASFileSystemRootID; - /// The include-tree for input file dependency tree. std::optional IncludeTreeID; @@ -146,20 +143,6 @@ class DependencyScanningTool { MakeformatOutputPath); } - /// Collect dependency tree. - llvm::Expected - getDependencyTree(const std::vector &CommandLine, StringRef CWD); - - /// If \p DiagGenerationAsCompilation is true it will generate error - /// diagnostics same way as the normal compilation, with "N errors generated" - /// message and the serialized diagnostics file emitted if the - /// \p DiagOpts.DiagnosticSerializationFile setting is set for the invocation. - llvm::Expected - getDependencyTreeFromCompilerInvocation( - std::shared_ptr Invocation, StringRef CWD, - DiagnosticConsumer &DiagsConsumer, raw_ostream *VerboseOS, - bool DiagGenerationAsCompilation); - Expected getIncludeTree(cas::ObjectStore &DB, const std::vector &CommandLine, StringRef CWD, @@ -255,17 +238,6 @@ class DependencyScanningTool { const CASOptions &getCASOpts() const { return Worker.getCASOpts(); } - CachingOnDiskFileSystemPtr getCachingFileSystem() { - return Worker.getCASFS(); - } - - /// If \p DependencyScanningService enabled sharing of \p FileManager this - /// will return the same instance, otherwise it will create a new one for - /// each invocation. - llvm::IntrusiveRefCntPtr getOrCreateFileManager() const { - return Worker.getOrCreateFileManager(); - } - static std::unique_ptr createActionController(DependencyScanningWorker &Worker, LookupModuleOutputCallback LookupModuleOutput); @@ -313,10 +285,6 @@ class FullDependencyConsumer : public DependencyConsumer { ContextHash = std::move(Hash); } - void handleCASFileSystemRootID(std::string ID) override { - CASFileSystemRootID = std::move(ID); - } - void handleIncludeTreeID(std::string ID) override { IncludeTreeID = std::move(ID); } @@ -341,7 +309,6 @@ class FullDependencyConsumer : public DependencyConsumer { std::vector VisibleModules; std::vector Commands; std::string ContextHash; - std::optional CASFileSystemRootID; std::optional IncludeTreeID; const llvm::DenseSet &AlreadySeen; }; diff --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h index e832c2b1527de..bbeee1f3e2e85 100644 --- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h +++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h @@ -15,7 +15,6 @@ #include "clang/Frontend/PCHContainerOperations.h" #include "clang/Tooling/DependencyScanning/DependencyScanningService.h" #include "clang/Tooling/DependencyScanning/ModuleDepCollector.h" -#include "llvm/CAS/CachingOnDiskFileSystem.h" #include "llvm/Support/Error.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBufferRef.h" @@ -28,10 +27,6 @@ class DependencyOutputOptions; namespace tooling { namespace dependencies { - -using CachingOnDiskFileSystemPtr = - llvm::IntrusiveRefCntPtr; - class DependencyScanningWorkerFilesystem; class CompilerInstanceWithContext; @@ -71,8 +66,6 @@ class DependencyConsumer { virtual void handleContextHash(std::string Hash) = 0; - virtual void handleCASFileSystemRootID(std::string ID) {} - virtual void handleIncludeTreeID(std::string ID) {} }; @@ -211,15 +204,9 @@ class DependencyScanningWorker { ScanningOutputFormat getScanningFormat() const { return Service.getFormat(); } - CachingOnDiskFileSystemPtr getCASFS() { return CacheFS; } const CASOptions &getCASOpts() const { return CASOpts; } std::shared_ptr getCAS() const { return CAS; } - /// If \p DependencyScanningService enabled sharing of \p FileManager this - /// will return the same instance, otherwise it will create a new one for - /// each invocation. - llvm::IntrusiveRefCntPtr getOrCreateFileManager() const; - llvm::vfs::FileSystem &getVFS() const { return *BaseFS; } private: @@ -235,10 +222,6 @@ class DependencyScanningWorker { /// (passed in the constructor). llvm::IntrusiveRefCntPtr DepFS; - /// The caching file system. - CachingOnDiskFileSystemPtr CacheFS; - /// The CAS Dependency Filesytem. This is not set at the sametime as DepFS; - llvm::IntrusiveRefCntPtr DepCASFS; CASOptions CASOpts; std::shared_ptr CAS; diff --git a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h index 1c9448e9f35ca..75685f3b8abb0 100644 --- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h +++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h @@ -191,9 +191,6 @@ struct ModuleDeps { /// determined that the differences are benign for this compilation. std::vector ClangModuleDeps; - /// The CASID for the module input dependency tree, if any. - std::optional CASFileSystemRootID; - /// The CASID for the module include-tree, if any. std::optional IncludeTreeID; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index c8bd037e83426..9738355475d07 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4959,7 +4959,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &Job, { const OptSpecifier DepScanOpts[] = {options::OPT_fdepscan_EQ, - options::OPT_fdepscan_include_tree, options::OPT_fdepscan_share_EQ, options::OPT_fdepscan_share_identifier, options::OPT_fdepscan_share_parent, diff --git a/clang/lib/Frontend/CompileJobCacheKey.cpp b/clang/lib/Frontend/CompileJobCacheKey.cpp index c234d865d63c1..d883dc64b3d23 100644 --- a/clang/lib/Frontend/CompileJobCacheKey.cpp +++ b/clang/lib/Frontend/CompileJobCacheKey.cpp @@ -40,9 +40,6 @@ static llvm::cas::CASID createCompileJobCacheKeyForArgs( case CachingInputKind::IncludeTree: Builder.push(InputRef, llvm::cas::TreeEntry::Regular, "include-tree"); break; - case CachingInputKind::FileSystemRoot: - Builder.push(InputRef, llvm::cas::TreeEntry::Tree, "filesystem"); - break; case CachingInputKind::CachedCompilation: // TODO: Pass a "ref" tree entry kind. Builder.push(InputRef, llvm::cas::TreeEntry::Tree, "cache-key"); @@ -152,9 +149,6 @@ createCompileJobCacheKeyImpl(ObjectStore &CAS, DiagnosticsEngine &Diags, if (!CI.getFrontendOpts().CASIncludeTreeID.empty()) { InputIDString = CI.getFrontendOpts().CASIncludeTreeID; InputKind = CachingInputKind::IncludeTree; - } else if (!CI.getFileSystemOpts().CASFileSystemRootID.empty()) { - InputIDString = CI.getFileSystemOpts().CASFileSystemRootID; - InputKind = CachingInputKind::FileSystemRoot; } else if (!CI.getFrontendOpts().CASInputFileCacheKey.empty()) { InputIDString = CI.getFrontendOpts().CASInputFileCacheKey; InputKind = CachingInputKind::CachedCompilation; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index f8f3f9749b443..f54225e789c70 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1537,7 +1537,7 @@ createBaseFS(const FileSystemOptions &FSOpts, const FrontendOptions &FEOpts, const CASOptions &CASOpts, DiagnosticsEngine &Diags, IntrusiveRefCntPtr BaseFS, std::shared_ptr OverrideCAS) { - if (FSOpts.CASFileSystemRootID.empty() && FEOpts.CASIncludeTreeID.empty()) + if (FEOpts.CASIncludeTreeID.empty()) return BaseFS; // If no CAS was provided, create one with CASOptions. @@ -1572,15 +1572,10 @@ createBaseFS(const FileSystemOptions &FSOpts, const FrontendOptions &FEOpts, if (!CAS) return makeEmptyCASFS(); - auto IsIncludeTreeFS = !FEOpts.CASIncludeTreeID.empty(); - - StringRef RootIDString = - IsIncludeTreeFS ? FEOpts.CASIncludeTreeID : FSOpts.CASFileSystemRootID; - - Expected RootID = CAS->parseID(RootIDString); + Expected RootID = CAS->parseID(FEOpts.CASIncludeTreeID); if (!RootID) { llvm::consumeError(RootID.takeError()); - Diags.Report(diag::err_cas_cannot_parse_root_id) << RootIDString; + Diags.Report(diag::err_cas_cannot_parse_root_id) << FEOpts.CASIncludeTreeID; return makeEmptyCASFS(); } @@ -1590,7 +1585,7 @@ createBaseFS(const FileSystemOptions &FSOpts, const FrontendOptions &FEOpts, std::optional Ref = CAS->getReference(ID); if (!Ref) return llvm::createStringError(llvm::inconvertibleErrorCode(), - "RootID does not exist"); + "include-tree CASID does not exist"); auto Root = cas::IncludeTreeRoot::get(*CAS, *Ref); if (!Root) return Root.takeError(); @@ -1600,33 +1595,15 @@ createBaseFS(const FileSystemOptions &FSOpts, const FrontendOptions &FEOpts, return cas::createIncludeTreeFileSystem(*FileList); }; - auto makeCASFS = [&](std::shared_ptr CAS, - llvm::cas::CASID &ID) - -> Expected> { - Expected> ExpectedFS = - llvm::cas::createCASFileSystem(std::move(CAS), ID); - if (!ExpectedFS) - return ExpectedFS.takeError(); - return std::move(*ExpectedFS); - }; - auto ExpectedFS = IsIncludeTreeFS ? makeIncludeTreeFS(std::move(CAS), *RootID) - : makeCASFS(std::move(CAS), *RootID); + auto ExpectedFS = makeIncludeTreeFS(std::move(CAS), *RootID); if (!ExpectedFS) { Diags.Report(diag::err_cas_filesystem_cannot_be_initialized) - << RootIDString << llvm::toString(ExpectedFS.takeError()); + << FEOpts.CASIncludeTreeID << llvm::toString(ExpectedFS.takeError()); return makeEmptyCASFS(); } - IntrusiveRefCntPtr FS = std::move(*ExpectedFS); - - // Try to change directories. - StringRef CWD = FSOpts.CASFileSystemWorkingDirectory; - if (!CWD.empty()) - if (std::error_code EC = FS->setCurrentWorkingDirectory(CWD)) - Diags.Report(diag::err_cas_filesystem_cannot_set_working_directory) - << CWD; - return FS; + return *ExpectedFS; } void CompilerInvocation::setDefaultPointerAuthOptions( diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 4362fd7862b5b..741d4cfb39dbd 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -3605,15 +3605,6 @@ ASTReader::ReadControlBlock(ModuleFile &F, F.ModuleCacheKey = Blob.str(); break; - case CASFS_ROOT_ID: - F.CASFileSystemRootID = Blob.str(); - if (Listener) { - bool Complain = - !canRecoverFromOutOfDate(F.FileName, ClientLoadCapabilities); - if (Listener->readCASFileSystemRootID(F.CASFileSystemRootID, Complain)) - return OutOfDate; - } - break; case CAS_INCLUDE_TREE_ID: F.IncludeTreeID = Blob.str(); if (Listener) { diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 32e9a0ebe1567..a442563f83846 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -912,7 +912,6 @@ void ASTWriter::WriteBlockInfoBlock() { RECORD(ORIGINAL_FILE_ID); RECORD(INPUT_FILE_OFFSETS); RECORD(MODULE_CACHE_KEY); - RECORD(CASFS_ROOT_ID); RECORD(CAS_INCLUDE_TREE_ID); BLOCK(OPTIONS_BLOCK); @@ -1602,15 +1601,6 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) { RecordData::value_type Record[] = {CAS_INCLUDE_TREE_ID}; Stream.EmitRecordWithBlob(AbbrevCode, Record, *ID); } - // CAS filesystem root id, for the scanner. - if (auto ID = PP.getCASFileSystemRootID()) { - auto Abbrev = std::make_shared(); - Abbrev->Add(BitCodeAbbrevOp(CASFS_ROOT_ID)); - Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); - unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev)); - RecordData::value_type Record[] = {CASFS_ROOT_ID}; - Stream.EmitRecordWithBlob(AbbrevCode, Record, *ID); - } // Imports if (Chain) { diff --git a/clang/lib/Tooling/DependencyScanning/CASFSActionController.cpp b/clang/lib/Tooling/DependencyScanning/CASFSActionController.cpp deleted file mode 100644 index f1681522df659..0000000000000 --- a/clang/lib/Tooling/DependencyScanning/CASFSActionController.cpp +++ /dev/null @@ -1,244 +0,0 @@ -//===- CASFSActionController.cpp ------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "CachingActions.h" -#include "clang/Frontend/CompilerInstance.h" -#include "clang/Lex/Preprocessor.h" -#include "llvm/CAS/CachingOnDiskFileSystem.h" -#include "llvm/CAS/ObjectStore.h" -#include "llvm/Support/PrefixMapper.h" - -using namespace clang; -using namespace tooling; -using namespace dependencies; -using llvm::Error; - -namespace { -class CASFSActionController : public CallbackActionController { -public: - CASFSActionController(LookupModuleOutputCallback LookupModuleOutput, - llvm::cas::CachingOnDiskFileSystem &CacheFS); - - llvm::Error initialize(CompilerInstance &ScanInstance, - CompilerInvocation &NewInvocation) override; - llvm::Error finalize(CompilerInstance &ScanInstance, - CompilerInvocation &NewInvocation) override; - std::optional - getCacheKey(const CompilerInvocation &NewInvocation) override; - llvm::Error - initializeModuleBuild(CompilerInstance &ModuleScanInstance) override; - llvm::Error - finalizeModuleBuild(CompilerInstance &ModuleScanInstance) override; - llvm::Error finalizeModuleInvocation(CowCompilerInvocation &CI, - const ModuleDeps &MD) override; - -private: - llvm::cas::CachingOnDiskFileSystem &CacheFS; - std::optional Mapper; - CASOptions CASOpts; - llvm::StringMap OutputToCacheKey; -}; -} // anonymous namespace - -CASFSActionController::CASFSActionController( - LookupModuleOutputCallback LookupModuleOutput, - llvm::cas::CachingOnDiskFileSystem &CacheFS) - : CallbackActionController(std::move(LookupModuleOutput)), - CacheFS(CacheFS) {} - -Error CASFSActionController::initialize(CompilerInstance &ScanInstance, - CompilerInvocation &NewInvocation) { - // Setup prefix mapping. - Mapper.emplace(&CacheFS); - DepscanPrefixMapping::configurePrefixMapper(NewInvocation, *Mapper); - - const PreprocessorOptions &PPOpts = ScanInstance.getPreprocessorOpts(); - if (!PPOpts.Includes.empty() || !PPOpts.ImplicitPCHInclude.empty()) - addReversePrefixMappingFileSystem(*Mapper, ScanInstance); - - CacheFS.trackNewAccesses(); - if (auto CWD = - ScanInstance.getVirtualFileSystem().getCurrentWorkingDirectory()) - CacheFS.setCurrentWorkingDirectory(*CWD); - // Track paths that are accessed by the scanner before we reach here. - for (const auto &File : ScanInstance.getHeaderSearchOpts().VFSOverlayFiles) - (void)CacheFS.status(File); - // Enable caching in the resulting commands. - ScanInstance.getFrontendOpts().CacheCompileJob = true; - CASOpts = ScanInstance.getCASOpts(); - return Error::success(); -} - -/// Ensure that all files reachable from imported modules/pch are tracked. -/// These could be loaded lazily during compilation. -static void trackASTFileInputs(CompilerInstance &CI, - llvm::cas::CachingOnDiskFileSystem &CacheFS) { - auto Reader = CI.getASTReader(); - if (!Reader) - return; - - for (serialization::ModuleFile &MF : Reader->getModuleManager()) { - Reader->visitInputFiles( - MF, /*IncludeSystem=*/true, /*Complain=*/false, - [](const serialization::InputFile &IF, bool isSystem) { - // Visiting input files triggers the file system lookup. - }); - } -} - -/// Ensure files that are not accessed during the scan (or accessed before the -/// tracking scope) are tracked. -static void trackFilesCommon(CompilerInstance &CI, - llvm::cas::CachingOnDiskFileSystem &CacheFS) { - trackASTFileInputs(CI, CacheFS); - - // Exclude the module cache from tracking. The implicit build pcms should - // not be needed after scanning. - if (!CI.getHeaderSearchOpts().ModuleCachePath.empty()) - (void)CacheFS.excludeFromTracking(CI.getHeaderSearchOpts().ModuleCachePath); - - // Normally this would be looked up while creating the VFS, but implicit - // modules share their VFS and it happens too early for the TU scan. - for (const auto &File : CI.getHeaderSearchOpts().VFSOverlayFiles) - (void)CacheFS.status(File); - - StringRef Sysroot = CI.getHeaderSearchOpts().Sysroot; - if (!Sysroot.empty()) { - // Include 'SDKSettings.json', if it exists, to accomodate availability - // checks during the compilation. - llvm::SmallString<256> FilePath = Sysroot; - llvm::sys::path::append(FilePath, "SDKSettings.json"); - (void)CacheFS.status(FilePath); - } -} - -Error CASFSActionController::finalize(CompilerInstance &ScanInstance, - CompilerInvocation &NewInvocation) { - // Handle profile mappings. - (void)CacheFS.status(NewInvocation.getCodeGenOpts().ProfileInstrumentUsePath); - (void)CacheFS.status(NewInvocation.getCodeGenOpts().SampleProfileFile); - (void)CacheFS.status(NewInvocation.getCodeGenOpts().ProfileRemappingFile); - - auto GetInputCacheKey = [&]() -> std::optional { - if (NewInvocation.getFrontendOpts().Inputs.size() != 1) - return {}; - const auto &FIF = NewInvocation.getFrontendOpts().Inputs.front(); - if (!FIF.isFile()) - return {}; - auto It = OutputToCacheKey.find(FIF.getFile()); - if (It == OutputToCacheKey.end()) - return {}; - - return It->second; - }; - - std::string InputID; - CachingInputKind InputKind; - - if (auto InputCacheKey = GetInputCacheKey()) { - InputID = InputCacheKey->str(); - InputKind = CachingInputKind::CachedCompilation; - } else { - trackFilesCommon(ScanInstance, CacheFS); - - auto CASFileSystemRootID = CacheFS.createTreeFromNewAccesses( - [&](const llvm::vfs::CachedDirectoryEntry &Entry, - SmallVectorImpl &Storage) { - return Mapper->mapDirEntry(Entry, Storage); - }); - if (!CASFileSystemRootID) - return CASFileSystemRootID.takeError(); - InputID = CASFileSystemRootID->getID().toString(); - InputKind = CachingInputKind::FileSystemRoot; - } - - configureInvocationForCaching(NewInvocation, CASOpts, InputID, InputKind, - CacheFS.getCurrentWorkingDirectory().get()); - - if (Mapper) - DepscanPrefixMapping::remapInvocationPaths(NewInvocation, *Mapper); - - auto &CAS = ScanInstance.getOrCreateObjectStore(); - auto Key = createCompileJobCacheKey(CAS, ScanInstance.getDiagnostics(), - NewInvocation); - if (Key) - OutputToCacheKey[NewInvocation.getFrontendOpts().OutputFile] = - Key->toString(); - return Error::success(); -} - -std::optional -CASFSActionController::getCacheKey(const CompilerInvocation &NewInvocation) { - auto It = OutputToCacheKey.find(NewInvocation.getFrontendOpts().OutputFile); - // FIXME: Assert this does not happen. - if (It == OutputToCacheKey.end()) - return std::nullopt; - return It->second; -} - -Error CASFSActionController::initializeModuleBuild( - CompilerInstance &ModuleScanInstance) { - - CacheFS.trackNewAccesses(); - // If the working directory is not otherwise accessed by the module build, - // we still need it due to -fcas-fs-working-directory being set. - if (auto CWD = CacheFS.getCurrentWorkingDirectory()) - (void)CacheFS.status(*CWD); - - return Error::success(); -} - -Error CASFSActionController::finalizeModuleBuild( - CompilerInstance &ModuleScanInstance) { - trackFilesCommon(ModuleScanInstance, CacheFS); - - std::optional RootID; - auto E = CacheFS - .createTreeFromNewAccesses( - [&](const llvm::vfs::CachedDirectoryEntry &Entry, - SmallVectorImpl &Storage) { - return Mapper->mapDirEntry(Entry, Storage); - }) - .moveInto(RootID); - if (E) - return E; - -#ifndef NDEBUG - Module *M = ModuleScanInstance.getPreprocessor().getCurrentModule(); - assert(M && "finalizing without a module"); -#endif - - ModuleScanInstance.getPreprocessor().setCASFileSystemRootID( - RootID->toString()); - return Error::success(); -} - -Error CASFSActionController::finalizeModuleInvocation( - CowCompilerInvocation &CowCI, const ModuleDeps &MD) { - // TODO: Avoid this copy. - CompilerInvocation CI(CowCI); - - if (auto ID = MD.CASFileSystemRootID) { - configureInvocationForCaching(CI, CASOpts, *ID, - CachingInputKind::FileSystemRoot, - CacheFS.getCurrentWorkingDirectory().get()); - } - - if (Mapper) - DepscanPrefixMapping::remapInvocationPaths(CI, *Mapper); - - CowCI = CI; - return llvm::Error::success(); -} - -std::unique_ptr -dependencies::createCASFSActionController( - LookupModuleOutputCallback LookupModuleOutput, - llvm::cas::CachingOnDiskFileSystem &CacheFS) { - return std::make_unique(LookupModuleOutput, CacheFS); -} diff --git a/clang/lib/Tooling/DependencyScanning/CMakeLists.txt b/clang/lib/Tooling/DependencyScanning/CMakeLists.txt index a6a23ab18b330..0afef66ea41b1 100644 --- a/clang/lib/Tooling/DependencyScanning/CMakeLists.txt +++ b/clang/lib/Tooling/DependencyScanning/CMakeLists.txt @@ -7,8 +7,6 @@ set(LLVM_LINK_COMPONENTS ) add_clang_library(clangDependencyScanning - CASFSActionController.cpp - DependencyScanningCASFilesystem.cpp DependencyScanningFilesystem.cpp DependencyScanningService.cpp DependencyScanningWorker.cpp diff --git a/clang/lib/Tooling/DependencyScanning/CachingActions.h b/clang/lib/Tooling/DependencyScanning/CachingActions.h index 8cb39dc649641..f6d15fdb25fcb 100644 --- a/clang/lib/Tooling/DependencyScanning/CachingActions.h +++ b/clang/lib/Tooling/DependencyScanning/CachingActions.h @@ -12,20 +12,12 @@ #include "clang/Tooling/DependencyScanning/DependencyScanningTool.h" #include "clang/Tooling/DependencyScanning/ScanAndUpdateArgs.h" -namespace llvm::cas { -class CachingOnDiskFileSystem; -} - namespace clang::tooling::dependencies { std::unique_ptr createIncludeTreeActionController(LookupModuleOutputCallback LookupModuleOutput, cas::ObjectStore &DB); -std::unique_ptr -createCASFSActionController(LookupModuleOutputCallback LookupModuleOutput, - llvm::cas::CachingOnDiskFileSystem &CacheFS); - /// The PCH recorded file paths with canonical paths, create a VFS that /// allows remapping back to the non-canonical source paths so that they are /// found during dep-scanning. diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScannerImpl.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScannerImpl.cpp index c2e0f4a06b9e3..25ede1fbd6e51 100644 --- a/clang/lib/Tooling/DependencyScanning/DependencyScannerImpl.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScannerImpl.cpp @@ -452,26 +452,6 @@ class ScanningDependencyDirectivesGetter : public DependencyDirectivesGetter { } }; -// FIXME: Make this thread-safe by pulling the FS out of `FileManager`. -class CASDependencyDirectivesGetter : public DependencyDirectivesGetter { - DependencyScanningCASFilesystem *DepCASFS; - -public: - CASDependencyDirectivesGetter(DependencyScanningCASFilesystem *DepCASFS) - : DepCASFS(DepCASFS) {} - - std::unique_ptr - cloneFor(FileManager &FileMgr) override { - (void)FileMgr; - return std::make_unique(DepCASFS); - } - - std::optional> - operator()(FileEntryRef File) override { - return DepCASFS->getDirectiveTokens(File.getName()); - } -}; - /// Sanitize diagnostic options for dependency scan. void sanitizeDiagOpts(DiagnosticOptions &DiagOpts) { // Don't print 'X warnings and Y errors generated'. @@ -568,11 +548,11 @@ createCompilerInvocation(ArrayRef CommandLine, } std::pair, std::vector> -initVFSForTUBuferScanning( - IntrusiveRefCntPtr BaseFS, - ArrayRef CommandLine, StringRef WorkingDirectory, - llvm::MemoryBufferRef TUBuffer, std::shared_ptr CAS, - IntrusiveRefCntPtr DepCASFS) { +initVFSForTUBuferScanning(IntrusiveRefCntPtr BaseFS, + ArrayRef CommandLine, + StringRef WorkingDirectory, + llvm::MemoryBufferRef TUBuffer, + std::shared_ptr CAS) { // Reset what might have been modified in the previous worker invocation. BaseFS->setCurrentWorkingDirectory(WorkingDirectory); @@ -586,9 +566,9 @@ initVFSForTUBuferScanning( InputPath, 0, llvm::MemoryBuffer::getMemBufferCopy(TUBuffer.getBuffer())); IntrusiveRefCntPtr InMemoryOverlay = InMemoryFS; - // If we are using a CAS but not dependency CASFS, we need to provide the - // fake input file in a CASProvidingFS for include-tree. - if (CAS && !DepCASFS) + // If we are using a CAS, we need to provide the fake input file in a + // CASProvidingFS for include-tree. + if (CAS) InMemoryOverlay = llvm::cas::createCASProvidingFileSystem(CAS, std::move(InMemoryFS)); @@ -602,11 +582,10 @@ initVFSForTUBuferScanning( std::pair, std::vector> -initVFSForByNameScanning( - IntrusiveRefCntPtr BaseFS, - ArrayRef CommandLine, StringRef WorkingDirectory, - StringRef ModuleName, std::shared_ptr CAS, - IntrusiveRefCntPtr DepCASFS) { +initVFSForByNameScanning(IntrusiveRefCntPtr BaseFS, + ArrayRef CommandLine, + StringRef WorkingDirectory, StringRef ModuleName, + std::shared_ptr CAS) { // Reset what might have been modified in the previous worker invocation. BaseFS->setCurrentWorkingDirectory(WorkingDirectory); @@ -624,9 +603,9 @@ initVFSForByNameScanning( InMemoryFS->addFile(FakeInputPath, 0, llvm::MemoryBuffer::getMemBuffer("")); IntrusiveRefCntPtr InMemoryOverlay = InMemoryFS; - // If we are using a CAS but not dependency CASFS, we need to provide the - // fake input file in a CASProvidingFS for include-tree. - if (CAS && !DepCASFS) + // If we are using a CAS, we need to provide the fake input file in a + // CASProvidingFS for include-tree. + if (CAS) InMemoryOverlay = llvm::cas::createCASProvidingFileSystem(CAS, std::move(InMemoryFS)); @@ -643,8 +622,7 @@ bool initializeScanCompilerInstance( IntrusiveRefCntPtr FS, DiagnosticConsumer *DiagConsumer, DependencyScanningService &Service, IntrusiveRefCntPtr DepFS, - bool DiagGenerationAsCompilation, raw_ostream *VerboseOS, - llvm::IntrusiveRefCntPtr DepCASFS) { + bool DiagGenerationAsCompilation, raw_ostream *VerboseOS) { ScanInstance.setBuildingModule(false); ScanInstance.createVirtualFileSystem(FS, DiagConsumer); @@ -674,8 +652,6 @@ bool initializeScanCompilerInstance( // This will prevent us compiling individual modules asynchronously since // FileManager is not thread-safe, but it does improve performance for now. ScanInstance.getFrontendOpts().ModulesShareFileManager = true; - if (DepCASFS) - ScanInstance.getFrontendOpts().ModulesShareFileManager = false; ScanInstance.getHeaderSearchOpts().ModuleFormat = "raw"; ScanInstance.getHeaderSearchOpts().ModulesIncludeVFSUsage = any(Service.getOptimizeArgs() & ScanningOptimizations::VFS); @@ -698,11 +674,6 @@ bool initializeScanCompilerInstance( ScanInstance.getFileManager())); } - // CAS Implementation. - if (DepCASFS) - ScanInstance.setDependencyDirectivesGetter( - std::make_unique(DepCASFS.get())); - ScanInstance.createSourceManager(); // Consider different header search and diagnostic options to create @@ -796,7 +767,6 @@ std::shared_ptr initializeScanInstanceDependencyCollector( // is explicit in each \p DependencyScanningTool function. switch (Service.getFormat()) { case ScanningOutputFormat::Make: - case ScanningOutputFormat::Tree: ScanInstance.addDependencyCollector( std::make_shared( std::move(DepOutputOpts), WorkingDirectory, Consumer, @@ -805,7 +775,6 @@ std::shared_ptr initializeScanInstanceDependencyCollector( case ScanningOutputFormat::IncludeTree: case ScanningOutputFormat::P1689: case ScanningOutputFormat::Full: - case ScanningOutputFormat::FullTree: case ScanningOutputFormat::FullIncludeTree: if (EmitDependencyFile) { auto DFG = std::make_shared( @@ -880,7 +849,7 @@ bool DependencyScanningAction::runInvocation( assert(!DiagConsumerFinished && "attempt to reuse finished consumer"); if (!initializeScanCompilerInstance(ScanInstance, FS, DiagConsumer, Service, DepFS, DiagGenerationAsCompilation, - VerboseOS, DepCASFS)) + VerboseOS)) return false; llvm::SmallVector StableDirs = getInitialStableDirs(ScanInstance); @@ -933,10 +902,7 @@ bool DependencyScanningAction::runInvocation( return reportError(std::move(E)); // Forward any CAS results to consumer. - std::string ID = OriginalInvocation.getFileSystemOpts().CASFileSystemRootID; - if (!ID.empty()) - Consumer.handleCASFileSystemRootID(std::move(ID)); - ID = OriginalInvocation.getFrontendOpts().CASIncludeTreeID; + std::string ID = OriginalInvocation.getFrontendOpts().CASIncludeTreeID; if (!ID.empty()) Consumer.handleIncludeTreeID(std::move(ID)); @@ -958,19 +924,6 @@ std::optional DependencyScanningAction::takeLastCC1CacheKey() { return Result; } -IntrusiveRefCntPtr -DependencyScanningAction::getDepScanFS() { - if (DepFS) { - assert(!DepCASFS && "CAS DepFS should not be set"); - return DepFS; - } - if (DepCASFS) { - assert(!DepFS && "DepFS should not be set"); - return DepCASFS; - } - return nullptr; -} - bool CompilerInstanceWithContext::initialize(DiagnosticConsumer *DC) { if (DC) { DiagConsumer = DC; @@ -980,10 +933,8 @@ bool CompilerInstanceWithContext::initialize(DiagnosticConsumer *DC) { DiagConsumer = &DiagPrinterWithOS->DiagPrinter; } - std::tie(OverlayFS, CommandLine) = - initVFSForByNameScanning(Worker.BaseFS, CommandLine, CWD, - "ScanningByName", Worker.CAS, Worker.DepCASFS); - + std::tie(OverlayFS, CommandLine) = initVFSForByNameScanning( + Worker.BaseFS, CommandLine, CWD, "ScanningByName", Worker.CAS); DiagEngineWithCmdAndOpts = std::make_unique( CommandLine, OverlayFS, *DiagConsumer); @@ -1025,7 +976,7 @@ bool CompilerInstanceWithContext::initialize(DiagnosticConsumer *DC) { CI.getInvocation().getCASOpts() = Worker.CASOpts; if (!initializeScanCompilerInstance( CI, OverlayFS, DiagEngineWithCmdAndOpts->DiagEngine->getClient(), - Worker.Service, Worker.DepFS, false, nullptr, Worker.DepCASFS)) + Worker.Service, Worker.DepFS, false, nullptr)) return false; llvm::SmallVector StableDirs = getInitialStableDirs(CI); @@ -1144,10 +1095,7 @@ bool CompilerInstanceWithContext::computeDependencies( return false; } - std::string ID = ModuleInvocation.getFileSystemOpts().CASFileSystemRootID; - if (!ID.empty()) - Consumer.handleCASFileSystemRootID(std::move(ID)); - ID = ModuleInvocation.getFrontendOpts().CASIncludeTreeID; + std::string ID = ModuleInvocation.getFrontendOpts().CASIncludeTreeID; if (!ID.empty()) Consumer.handleIncludeTreeID(std::move(ID)); diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScannerImpl.h b/clang/lib/Tooling/DependencyScanning/DependencyScannerImpl.h index 0d6b865bd2057..0126607630560 100644 --- a/clang/lib/Tooling/DependencyScanning/DependencyScannerImpl.h +++ b/clang/lib/Tooling/DependencyScanning/DependencyScannerImpl.h @@ -35,15 +35,12 @@ class DependencyScanningAction { DependencyScanningService &Service, StringRef WorkingDirectory, DependencyConsumer &Consumer, DependencyActionController &Controller, llvm::IntrusiveRefCntPtr DepFS, - llvm::IntrusiveRefCntPtr DepCASFS, - llvm::IntrusiveRefCntPtr CacheFS, bool EmitDependencyFile, bool DiagGenerationAsCompilation, const CASOptions &CASOpts, std::optional ModuleName = std::nullopt, raw_ostream *VerboseOS = nullptr) : Service(Service), WorkingDirectory(WorkingDirectory), Consumer(Consumer), Controller(Controller), DepFS(std::move(DepFS)), - DepCASFS(std::move(DepCASFS)), CacheFS(std::move(CacheFS)), CASOpts(CASOpts), EmitDependencyFile(EmitDependencyFile), DiagGenerationAsCompilation(DiagGenerationAsCompilation), VerboseOS(VerboseOS) {} @@ -62,16 +59,12 @@ class DependencyScanningAction { std::optional takeLastCC1CacheKey(); - IntrusiveRefCntPtr getDepScanFS(); - private: DependencyScanningService &Service; StringRef WorkingDirectory; DependencyConsumer &Consumer; DependencyActionController &Controller; llvm::IntrusiveRefCntPtr DepFS; - llvm::IntrusiveRefCntPtr DepCASFS; - llvm::IntrusiveRefCntPtr CacheFS; const CASOptions &CASOpts; bool EmitDependencyFile = false; bool DiagGenerationAsCompilation; @@ -124,27 +117,25 @@ createCompilerInvocation(ArrayRef CommandLine, DiagnosticsEngine &Diags); std::pair, std::vector> -initVFSForTUBuferScanning( - IntrusiveRefCntPtr BaseFS, - ArrayRef CommandLine, StringRef WorkingDirectory, - llvm::MemoryBufferRef TUBuffer, std::shared_ptr CAS, - IntrusiveRefCntPtr DepCASFS); +initVFSForTUBuferScanning(IntrusiveRefCntPtr BaseFS, + ArrayRef CommandLine, + StringRef WorkingDirectory, + llvm::MemoryBufferRef TUBuffer, + std::shared_ptr CAS); std::pair, std::vector> -initVFSForByNameScanning( - IntrusiveRefCntPtr BaseFS, - ArrayRef CommandLine, StringRef WorkingDirectory, - StringRef ModuleName, std::shared_ptr CAS, - IntrusiveRefCntPtr DepCASFS); +initVFSForByNameScanning(IntrusiveRefCntPtr BaseFS, + ArrayRef CommandLine, + StringRef WorkingDirectory, StringRef ModuleName, + std::shared_ptr CAS); bool initializeScanCompilerInstance( CompilerInstance &ScanInstance, IntrusiveRefCntPtr FS, DiagnosticConsumer *DiagConsumer, DependencyScanningService &Service, IntrusiveRefCntPtr DepFS, - bool DiagGenerationAsCompilation, raw_ostream *VerboseOS, - llvm::IntrusiveRefCntPtr DepCASFS); + bool DiagGenerationAsCompilation, raw_ostream *VerboseOS); SmallVector getInitialStableDirs(const CompilerInstance &ScanInstance); diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningCASFilesystem.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningCASFilesystem.cpp deleted file mode 100644 index 8741fb1a15ddd..0000000000000 --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningCASFilesystem.cpp +++ /dev/null @@ -1,345 +0,0 @@ -//===- DependencyScanningCASFilesystem.cpp - clang-scan-deps fs -----------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "clang/Tooling/DependencyScanning/DependencyScanningCASFilesystem.h" -#include "clang/Tooling/DependencyScanning/DependencyScanningService.h" -#include "clang/Basic/Version.h" -#include "clang/Lex/DependencyDirectivesScanner.h" -#include "llvm/CAS/ActionCache.h" -#include "llvm/CAS/CachingOnDiskFileSystem.h" -#include "llvm/CAS/HierarchicalTreeBuilder.h" -#include "llvm/CAS/ObjectStore.h" -#include "llvm/Support/EndianStream.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/Threading.h" - -using namespace clang; -using namespace tooling; -using namespace dependencies; - -template static T reportAsFatalIfError(Expected ValOrErr) { - if (!ValOrErr) - llvm::report_fatal_error(ValOrErr.takeError()); - return std::move(*ValOrErr); -} - -static void reportAsFatalIfError(llvm::Error E) { - if (E) - llvm::report_fatal_error(std::move(E)); -} - -using llvm::Error; - -DependencyScanningCASFilesystem::DependencyScanningCASFilesystem( - DependencyScanningService &Service, - IntrusiveRefCntPtr WorkerFS) - : FS(WorkerFS), Entries(EntryAlloc), CAS(WorkerFS->getCAS()), - Cache(*Service.getCache()), Service(Service) {} - -const char DependencyScanningCASFilesystem::ID = 0; -DependencyScanningCASFilesystem::~DependencyScanningCASFilesystem() = default; - -static Expected -storeDepDirectives(cas::ObjectStore &CAS, - ArrayRef Directives) { - llvm::SmallString<1024> Buffer; - llvm::raw_svector_ostream OS(Buffer); - llvm::support::endian::Writer W(OS, llvm::endianness::little); - size_t NumTokens = 0; - for (const auto &Directive : Directives) - NumTokens += Directive.Tokens.size(); - W.write(NumTokens); - for (const auto &Directive : Directives) { - for (const auto &Token : Directive.Tokens) { - W.write(Token.Offset); - W.write(Token.Length); - W.write(static_cast::type>( - Token.Kind)); - W.write(Token.Flags); - } - } - - size_t TokenIdx = 0; - W.write(Directives.size()); - for (const auto &Directive : Directives) { - W.write(static_cast::type>( - Directive.Kind)); - W.write(TokenIdx); - W.write(Directive.Tokens.size()); - TokenIdx += Directive.Tokens.size(); - } - - return CAS.storeFromString({}, Buffer); -} - -template static void readle(StringRef &Slice, T &Out) { - using namespace llvm::support::endian; - if (Slice.size() < sizeof(T)) - llvm::report_fatal_error("buffer too small"); - Out = read(Slice.begin()); - Slice = Slice.drop_front(sizeof(T)); -} - -static Error loadDepDirectives( - cas::ObjectStore &CAS, cas::ObjectRef Ref, - llvm::SmallVectorImpl &DepTokens, - llvm::SmallVectorImpl - &DepDirectives) { - using namespace dependency_directives_scan; - auto Blob = CAS.getProxy(Ref); - if (!Blob) - return Blob.takeError(); - - StringRef Data = Blob->getData(); - StringRef Cursor = Data; - - size_t NumTokens = 0; - readle(Cursor, NumTokens); - DepTokens.reserve(NumTokens); - for (size_t I = 0; I < NumTokens; ++I) { - DepTokens.emplace_back(0, 0, (tok::TokenKind)0, 0); - auto &Token = DepTokens.back(); - readle(Cursor, Token.Offset); - readle(Cursor, Token.Length); - std::underlying_type::type Kind; - readle(Cursor, Kind); - Token.Kind = static_cast(Kind); - readle(Cursor, Token.Flags); - } - - size_t NumDirectives = 0; - readle(Cursor, NumDirectives); - DepDirectives.reserve(NumDirectives); - for (size_t I = 0; I < NumDirectives; ++I) { - std::underlying_type::type Kind; - readle(Cursor, Kind); - size_t TokenStart, NumTokens; - readle(Cursor, TokenStart); - readle(Cursor, NumTokens); - assert(NumTokens <= DepTokens.size() && - TokenStart <= DepTokens.size() - NumTokens); - DepDirectives.emplace_back( - static_cast(Kind), - ArrayRef(DepTokens.begin() + TokenStart, - DepTokens.begin() + TokenStart + NumTokens)); - } - assert(Cursor.empty()); - return Error::success(); -} - -void DependencyScanningCASFilesystem::scanForDirectives( - llvm::cas::ObjectRef InputDataID, StringRef Identifier, - SmallVectorImpl &Tokens, - SmallVectorImpl &Directives) { - using namespace llvm; - using namespace llvm::cas; - - // Get a blob for the clang version string. - if (!ClangFullVersionID) - ClangFullVersionID = - reportAsFatalIfError(CAS.storeFromString({}, getClangFullVersion())); - - // Get a blob for the dependency directives scan command. - if (!DepDirectivesID) - DepDirectivesID = - reportAsFatalIfError(CAS.storeFromString({}, "directives")); - - // Get an empty blob. - if (!EmptyBlobID) - EmptyBlobID = reportAsFatalIfError(CAS.storeFromString({}, "")); - - // Construct a tree for the input. - std::optional InputID; - { - HierarchicalTreeBuilder Builder; - Builder.push(*ClangFullVersionID, TreeEntry::Regular, "version"); - Builder.push(*DepDirectivesID, TreeEntry::Regular, "command"); - Builder.push(InputDataID, TreeEntry::Regular, "data"); - InputID = reportAsFatalIfError(Builder.create(CAS)).getID(); - } - - // Check the result cache. - if (std::optional OutputID = - reportAsFatalIfError(Cache.get(*InputID))) { - if (std::optional OutputRef = CAS.getReference(*OutputID)) { - if (OutputRef == EmptyBlobID) - return; // Cached directive scanning failure. - reportAsFatalIfError( - loadDepDirectives(CAS, *OutputRef, Tokens, Directives)); - return; - } - } - - StringRef InputData = - reportAsFatalIfError(CAS.getProxy(InputDataID)).getData(); - - if (scanSourceForDependencyDirectives(InputData, Tokens, Directives)) { - // FIXME: Propagate the diagnostic if desired by the client. - // Failure. Cache empty directives. - Tokens.clear(); - Directives.clear(); - reportAsFatalIfError(Cache.put(*InputID, CAS.getID(*EmptyBlobID))); - return; - } - - // Success. Add to the CAS and get back persistent output data. - cas::ObjectRef DirectivesID = - reportAsFatalIfError(storeDepDirectives(CAS, Directives)); - // Cache the computation. - reportAsFatalIfError(Cache.put(*InputID, CAS.getID(DirectivesID))); -} - -Expected -DependencyScanningCASFilesystem::getOriginal(cas::CASID InputDataID) { - Expected Blob = CAS.getProxy(InputDataID); - if (Blob) - return Blob->getData(); - return Blob.takeError(); -} - -llvm::cas::CachingOnDiskFileSystem & -DependencyScanningCASFilesystem::getCachingFS() { - return static_cast(*FS); -} - -DependencyScanningCASFilesystem::LookupPathResult -DependencyScanningCASFilesystem::lookupPath(const Twine &Path) { - SmallString<256> PathStorage; - StringRef PathRef = Path.toStringRef(PathStorage); - - { - auto I = Entries.find(PathRef); - if (I != Entries.end()) { - // FIXME: Gross hack to ensure this file gets tracked as part of the - // compilation. Instead, we should add an explicit hook somehow / - // somewhere. - (void)getCachingFS().status(PathRef); - return LookupPathResult{&I->second, std::error_code()}; - } - } - - std::optional FileID; - llvm::ErrorOr MaybeStatus = - getCachingFS().statusAndFileID(PathRef, FileID); - if (!MaybeStatus) { - if (Service.shouldCacheNegativeStats() && - shouldCacheNegativeStatsForPath(PathRef)) - Entries[PathRef].EC = MaybeStatus.getError(); - return LookupPathResult{nullptr, MaybeStatus.getError()}; - } - - // Underlying file system caches directories. No need to duplicate. - if (MaybeStatus->isDirectory()) - return LookupPathResult{nullptr, std::move(MaybeStatus)}; - - auto &Entry = Entries[PathRef]; - Entry.CASContents = CAS.getReference(*FileID); - llvm::ErrorOr Buffer = expectedToErrorOr(getOriginal(*FileID)); - if (!Buffer) { - // Cache CAS failures. Not going to recover later. - Entry.EC = Buffer.getError(); - return LookupPathResult{&Entry, std::error_code()}; - } - - Entry.Buffer = std::move(*Buffer); - Entry.Status = llvm::vfs::Status( - PathRef, MaybeStatus->getUniqueID(), - MaybeStatus->getLastModificationTime(), MaybeStatus->getUser(), - MaybeStatus->getGroup(), Entry.Buffer->size(), MaybeStatus->getType(), - MaybeStatus->getPermissions()); - return LookupPathResult{&Entry, std::error_code()}; -} - -llvm::ErrorOr -DependencyScanningCASFilesystem::status(const Twine &Path) { - LookupPathResult Result = lookupPath(Path); - if (!Result.Entry) - return std::move(Result.Status); - if (Result.Entry->EC) - return Result.Entry->EC; - return Result.Entry->Status; -} - -bool DependencyScanningCASFilesystem::exists(const Twine &Path) { - // Existence check does not require caching the result at the dependency - // scanning level. The CachingOnDiskFileSystem tracks the exists call, which - // ensures it is included in any resulting CASFileSystem. - return getCachingFS().exists(Path); -} - -IntrusiveRefCntPtr -DependencyScanningCASFilesystem::createThreadSafeProxyFS() { - llvm::report_fatal_error("not implemented"); -} - -namespace { - -class DepScanFile final : public llvm::cas::CASBackedFile { -public: - DepScanFile(StringRef Buffer, cas::ObjectRef CASContents, - llvm::vfs::Status Stat) - : Buffer(Buffer), CASContents(CASContents), Stat(std::move(Stat)) {} - - llvm::ErrorOr status() override { return Stat; } - - llvm::ErrorOr> - getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator, - bool IsVolatile) override { - SmallString<256> Storage; - return llvm::MemoryBuffer::getMemBuffer(Buffer, Name.toStringRef(Storage)); - } - - cas::ObjectRef getObjectRefForContent() override { return CASContents; } - - std::error_code close() override { return {}; } - -private: - StringRef Buffer; - cas::ObjectRef CASContents; - llvm::vfs::Status Stat; -}; - -} // end anonymous namespace - -Expected> -DependencyScanningCASFilesystem::openCASBackedFileForRead(const Twine &Path) { - LookupPathResult Result = lookupPath(Path); - if (!Result.Entry) { - if (std::error_code EC = Result.Status.getError()) - return llvm::errorCodeToError(EC); - assert(Result.Status->getType() == - llvm::sys::fs::file_type::directory_file); - return llvm::createFileError( - Path, std::make_error_code(std::errc::is_a_directory)); - } - if (Result.Entry->EC) - return llvm::errorCodeToError(Result.Entry->EC); - - assert(Result.Entry->CASContents); - return std::make_unique( - *Result.Entry->Buffer, *Result.Entry->CASContents, Result.Entry->Status); -} - -std::optional> -DependencyScanningCASFilesystem::getDirectiveTokens(const Twine &Path) { - LookupPathResult Result = lookupPath(Path); - - if (Result.Entry) { - if (Result.Entry->DepDirectives.empty()) { - SmallString<256> PathStorage; - StringRef PathRef = Path.toStringRef(PathStorage); - FileEntry &Entry = const_cast(*Result.Entry); - scanForDirectives(*Entry.CASContents, PathRef, Entry.DepTokens, - Entry.DepDirectives); - } - - if (!Result.Entry->DepDirectives.empty()) - return ArrayRef(Result.Entry->DepDirectives); - } - return std::nullopt; -} diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp index a157f10a899a7..2276e9e4a4013 100644 --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp @@ -9,7 +9,6 @@ #include "clang/Tooling/DependencyScanning/DependencyScanningService.h" #include "clang/Basic/BitmaskEnum.h" #include "llvm/CAS/ActionCache.h" -#include "llvm/CAS/CachingOnDiskFileSystem.h" #include "llvm/CAS/ObjectStore.h" #include "llvm/Support/Process.h" @@ -47,18 +46,13 @@ DependencyScanningService::DependencyScanningService( ScanningMode Mode, ScanningOutputFormat Format, CASOptions CASOpts, std::shared_ptr CAS, std::shared_ptr Cache, - IntrusiveRefCntPtr SharedFS, ScanningOptimizations OptimizeArgs, bool EagerLoadModules, bool TraceVFS, std::time_t BuildSessionTimestamp, bool CacheNegativeStats) : Mode(Mode), Format(Format), CASOpts(std::move(CASOpts)), CAS(std::move(CAS)), Cache(std::move(Cache)), OptimizeArgs(OptimizeArgs), EagerLoadModules(EagerLoadModules), TraceVFS(TraceVFS), CacheNegativeStats(CacheNegativeStats), - SharedFS(std::move(SharedFS)), BuildSessionTimestamp(BuildSessionTimestamp) { - if (!this->SharedFS) - SharedCache.emplace(); - // The FullIncludeTree output format completely subsumes header search and // VFS optimizations due to how it works. Disable these optimizations so // we're not doing unneeded work. diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp index c5561762df7d3..c3f3e3fb53065 100644 --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp @@ -107,31 +107,6 @@ class EmptyDependencyConsumer : public DependencyConsumer { void handleContextHash(std::string Hash) override {} }; -/// Returns a CAS tree containing the dependencies. -class GetDependencyTree : public EmptyDependencyConsumer { -public: - void handleCASFileSystemRootID(std::string ID) override { - CASFileSystemRootID = ID; - } - - Expected getTree() { - if (CASFileSystemRootID) { - auto ID = FS.getCAS().parseID(*CASFileSystemRootID); - if (!ID) - return ID.takeError(); - return FS.getCAS().getProxy(*ID); - } - return llvm::createStringError(llvm::inconvertibleErrorCode(), - "failed to get casfs"); - } - - GetDependencyTree(llvm::cas::CachingOnDiskFileSystem &FS) : FS(FS) {} - -private: - llvm::cas::CachingOnDiskFileSystem &FS; - std::optional CASFileSystemRootID; -}; - /// Returns an IncludeTree containing the dependencies. class GetIncludeTree : public EmptyDependencyConsumer { public: @@ -161,31 +136,6 @@ class GetIncludeTree : public EmptyDependencyConsumer { }; } -llvm::Expected -DependencyScanningTool::getDependencyTree( - const std::vector &CommandLine, StringRef CWD) { - GetDependencyTree Consumer(*Worker.getCASFS()); - auto Controller = createCASFSActionController(nullptr, *Worker.getCASFS()); - auto Result = - Worker.computeDependencies(CWD, CommandLine, Consumer, *Controller); - if (Result) - return std::move(Result); - return Consumer.getTree(); -} - -llvm::Expected -DependencyScanningTool::getDependencyTreeFromCompilerInvocation( - std::shared_ptr Invocation, StringRef CWD, - DiagnosticConsumer &DiagsConsumer, raw_ostream *VerboseOS, - bool DiagGenerationAsCompilation) { - GetDependencyTree Consumer(*Worker.getCASFS()); - auto Controller = createCASFSActionController(nullptr, *Worker.getCASFS()); - Worker.computeDependenciesFromCompilerInvocation( - std::move(Invocation), CWD, Consumer, *Controller, DiagsConsumer, - VerboseOS, DiagGenerationAsCompilation); - return Consumer.getTree(); -} - Expected DependencyScanningTool::getIncludeTree( cas::ObjectStore &DB, const std::vector &CommandLine, StringRef CWD, LookupModuleOutputCallback LookupModuleOutput) { @@ -338,7 +288,6 @@ TranslationUnitDeps FullDependencyConsumer::takeTranslationUnitDeps() { TU.PrebuiltModuleDeps = std::move(PrebuiltModuleDeps); TU.VisibleModules = std::move(VisibleModules); TU.Commands = std::move(Commands); - TU.CASFileSystemRootID = std::move(CASFileSystemRootID); TU.IncludeTreeID = std::move(IncludeTreeID); for (auto &&M : ClangModuleDeps) { @@ -363,8 +312,6 @@ DependencyScanningTool::createActionController( if (Worker.getScanningFormat() == ScanningOutputFormat::FullIncludeTree) return createIncludeTreeActionController(LookupModuleOutput, *Worker.getCAS()); - if (auto CacheFS = Worker.getCASFS()) - return createCASFSActionController(LookupModuleOutput, *CacheFS); return std::make_unique(LookupModuleOutput); } diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp index 626fa95c6f28c..c37bc03d855c2 100644 --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp @@ -32,13 +32,6 @@ DependencyScanningWorker::DependencyScanningWorker( if (Service.shouldTraceVFS()) FS = llvm::makeIntrusiveRefCnt(std::move(FS)); - if (Service.useCASFS()) { - CacheFS = Service.getSharedFS().createProxyFS(); - DepCASFS = new DependencyScanningCASFilesystem(Service, CacheFS); - BaseFS = DepCASFS; - return; - } - switch (Service.getMode()) { case ScanningMode::DependencyDirectivesScan: DepFS = llvm::makeIntrusiveRefCnt( @@ -52,11 +45,6 @@ DependencyScanningWorker::DependencyScanningWorker( } } -llvm::IntrusiveRefCntPtr -DependencyScanningWorker::getOrCreateFileManager() const { - return new FileManager(FileSystemOptions(), BaseFS); -} - DependencyScanningWorker::~DependencyScanningWorker() = default; DependencyActionController::~DependencyActionController() = default; @@ -121,7 +109,7 @@ bool DependencyScanningWorker::scanDependencies( llvm::IntrusiveRefCntPtr FS) { DignosticsEngineWithDiagOpts DiagEngineWithCmdAndOpts(CommandLine, FS, DC); DependencyScanningAction Action( - Service, WorkingDirectory, Consumer, Controller, DepFS, DepCASFS, CacheFS, + Service, WorkingDirectory, Consumer, Controller, DepFS, /*EmitDependencyFile=*/false, /*DiagGenerationAsCompilation=*/false, getCASOpts()); bool Success = false; @@ -176,7 +164,7 @@ bool DependencyScanningWorker::computeDependencies( DiagnosticConsumer &DC, std::optional TUBuffer) { if (TUBuffer) { auto [FinalFS, FinalCommandLine] = initVFSForTUBuferScanning( - BaseFS, CommandLine, WorkingDirectory, *TUBuffer, CAS, DepCASFS); + BaseFS, CommandLine, WorkingDirectory, *TUBuffer, CAS); return scanDependencies(WorkingDirectory, FinalCommandLine, Consumer, Controller, DC, FinalFS); } else { @@ -216,7 +204,7 @@ void DependencyScanningWorker::computeDependenciesFromCompilerInvocation( // FIXME: EmitDependencyFile should only be set when it's for a real // compilation. DependencyScanningAction Action(Service, WorkingDirectory, DepsConsumer, - Controller, DepFS, DepCASFS, CacheFS, + Controller, DepFS, /*EmitDependencyFile=*/!DepFile.empty(), DiagGenerationAsCompilation, getCASOpts(), /*ModuleName=*/std::nullopt, VerboseOS); diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp index 08004223acf90..08142743d8aa3 100644 --- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp +++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp @@ -552,10 +552,8 @@ static std::string getModuleContextHash(const ModuleDeps &MD, // Save and restore options that should not affect the hash, e.g. the exact // contents of input files, or prefix mappings. - auto &FSOpts = const_cast(CI.getFileSystemOpts()); auto &FEOpts = const_cast(CI.getFrontendOpts()); auto &CASOpts = const_cast(CI.getCASOpts()); - llvm::SaveAndRestore RestoreCASFSRootID(FSOpts.CASFileSystemRootID, {}); llvm::SaveAndRestore RestorePrefixMappings(FEOpts.PathPrefixMappings, {}); llvm::SaveAndRestore RestoreCASOptions(CASOpts, {}); @@ -826,9 +824,6 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module *M) { if (!MF->IncludeTreeID.empty()) MD.IncludeTreeID = MF->IncludeTreeID; - if (!MF->CASFileSystemRootID.empty()) - MD.CASFileSystemRootID = MF->CASFileSystemRootID; - bool IgnoreCWD = false; CowCompilerInvocation CI = MDC.getInvocationAdjustedForModuleBuildWithoutOutputs( diff --git a/clang/lib/Tooling/DependencyScanning/ScanAndUpdateArgs.cpp b/clang/lib/Tooling/DependencyScanning/ScanAndUpdateArgs.cpp index 12f9d46c308cd..131611c77f210 100644 --- a/clang/lib/Tooling/DependencyScanning/ScanAndUpdateArgs.cpp +++ b/clang/lib/Tooling/DependencyScanning/ScanAndUpdateArgs.cpp @@ -111,11 +111,6 @@ void tooling::dependencies::configureInvocationForCaching( CodeGenOpts.DebugCompilationDir.clear(); break; } - case CachingInputKind::FileSystemRoot: { - FileSystemOpts.CASFileSystemRootID = std::move(InputID); - FileSystemOpts.CASFileSystemWorkingDirectory = std::move(WorkingDir); - break; - } case CachingInputKind::CachedCompilation: { FrontendOpts.Inputs.clear(); FrontendOpts.CASInputFileCacheKey = std::move(InputID); @@ -150,9 +145,6 @@ void DepscanPrefixMapping::remapInvocationPaths(CompilerInvocation &Invocation, Mapper.mapInPlace(Path); }; - auto &FileSystemOpts = Invocation.getFileSystemOpts(); - Mapper.mapInPlace(FileSystemOpts.CASFileSystemWorkingDirectory); - // Remap header search. auto &HeaderSearchOpts = Invocation.getHeaderSearchOpts(); Mapper.mapInPlace(HeaderSearchOpts.Sysroot); @@ -211,6 +203,7 @@ void DepscanPrefixMapping::remapInvocationPaths(CompilerInvocation &Invocation, Mapper.mapInPlace(FrontendOpts.StatsFile); // Filesystem options. + auto &FileSystemOpts = Invocation.getFileSystemOpts(); Mapper.mapInPlace(FileSystemOpts.WorkingDir); // Code generation options. @@ -261,18 +254,7 @@ Expected clang::scanAndUpdateCC1InlineWithTool( // out of InputArgs) but if they have been overridden we want the new ones. Invocation.getCASOpts() = Tool.getCASOpts(); - bool ProduceIncludeTree = - Tool.getScanningFormat() == - tooling::dependencies::ScanningOutputFormat::IncludeTree; - - std::unique_ptr MapperPtr; - if (ProduceIncludeTree) { - MapperPtr = std::make_unique(); - } else { - MapperPtr = std::make_unique( - Tool.getCachingFileSystem()); - } - llvm::PrefixMapper &Mapper = *MapperPtr; + llvm::PrefixMapper Mapper; DepscanPrefixMapping::configurePrefixMapper(Invocation, Mapper); auto ScanInvocation = std::make_shared(Invocation); @@ -280,31 +262,22 @@ Expected clang::scanAndUpdateCC1InlineWithTool( // failed, but warnings are ignored and deferred for the main compilation. ScanInvocation->getDiagnosticOpts().IgnoreWarnings = true; + LookupModuleOutputCallback Lookup; + std::optional Root; - if (ProduceIncludeTree) { - if (Error E = - Tool.getIncludeTreeFromCompilerInvocation( - DB, std::move(ScanInvocation), WorkingDirectory, - /*LookupModuleOutput=*/nullptr, DiagsConsumer, VerboseOS, - /*DiagGenerationAsCompilation*/ true) - .moveInto(Root)) - return std::move(E); - } else { - if (Error E = Tool.getDependencyTreeFromCompilerInvocation( - std::move(ScanInvocation), WorkingDirectory, - DiagsConsumer, VerboseOS, - /*DiagGenerationAsCompilation*/ true) - .moveInto(Root)) - return std::move(E); - } + if (Error E = + Tool.getIncludeTreeFromCompilerInvocation( + DB, std::move(ScanInvocation), WorkingDirectory, + /*LookupModuleOutput=*/nullptr, DiagsConsumer, VerboseOS, + /*DiagGenerationAsCompilation*/ true) + .moveInto(Root)) + return std::move(E); // Turn off dependency outputs. Should have already been emitted. Invocation.getDependencyOutputOpts().OutputFile.clear(); configureInvocationForCaching(Invocation, Tool.getCASOpts(), Root->toString(), - ProduceIncludeTree - ? CachingInputKind::IncludeTree - : CachingInputKind::FileSystemRoot, + CachingInputKind::IncludeTree, WorkingDirectory.str()); DepscanPrefixMapping::remapInvocationPaths(Invocation, Mapper); return *Root; diff --git a/clang/test/CAS/analyze-action.c b/clang/test/CAS/analyze-action.c index 40f5800388ccb..629339e32771e 100644 --- a/clang/test/CAS/analyze-action.c +++ b/clang/test/CAS/analyze-action.c @@ -7,7 +7,7 @@ // CHECK-DIAG: Value stored to 'v' during its initialization is never read // CHECK-PLIST: Value stored to 'v' during its initialization is never read -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t/t.rsp -cc1-args \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t/t.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macosx12 -fcas-path %t/cas -analyze -analyzer-checker=deadcode -analyzer-output plist %s -o %t/cached.plist // RUN: %clang @%t/t.rsp @@ -21,7 +21,7 @@ // RUN: diff -u %t/regular.plist %t/cached.plist // Check cache is skipped for analyzer html output. -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t/t2.rsp -cc1-args \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t/t2.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macosx12 -fcas-path %t/cas -analyze -analyzer-checker=deadcode -analyzer-output html %s -o %t/analysis // RUN: %clang @%t/t2.rsp -Rcompile-job-cache 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-HTML diff --git a/clang/test/CAS/availability-check.c b/clang/test/CAS/availability-check.c index 9d4ad7d267477..fd7dc42a28bae 100644 --- a/clang/test/CAS/availability-check.c +++ b/clang/test/CAS/availability-check.c @@ -2,17 +2,12 @@ // RUN: %clang_cc1 -triple x86_64-apple-ios14-macabi -isysroot %S/Inputs/MacOSX11.0.sdk -fsyntax-only -verify %s -// RUN: %clang -cc1depscan -o %t/cmd.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args \ -// RUN: -cc1 -fcas-path %t/cas -triple x86_64-apple-ios14-macabi -isysroot %S/Inputs/MacOSX11.0.sdk %s -fsyntax-only - -// RUN: %clang -cc1depscan -o %t/cmd-casfs.rsp -fdepscan=inline -cc1-args \ +// RUN: %clang -cc1depscan -o %t/cmd.rsp -fdepscan=inline -cc1-args \ // RUN: -cc1 -fcas-path %t/cas -triple x86_64-apple-ios14-macabi -isysroot %S/Inputs/MacOSX11.0.sdk %s -fsyntax-only // FIXME: `-verify` should work with a CAS invocation. // RUN: not %clang @%t/cmd.rsp 2> %t/out.txt -// RUN: not %clang @%t/cmd-casfs.rsp 2> %t/out-casfs.txt // RUN: FileCheck -input-file %t/out.txt %s -// RUN: FileCheck -input-file %t/out-casfs.txt %s // CHECK: error: 'fUnavail' is unavailable void fUnavail(void) __attribute__((availability(macOS, obsoleted = 10.15))); // expected-note {{marked unavailable here}} diff --git a/clang/test/CAS/cached-diagnostics.c b/clang/test/CAS/cached-diagnostics.c index 2c5e9b696dd84..da4cc337d9d80 100644 --- a/clang/test/CAS/cached-diagnostics.c +++ b/clang/test/CAS/cached-diagnostics.c @@ -4,7 +4,7 @@ // RUN: %clang_cc1 -triple x86_64-apple-macos12 -fsyntax-only %t/src/main.c -I %t/src/inc -Wunknown-pragmas 2> %t/regular-diags1.txt -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t/t1.rsp -cc1-args \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t/t1.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macos12 -fcas-path %t/cas -fdepscan-prefix-map %t/src /^src \ // RUN: -emit-obj %t/src/main.c -o %t/out/output.o -I %t/src/inc -Wunknown-pragmas @@ -12,7 +12,7 @@ // RUN: %clang @%t/t1.rsp 2> %t/diags1.txt // RUN: diff -u %t/regular-diags1.txt %t/diags1.txt -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t/t1.noprefix.rsp -cc1-args \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t/t1.noprefix.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macos12 -fcas-path %t/cas \ // RUN: -emit-obj %t/src/main.c -o %t/out/output.o -I %t/src/inc -Wunknown-pragmas @@ -41,7 +41,7 @@ // RUN: %clang_cc1 -triple x86_64-apple-macos12 -fsyntax-only %t/src2/main.c -I %t/src2/inc -Wunknown-pragmas 2> %t/regular-diags2.txt -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t/t2.rsp -cc1-args \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t/t2.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macos12 -fcas-path %t/cas -fdepscan-prefix-map %t/src2 /^src \ // RUN: -emit-obj %t/src2/main.c -o %t/out2/output.o -I %t/src2/inc -Wunknown-pragmas // RUN: %clang @%t/t2.rsp -Rcompile-job-cache 2> %t/diags-hit2.txt @@ -54,7 +54,7 @@ // RUN: %clang @%t/t2.rsp 2> %t/cached-diags2.txt // RUN: diff -u %t/regular-diags2.txt %t/cached-diags2.txt -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t/terr.rsp -cc1-args \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t/terr.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macos12 -fcas-path %t/cas -fdepscan-prefix-map %t/src /^src \ // RUN: -emit-obj %t/src/main.c -o %t/out/output.o -I %t/src/inc -Rcompile-job-cache -DERROR diff --git a/clang/test/CAS/cached-diags-scratch-space.c b/clang/test/CAS/cached-diags-scratch-space.c index 6b8f611232f8a..e4fbc40e11a45 100644 --- a/clang/test/CAS/cached-diags-scratch-space.c +++ b/clang/test/CAS/cached-diags-scratch-space.c @@ -1,5 +1,4 @@ // RUN: rm -rf %t && mkdir -p %t -// RUN: llvm-cas --cas %t/cas --ingest %s > %t/casid // Check that this doesn't crash and provides proper round-tripping. @@ -7,15 +6,19 @@ // RUN: -fconst-strings -Wincompatible-pointer-types-discards-qualifiers \ // RUN: -serialize-diagnostic-file %t/regular.dia %s 2> %t/regular-diags.txt -// RUN: %clang -cc1 -triple x86_64-apple-macos12 -fcas-path %t/cas \ -// RUN: -fcas-fs @%t/casid -fcache-compile-job -emit-obj -o %t/output.o \ +// RUN: %clang -cc1depscan -o %t.rsp -fdepscan=inline -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos12 -fcas-path %t/cas \ +// RUN: -fcache-compile-job -emit-obj -o %t/output.o \ // RUN: -fconst-strings -Wincompatible-pointer-types-discards-qualifiers \ -// RUN: -serialize-diagnostic-file %t/t1.dia %s 2> %t/diags1.txt +// RUN: -serialize-diagnostic-file %t/t1.dia %s +// RUN: %clang @%t.rsp 2> %t/diags1.txt -// RUN: %clang -cc1 -triple x86_64-apple-macos12 -fcas-path %t/cas \ -// RUN: -fcas-fs @%t/casid -fcache-compile-job -emit-obj -o %t/output.o \ +// RUN: %clang -cc1depscan -o %t.rsp -fdepscan=inline -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos12 -fcas-path %t/cas \ +// RUN: -fcache-compile-job -emit-obj -o %t/output.o \ // RUN: -fconst-strings -Wincompatible-pointer-types-discards-qualifiers \ -// RUN: -serialize-diagnostic-file %t/t2.dia %s 2> %t/diags2.txt +// RUN: -serialize-diagnostic-file %t/t2.dia %s +// RUN: %clang @%t.rsp 2> %t/diags2.txt // RUN: diff -u %t/regular-diags.txt %t/diags1.txt // RUN: diff -u %t/regular-diags.txt %t/diags2.txt diff --git a/clang/test/CAS/cas-backend.c b/clang/test/CAS/cas-backend.c deleted file mode 100644 index 662c45b0f7212..0000000000000 --- a/clang/test/CAS/cas-backend.c +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: rm -rf %t && mkdir -p %t -// RUN: llvm-cas --cas %t/cas --ingest %s > %t/casid -// -// RUN: %clang -cc1 -fcas-emit-casid-file -triple x86_64-apple-macos11 -fcas-backend \ -// RUN: -fcas-path %t/cas -fcas-fs @%t/casid -fcache-compile-job \ -// RUN: -Rcompile-job-cache %s -emit-obj -o %t/output.o \ -// RUN: -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb \ -// RUN: -dependency-file %t/deps.d -MT %t/output.o 2>&1 \ -// RUN: | FileCheck %s --allow-empty --check-prefix=CACHE-MISS -// -// RUN: ls %t/output.o && rm %t/output.o -// RUN: ls %t/deps.d && mv %t/deps.d %t/deps.d.orig -// -// RUN: %clang -cc1 -fcas-emit-casid-file\ -// RUN: -triple x86_64-apple-macos11 -fcas-backend \ -// RUN: -fcas-path %t/cas -fcas-fs @%t/casid -fcache-compile-job \ -// RUN: -Rcompile-job-cache %s -emit-obj -o %t/output.o \ -// RUN: -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb \ -// RUN: -dependency-file %t/deps.d -MT %t/output.o 2>&1 \ -// RUN: | FileCheck %s --check-prefix=CACHE-HIT -// -// RUN: ls %t/output.o -// RUN: diff -u %t/deps.d %t/deps.d.orig -// RUN: llvm-cas-dump --cas %t/cas --casid-file \ -// RUN: --object-stats - %t/output.o.casid -// -// CACHE-HIT: remark: compile job cache hit -// CACHE-MISS-NOT: remark: compile job cache hit - -void test(void) {} - -int test1(void) { - return 0; -} diff --git a/clang/test/CAS/cas-module-file-use-without-cas.c b/clang/test/CAS/cas-module-file-use-without-cas.c deleted file mode 100644 index 303366a31755c..0000000000000 --- a/clang/test/CAS/cas-module-file-use-without-cas.c +++ /dev/null @@ -1,63 +0,0 @@ -// Tests for reusing a PCM output from CAS builds by a non-cas build. -// This is to simulate a configuration by debugger without CAS support. - -// REQUIRES: ondisk_cas - -// RUN: rm -rf %t %t.cas -// RUN: split-file %s %t - -// RUN: llvm-cas --cas %t.cas --ingest %t > %t/casid - -// == Build B - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fmodule-name=B -fno-implicit-modules \ -// RUN: -emit-module %t/module.modulemap -o %t/B.pcm \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/B.out.txt -// RUN: cat %t/B.out.txt | sed -E "s:^.*cache [a-z]+ for '([^']+)'.*$:\1:" > %t/B.key - -// == Build A, importing B - -// RUN: echo -n '-fmodule-file-cache-key %t/B.pcm ' > %t/B.import.rsp -// RUN: cat %t/B.key >> %t/B.import.rsp - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fmodule-name=A -fno-implicit-modules \ -// RUN: @%t/B.import.rsp -fmodule-file=%t/B.pcm \ -// RUN: -emit-module %t/module.modulemap -o %t/A.pcm \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/A.out.txt -// RUN: cat %t/A.out.txt | sed -E "s:^.*cache [a-z]+ for '([^']+)'.*$:\1:" > %t/A.key - -// == Build tu, importing A and B, without a CAS, this should fail. - -// RUN: not %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: -fmodule-file=%t/A.pcm\ -// RUN: -fmodule-file=%t/B.pcm\ -// RUN: -fsyntax-only %t/tu.c - -// == Using option to ignore CAS info inside module - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: -fmodule-file=%t/A.pcm\ -// RUN: -fmodule-file=%t/B.pcm\ -// RUN: -fsyntax-only %t/tu.c -fmodule-load-ignore-cas - -//--- module.modulemap -module A { header "A.h" export * } -module B { header "B.h" } - -//--- A.h -#include "B.h" - -//--- B.h -void B(void); - -//--- tu.c -#include "A.h" -void tu(void) { - B(); -} diff --git a/clang/test/CAS/cmd-macro-and-pch.c b/clang/test/CAS/cmd-macro-and-pch.c index 2026c561a9cf3..b7a78241e31fd 100644 --- a/clang/test/CAS/cmd-macro-and-pch.c +++ b/clang/test/CAS/cmd-macro-and-pch.c @@ -5,11 +5,11 @@ // RUN: %clang_cc1 -x c-header %t/prefix.h -DSOME_MACRO=1 -emit-pch -o %t/prefix1.pch -Werror // RUN: %clang_cc1 %t/t1.c -include-pch %t/prefix1.pch -DSOME_MACRO=1 -fsyntax-only -Werror -// RUN: %clang -cc1depscan -o %t/pch.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args \ +// RUN: %clang -cc1depscan -o %t/pch.rsp -fdepscan=inline -cc1-args \ // RUN: -cc1 -x c-header %t/prefix.h -emit-pch -DSOME_MACRO=1 -fcas-path %t/cas -Werror // RUN: %clang @%t/pch.rsp -o %t/prefix2.pch -// RUN: %clang -cc1depscan -o %t/tu.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args \ +// RUN: %clang -cc1depscan -o %t/tu.rsp -fdepscan=inline -cc1-args \ // RUN: -cc1 %t/t1.c -fsyntax-only -include-pch %t/prefix2.pch -DSOME_MACRO=1 -fcas-path %t/cas -Werror // RUN: %clang @%t/tu.rsp diff --git a/clang/test/CAS/custom-diags.m b/clang/test/CAS/custom-diags.m index 5bac91f050a1a..aed30ec29c8c0 100644 --- a/clang/test/CAS/custom-diags.m +++ b/clang/test/CAS/custom-diags.m @@ -2,7 +2,7 @@ // RUN: not %clang_cc1 -triple arm64-apple-macosx12 -fsyntax-only %s 2> %t/diags-orig -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t/t.rsp -cc1-args \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t/t.rsp -cc1-args \ // RUN: -cc1 -triple arm64-apple-macosx12 -fcas-path %t/cas -fsyntax-only %s // RUN: not %clang @%t/t.rsp 2> %t/diags-cached diff --git a/clang/test/CAS/depscan-cas-log.c b/clang/test/CAS/depscan-cas-log.c index e3833553593a1..84f80abac4539 100644 --- a/clang/test/CAS/depscan-cas-log.c +++ b/clang/test/CAS/depscan-cas-log.c @@ -6,7 +6,7 @@ // RUN: rm -rf %t && mkdir %t // RUN: env LLVM_CACHE_CAS_PATH=%t/cas LLVM_CAS_LOG=1 LLVM_CAS_DISABLE_VALIDATION=1 %clang \ -// RUN: -cc1depscan -fdepscan=daemon -fdepscan-include-tree -o - \ +// RUN: -cc1depscan -fdepscan=daemon -o - \ // RUN: -cc1-args -cc1 -triple x86_64-apple-macosx11.0.0 -emit-obj %s -o %t/t.o -fcas-path %t/cas // RUN: FileCheck %s --input-file %t/cas/v1.log diff --git a/clang/test/CAS/depscan-dependency-file.c b/clang/test/CAS/depscan-dependency-file.c index 9fcf72649bf07..97d2048686def 100644 --- a/clang/test/CAS/depscan-dependency-file.c +++ b/clang/test/CAS/depscan-dependency-file.c @@ -1,14 +1,14 @@ // RUN: rm -rf %t && mkdir -p %t // RUN: split-file %s %t -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t/t.rsp -cc1-args \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t/t.rsp -cc1-args \ // RUN: -cc1 -fcas-path %t/cas -triple x86_64-apple-macos11 %t/main.c -emit-obj -o %t/output.o -isystem %t/sys \ // RUN: -MT deps -dependency-file %t/t.d // RUN: FileCheck %s -input-file=%t/t.d -check-prefix=NOSYS // RUN: FileCheck %s -input-file=%t/t.d -check-prefix=COMMON // Including system headers. -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t/t.rsp -cc1-args \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t/t.rsp -cc1-args \ // RUN: -cc1 -fcas-path %t/cas -triple x86_64-apple-macos11 %t/main.c -emit-obj -o %t/output.o -isystem %t/sys \ // RUN: -MT deps -sys-header-deps -dependency-file %t/t-sys.d // RUN: FileCheck %s -input-file=%t/t-sys.d -check-prefix=WITHSYS -check-prefix=COMMON diff --git a/clang/test/CAS/depscan-include-tree-daemon.c b/clang/test/CAS/depscan-include-tree-daemon.c index b28ba43ebf09c..7be2eee089518 100644 --- a/clang/test/CAS/depscan-include-tree-daemon.c +++ b/clang/test/CAS/depscan-include-tree-daemon.c @@ -2,11 +2,11 @@ // RUN: rm -rf %t // RUN: split-file %s %t -// RUN: %clang -cc1depscan -o %t/inline.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args -cc1 -triple x86_64-apple-macos11.0 \ +// RUN: %clang -cc1depscan -o %t/inline.rsp -fdepscan=inline -cc1-args -cc1 -triple x86_64-apple-macos11.0 \ // RUN: -fsyntax-only %t/t.c -I %t/includes -isysroot %S/Inputs/SDK -fcas-path %t/cas -DSOME_MACRO -dependency-file %t/inline.d -MT deps -// RUN: %clang -cc1depscand -execute %{clang-daemon-dir}/%basename_t -cas-args -fdepscan-include-tree -fcas-path %t/cas -- \ -// RUN: %clang -cc1depscan -o %t/daemon.rsp -fdepscan=daemon -fdepscan-daemon=%{clang-daemon-dir}/%basename_t -fdepscan-include-tree \ +// RUN: %clang -cc1depscand -execute %{clang-daemon-dir}/%basename_t -cas-args -fcas-path %t/cas -- \ +// RUN: %clang -cc1depscan -o %t/daemon.rsp -fdepscan=daemon -fdepscan-daemon=%{clang-daemon-dir}/%basename_t \ // RUN: -cc1-args -cc1 -triple x86_64-apple-macos11.0 \ // RUN: -fsyntax-only %t/t.c -I %t/includes -isysroot %S/Inputs/SDK -fcas-path %t/cas -DSOME_MACRO -dependency-file %t/daemon.d -MT deps diff --git a/clang/test/CAS/depscan-include-tree.c b/clang/test/CAS/depscan-include-tree.c index 628993b6ca0a2..eca2c50fdece8 100644 --- a/clang/test/CAS/depscan-include-tree.c +++ b/clang/test/CAS/depscan-include-tree.c @@ -1,7 +1,7 @@ // RUN: rm -rf %t // RUN: split-file %s %t -// RUN: %clang -cc1depscan -o %t/inline.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args -cc1 -triple x86_64-apple-macos11.0 \ +// RUN: %clang -cc1depscan -o %t/inline.rsp -fdepscan=inline -cc1-args -cc1 -triple x86_64-apple-macos11.0 \ // RUN: -emit-obj %t/t.c -o %t/t.o -dwarf-ext-refs -fmodule-format=obj \ // RUN: -coverage-notes-file=%t/t.gcno -coverage-data-file=%t/t.gcda \ // RUN: -I %t/includes -isysroot %S/Inputs/SDK -fcas-path %t/cas -DSOME_MACRO -dependency-file %t/inline.d -MT deps @@ -18,8 +18,6 @@ // CHECK: "-dwarf-ext-refs" // CHECK: "-coverage-data-file=[[PREFIX]]/t.gcda" // CHECK: "-coverage-notes-file=[[PREFIX]]/t.gcno" -// SHOULD-NOT: "-fcas-fs" -// SHOULD-NOT: "-fcas-fs-working-directory" // SHOULD-NOT: "-I" // SHOULD-NOT: "[[PREFIX]]/t.c" // SHOULD-NOT: "-D" diff --git a/clang/test/CAS/depscan-prefix-map.c b/clang/test/CAS/depscan-prefix-map.c deleted file mode 100644 index 51f2364a63a38..0000000000000 --- a/clang/test/CAS/depscan-prefix-map.c +++ /dev/null @@ -1,71 +0,0 @@ -// REQUIRES: clang-cc1daemon -// -// Check with prefix mapping: -// -// RUN: rm -rf %t.d -// RUN: mkdir %t.d -// RUN: %clang -cc1depscan -dump-depscan-tree=%t.root -fdepscan=inline \ -// RUN: -cc1-args -triple x86_64-apple-macos11.0 -x c %s -o %t.d/out.o \ -// RUN: -isysroot %S/Inputs/SDK \ -// RUN: -resource-dir %S/Inputs/toolchain_dir/usr/lib/clang/1000 \ -// RUN: -internal-isystem %S/Inputs/toolchain_dir/usr/lib/clang/1000/include \ -// RUN: -working-directory %t.d \ -// RUN: -fcas-path %t.d/cas \ -// RUN: -fdepscan-prefix-map %S /^source \ -// RUN: -fdepscan-prefix-map %t.d /^testdir \ -// RUN: -fdepscan-prefix-map %{objroot} /^objroot \ -// RUN: -fdepscan-prefix-map %S/Inputs/toolchain_dir /^toolchain \ -// RUN: -fdepscan-prefix-map %S/Inputs/SDK /^sdk \ -// RUN: -fdepfile-entry=%t.d/extra \ -// RUN: | FileCheck %s -DPREFIX=%t.d -// RUN: %clang -cc1depscan -dump-depscan-tree=%t.root -fdepscan=inline \ -// RUN: -cc1-args -triple x86_64-apple-macos11.0 -x c %s -o %t.d/out.o \ -// RUN: -isysroot %S/Inputs/SDK \ -// RUN: -resource-dir %S/Inputs/toolchain_dir/lib/clang/1000 \ -// RUN: -internal-isystem %S/Inputs/toolchain_dir/lib/clang/1000/include \ -// RUN: -working-directory %t.d \ -// RUN: -fcas-path %t.d/cas \ -// RUN: -fdepscan-prefix-map %S /^source \ -// RUN: -fdepscan-prefix-map %t.d /^testdir \ -// RUN: -fdepscan-prefix-map %{objroot} /^objroot \ -// RUN: -fdepscan-prefix-map %S/Inputs/toolchain_dir /^toolchain \ -// RUN: -fdepscan-prefix-map %S/Inputs/SDK /^sdk \ -// RUN: -fdepfile-entry=%t.d/extra \ -// RUN: | FileCheck %s -DPREFIX=%t.d -// RUN: %clang -cc1depscand -execute %{clang-daemon-dir}/%basename_t \ -// RUN: -cas-args -fcas-path %t.d/cas -- \ -// RUN: %clang -cc1depscan -dump-depscan-tree=%t.root -fdepscan=daemon \ -// RUN: -fdepscan-daemon=%{clang-daemon-dir}/%basename_t \ -// RUN: -cc1-args -triple x86_64-apple-macos11.0 -x c %s -o %t.d/out.o \ -// RUN: -isysroot %S/Inputs/SDK \ -// RUN: -resource-dir %S/Inputs/toolchain_dir/usr/lib/clang/1000 \ -// RUN: -internal-isystem %S/Inputs/toolchain_dir/usr/lib/clang/1000/include \ -// RUN: -working-directory %t.d \ -// RUN: -fcas-path %t.d/cas \ -// RUN: -fdepscan-prefix-map %S /^source \ -// RUN: -fdepscan-prefix-map %t.d /^testdir \ -// RUN: -fdepscan-prefix-map %{objroot} /^objroot \ -// RUN: -fdepscan-prefix-map %S/Inputs/toolchain_dir /^toolchain \ -// RUN: -fdepscan-prefix-map %S/Inputs/SDK /^sdk \ -// RUN: -fdepfile-entry=%t.d/extra \ -// RUN: | FileCheck %s -DPREFIX=%t.d -// -// CHECK: "-fcas-path" "[[PREFIX]]/cas" -// CHECK-SAME: "-working-directory" "/^testdir" -// CHECK-SAME: "-x" "c" "/^source/depscan-prefix-map.c" -// CHECK-SAME: "-isysroot" "/^sdk" -// CHECK-SAME: "-fdepfile-entry=/^testdir/extra" - -// RUN: llvm-cas --cas %t.d/cas --ls-tree-recursive @%t.root \ -// RUN: | FileCheck %s -check-prefix=CHECK-ROOT -// -// RUN: llvm-cas --cas %t.d/cas --ls-tree-recursive @%t.root \ -// RUN: | FileCheck %s -check-prefix=CHECK-ROOT -// -// CHECK-ROOT: tree -// CHECK-ROOT-SAME: /^objroot/test/CAS/{{$}} -// CHECK-ROOT-NEXT: file {{.*}} /^source/depscan-prefix-map.c{{$}} -// CHECK-ROOT-NEXT: file {{.*}} /^toolchain/usr/lib/clang/1000/include/stdarg.h{{$}} - -#include -int test() { return 0; } diff --git a/clang/test/CAS/driver-cache-launcher.c b/clang/test/CAS/driver-cache-launcher.c index b9ef76d6f2ac1..16e2565e2f2a2 100644 --- a/clang/test/CAS/driver-cache-launcher.c +++ b/clang/test/CAS/driver-cache-launcher.c @@ -24,10 +24,6 @@ // RUN: env LLVM_CACHE_CAS_PATH=%t/cas %clang-cache %clang -c %s -o %t.o -### 2>&1 | FileCheck %s -check-prefix=INCLUDE-TREE -DPREFIX=%t // INCLUDE-TREE: "-cc1depscan" "-fdepscan=auto" -// INCLUDE-TREE: "-fdepscan-include-tree" - -// RUN: env LLVM_CACHE_CAS_PATH=%t/cas CLANG_CACHE_USE_CASFS_DEPSCAN=1 %clang-cache %clang -c %s -o %t.o -### 2>&1 | FileCheck %s -check-prefix=CASFS-SCAN -DPREFIX=%t -// CASFS-SCAN-NOT: "-fdepscan-include-tree" // RUN: env LLVM_CACHE_CAS_PATH=%t/cas cache-build-session %clang-cache %clang -c %s -o %t.o -### 2>&1 | FileCheck %s -check-prefix=SESSION -DPREFIX=%t // SESSION: "-cc1depscan" "-fdepscan=daemon" "-fdepscan-share-identifier" diff --git a/clang/test/CAS/fcache-compile-job-dependency-file.c b/clang/test/CAS/fcache-compile-job-dependency-file.c index e8796fa273dba..f246eb1f27c23 100644 --- a/clang/test/CAS/fcache-compile-job-dependency-file.c +++ b/clang/test/CAS/fcache-compile-job-dependency-file.c @@ -2,11 +2,12 @@ // RUN: split-file %s %t/src // RUN: llvm-cas --cas %t/cas --ingest %t/src > %t/casid // -// RUN: %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas -fcas-fs @%t/casid -fcache-compile-job \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos11 \ +// RUN: -fcas-path %t/cas -fcache-compile-job \ // RUN: -Rcompile-job-cache %t/src/main.c -emit-obj -o %t/output.o -isystem %t/src/sys \ -// RUN: -dependency-file %t/deps1.d -MT depends 2>&1 \ -// RUN: | FileCheck %s --allow-empty --check-prefix=CACHE-MISS +// RUN: -dependency-file %t/deps1.d -MT depends +// RUN: %clang @%t.rsp 2>&1 | FileCheck %s --allow-empty --check-prefix=CACHE-MISS // // RUN: FileCheck %s --input-file=%t/deps1.d --check-prefix=DEPS // DEPS: depends: @@ -16,11 +17,12 @@ // RUN: ls %t/output.o && rm %t/output.o // -// RUN: %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas -fcas-fs @%t/casid -fcache-compile-job \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos11 \ +// RUN: -fcas-path %t/cas -fcache-compile-job \ // RUN: -Rcompile-job-cache %t/src/main.c -emit-obj -o %t/output.o -isystem %t/src/sys \ -// RUN: -dependency-file %t/deps2.d -MT depends 2>&1 \ -// RUN: | FileCheck %s --check-prefix=CACHE-HIT +// RUN: -dependency-file %t/deps2.d -MT depends +// RUN: %clang @%t.rsp 2>&1 | FileCheck %s --allow-empty --check-prefix=CACHE-HIT // // RUN: ls %t/output.o // RUN: diff -u %t/deps1.d %t/deps2.d @@ -28,11 +30,12 @@ // CACHE-HIT: remark: compile job cache hit // CACHE-MISS-NOT: remark: compile job cache hit -// RUN: %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas -fcas-fs @%t/casid -fcache-compile-job \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos11 \ +// RUN: -fcas-path %t/cas -fcache-compile-job \ // RUN: -Rcompile-job-cache %t/src/main.c -emit-obj -o %t/output.o -isystem %t/src/sys \ -// RUN: -dependency-file %t/deps3.d -MT other1 -MT other2 -MP -fdepfile-entry=extra-depfile.json 2>&1 \ -// RUN: | FileCheck %s --check-prefix=CACHE-HIT +// RUN: -dependency-file %t/deps3.d -MT other1 -MT other2 -MP -fdepfile-entry=extra-depfile.json +// RUN: %clang @%t.rsp 2>&1 | FileCheck %s --check-prefix=CACHE-HIT // RUN: FileCheck %s --input-file=%t/deps3.d --check-prefix=DEPS_OTHER // DEPS_OTHER: other1 other2: @@ -42,11 +45,12 @@ // DEPS_OTHER-NOT: sys.h // DEPS_OTHER: my_header.h: -// RUN: %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas -fcas-fs @%t/casid -fcache-compile-job \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos11 \ +// RUN: -fcas-path %t/cas -fcache-compile-job \ // RUN: -Rcompile-job-cache %t/src/main.c -emit-obj -o %t/output.o -isystem %t/src/sys \ -// RUN: -sys-header-deps -dependency-file %t/deps4.d -MT depends 2>&1 \ -// RUN: | FileCheck %s --check-prefix=CACHE-MISS +// RUN: -sys-header-deps -dependency-file %t/deps4.d -MT depends +// RUN: %clang @%t.rsp 2>&1 | FileCheck %s --check-prefix=CACHE-MISS // Note: currently options that affect the list of deps (like sys-header-deps) // are part of the cache key, to avoid saving unnecessary paths. @@ -58,24 +62,25 @@ // DEPS_SYS: sys.h // Using another cas path to avoid reusing artifacts. -// RUN: llvm-cas --cas %t/cas2 --ingest %t/src -// RUN: %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas2 -fcas-fs @%t/casid -fcache-compile-job \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos11 \ +// RUN: -fcas-path %t/cas2 -fcache-compile-job \ // RUN: -Rcompile-job-cache %t/src/main.c -emit-obj -o %t/output.o -isystem %t/src/sys \ -// RUN: -dependency-file %t/deps-depfile1.d -MT deps -fdepfile-entry=extra-depfile.json -fdepfile-entry=%t/main.c 2>&1 \ -// RUN: | FileCheck %s --check-prefix=CACHE-MISS +// RUN: -dependency-file %t/deps-depfile1.d -MT deps -fdepfile-entry=extra-depfile.json -fdepfile-entry=%t/main.c +// RUN: %clang @%t.rsp 2>&1 | FileCheck %s --check-prefix=CACHE-MISS // RUN: FileCheck %s --input-file=%t/deps-depfile1.d --check-prefix=DEPS_DEPFILE1 // DEPS_DEPFILE1: deps: // DEPS_DEPFILE1: extra-depfile.json // DEPS_DEPFILE1: main.c -// RUN: %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas2 -fcas-fs @%t/casid -fcache-compile-job \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos11 \ +// RUN: -fcas-path %t/cas2 -fcache-compile-job \ // RUN: -Rcompile-job-cache %t/src/main.c -emit-obj -o %t/output.o -isystem %t/src/sys \ -// RUN: -dependency-file %t/deps-depfile2.d -MT deps 2>&1 \ -// RUN: | FileCheck %s --check-prefix=CACHE-HIT +// RUN: -dependency-file %t/deps-depfile2.d -MT deps +// RUN: %clang @%t.rsp 2>&1 | FileCheck %s --check-prefix=CACHE-HIT // RUN: FileCheck %s --input-file=%t/deps-depfile2.d --check-prefix=DEPS_DEPFILE2 // DEPS_DEPFILE2-NOT: extra-depfile.json diff --git a/clang/test/CAS/fcache-compile-job-serialized-diagnostics.c b/clang/test/CAS/fcache-compile-job-serialized-diagnostics.c deleted file mode 100644 index 2d3ece2b6f04b..0000000000000 --- a/clang/test/CAS/fcache-compile-job-serialized-diagnostics.c +++ /dev/null @@ -1,63 +0,0 @@ -// RUN: rm -rf %t && mkdir -p %t -// RUN: llvm-cas --cas %t/cas --ingest %s > %t/casid - -// RUN: %clang -cc1 -triple x86_64-apple-macos11 -fcas-path %t/cas \ -// RUN: -fcas-fs @%t/casid -fcache-compile-job \ -// RUN: -Wimplicit-function-declaration \ -// RUN: -Wno-error=implicit-function-declaration \ -// RUN: -Rcompile-job-cache -emit-obj -o %t/output.o \ -// RUN: -serialize-diagnostic-file %t/diags %s 2>&1 \ -// RUN: | FileCheck %s --allow-empty --check-prefix=CACHE-MISS - -// RUN: c-index-test -read-diagnostics %t/diags 2>&1 | FileCheck %s --check-prefix=SERIALIZED-MISS --check-prefix=SERIALIZED-COMMON - -// RUN: ls %t/output.o && rm %t/output.o - -// RUN: %clang -cc1 -triple x86_64-apple-macos11 -fcas-path %t/cas \ -// RUN: -fcas-fs @%t/casid -fcache-compile-job \ -// RUN: -Wimplicit-function-declaration \ -// RUN: -Wno-error=implicit-function-declaration \ -// RUN: -Rcompile-job-cache -emit-obj -o %t/output.o \ -// RUN: -serialize-diagnostic-file %t/diags %s 2>&1 \ -// RUN: | FileCheck %s --check-prefix=CACHE-HIT - -// RUN: c-index-test -read-diagnostics %t/diags 2>&1 | FileCheck %s --check-prefix=SERIALIZED-HIT --check-prefix=SERIALIZED-COMMON - -// CACHE-HIT: remark: compile job cache hit -// CACHE-HIT: warning: some warning - -// CACHE-MISS: remark: compile job cache miss -// CACHE-MISS: warning: some warning - -// SERIALIZED-HIT: warning: compile job cache hit -// SERIALIZED-MISS: warning: compile job cache miss -// SERIALIZED-COMMON: warning: some warning -// SERIALIZED-COMMON: Number of diagnostics: 2 - -// Make sure warnings are merged with driver ones. -// Using normal compilation as baseline. -// RUN: %clang -target x86_64-apple-macos11 -c %s -o %t/t.o -Wl,-none --serialize-diagnostics %t/t1.diag \ -// RUN: 2>&1 | FileCheck %s -check-prefix=WARN -// RUN: env LLVM_CACHE_CAS_PATH=%t/cas CLANG_CACHE_USE_CASFS_DEPSCAN=1 %clang-cache \ -// RUN: %clang -target x86_64-apple-macos11 -c %s -o %t/t.o -Wl,-none --serialize-diagnostics %t/t2.diag \ -// RUN: 2>&1 | FileCheck %s -check-prefix=WARN -// RUN: env LLVM_CACHE_CAS_PATH=%t/cas %clang-cache \ -// RUN: %clang -target x86_64-apple-macos11 -c %s -o %t/t.o -Wl,-none --serialize-diagnostics %t/t2.inc.diag \ -// RUN: 2>&1 | FileCheck %s -check-prefix=WARN -// RUN: diff %t/t1.diag %t/t2.diag -// RUN: diff %t/t1.diag %t/t2.inc.diag - -// Try again with cache hit. -// RUN: rm %t/t2.diag -// RUN: env LLVM_CACHE_CAS_PATH=%t/cas CLANG_CACHE_USE_CASFS_DEPSCAN=1 %clang-cache \ -// RUN: %clang -target x86_64-apple-macos11 -c %s -o %t/t.o -Wl,-none --serialize-diagnostics %t/t2.diag -// RUN: env LLVM_CACHE_CAS_PATH=%t/cas %clang-cache \ -// RUN: %clang -target x86_64-apple-macos11 -c %s -o %t/t.o -Wl,-none --serialize-diagnostics %t/t2.inc.diag \ -// RUN: 2>&1 | FileCheck %s -check-prefix=WARN -// RUN: diff %t/t1.diag %t/t2.diag -// RUN: diff %t/t1.diag %t/t2.inc.diag - -// WARN: warning: -Wl,-none: 'linker' input unused -// WARN: warning: some warning - -#warning some warning diff --git a/clang/test/CAS/fcache-compile-job.c b/clang/test/CAS/fcache-compile-job.c index 58c8e41a3b4d8..7288b3c68bbab 100644 --- a/clang/test/CAS/fcache-compile-job.c +++ b/clang/test/CAS/fcache-compile-job.c @@ -1,28 +1,31 @@ // RUN: rm -rf %t && mkdir -p %t -// RUN: llvm-cas --cas %t/cas --ingest %s > %t/casid -// -// RUN: %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas -fcas-fs @%t/casid -fcache-compile-job \ -// RUN: -Rcompile-job-cache -emit-obj %s -o %t/output.o 2>&1 \ + +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos11 \ +// RUN: -fcas-path %t/cas -emit-obj %s -o %t/output.o +// RUN: %clang @%t.rsp -fcache-compile-job -Rcompile-job-cache 2>&1 \ // RUN: | FileCheck %s --allow-empty --check-prefix=CACHE-MISS // RUN: ls %t/output.o && rm %t/output.o -// RUN: %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas -fcas-fs @%t/casid -fcache-compile-job \ -// RUN: -Rcompile-job-cache -emit-obj %s -o %t/output.o 2>&1 \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos11 \ +// RUN: -fcas-path %t/cas -emit-obj %s -o %t/output.o +// RUN: %clang @%t.rsp -fcache-compile-job -Rcompile-job-cache 2>&1 \ // RUN: | FileCheck %s --check-prefix=CACHE-HIT // RUN: ls %t/output.o && rm %t/output.o // RUN: cd %t -// RUN: %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas -fcas-fs @%t/casid -fcache-compile-job \ -// RUN: -Rcompile-job-cache -emit-obj %s -o output.o 2>&1 \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos11 \ +// RUN: -fcas-path %t/cas -emit-obj %s -o output.o +// RUN: %clang @%t.rsp -fcache-compile-job -Rcompile-job-cache 2>&1 \ // RUN: | FileCheck %s --allow-empty --check-prefix=CACHE-HIT // RUN: ls %t/output.o // // Check for a cache hit if the CAS moves: // RUN: mv %t/cas %t/cas.moved -// RUN: %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas.moved -fcas-fs @%t/casid -fcache-compile-job \ -// RUN: -Rcompile-job-cache -emit-obj %s -o output.o 2> %t/cache-hit.out +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos11 \ +// RUN: -fcas-path %t/cas.moved -emit-obj %s -o output.o +// RUN: %clang @%t.rsp -fcache-compile-job -Rcompile-job-cache 2> %t/cache-hit.out // RUN: FileCheck %s -input-file=%t/cache-hit.out --check-prefix=CACHE-HIT // RUN: ls %t/output.o @@ -33,14 +36,14 @@ // RUN: -e "s/^.*=> '//" \ // RUN: -e "s/' .*$//" > %t/cache-result -// Check for a handling error if the CAS is removed but not action cache. -// First need to ingest the input file so the compile cache can be constructed. -// RUN: llvm-cas --ingest --cas %t/cas.new %s +// Check for a handling error if the result in the CAS is removed but not action cache. +// First need to construct the include-tree and the compilation key. +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos11 \ +// RUN: -fcas-path %t/cas.new -emit-obj %s -o output.o // Add the 'key => result' association we got earlier. // RUN: llvm-cas --cas %t/cas.new --put-cache-key @%t/cache-key @%t/cache-result -// RUN: %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas.new -fcas-fs @%t/casid -fcache-compile-job \ -// RUN: -Rcompile-job-cache -emit-obj %s -o output.o 2>&1 \ +// RUN: %clang @%t.rsp -fcache-compile-job -Rcompile-job-cache 2>&1 \ // RUN: | FileCheck %s --check-prefix=CACHE-RESULT // RUN: ls %t/output.o // diff --git a/clang/test/CAS/fcas-include-tree-prefix-mapping.c b/clang/test/CAS/fcas-include-tree-prefix-mapping.c index 4eaca1a762504..4addfca3d2c12 100644 --- a/clang/test/CAS/fcas-include-tree-prefix-mapping.c +++ b/clang/test/CAS/fcas-include-tree-prefix-mapping.c @@ -2,7 +2,7 @@ // RUN: split-file %s %t/src // RUN: mkdir %t/out -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree \ +// RUN: %clang -cc1depscan -fdepscan=inline \ // RUN: -o %t/t1.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macos11 -fcas-path %t/cas -Rcompile-job-cache \ // RUN: -resource-dir %S/Inputs/toolchain_dir/lib/clang/1000 -internal-isystem %S/Inputs/toolchain_dir/lib/clang/1000/include \ @@ -42,7 +42,7 @@ // RUN: split-file %s %t/src2 // RUN: mkdir %t/out2 -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree \ +// RUN: %clang -cc1depscan -fdepscan=inline \ // RUN: -o %t/t2.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macos11 -fcas-path %t/cas -Rcompile-job-cache \ // RUN: -resource-dir %S/Inputs/toolchain_dir/lib/clang/1000 -internal-isystem %S/Inputs/toolchain_dir/lib/clang/1000/include \ @@ -80,7 +80,7 @@ // Check with PCH. -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree \ +// RUN: %clang -cc1depscan -fdepscan=inline \ // RUN: -o %t/pch1.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macos11 -fcas-path %t/cas -Rcompile-job-cache \ // RUN: -resource-dir %S/Inputs/toolchain_dir/lib/clang/1000 -internal-isystem %S/Inputs/toolchain_dir/lib/clang/1000/include \ @@ -93,7 +93,7 @@ // RUN: %clang @%t/pch1.rsp // With different cas path to avoid cache hit. -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree \ +// RUN: %clang -cc1depscan -fdepscan=inline \ // RUN: -o %t/pch2.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macos11 -fcas-path %t/cas2 -Rcompile-job-cache \ // RUN: -resource-dir %S/Inputs/toolchain_dir/lib/clang/1000 -internal-isystem %S/Inputs/toolchain_dir/lib/clang/1000/include \ @@ -107,7 +107,7 @@ // RUN: diff %t/out/prefix.h.pch %t/out2/prefix.h.pch -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree \ +// RUN: %clang -cc1depscan -fdepscan=inline \ // RUN: -o %t/t3.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macos11 -fcas-path %t/cas -Rcompile-job-cache \ // RUN: -resource-dir %S/Inputs/toolchain_dir/lib/clang/1000 -internal-isystem %S/Inputs/toolchain_dir/lib/clang/1000/include \ @@ -124,7 +124,7 @@ // RUN: -e "s/^.*miss for '//" \ // RUN: -e "s/' .*$//" > %t/cache-key3 -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree \ +// RUN: %clang -cc1depscan -fdepscan=inline \ // RUN: -o %t/t4.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macos11 -fcas-path %t/cas -Rcompile-job-cache \ // RUN: -resource-dir %S/Inputs/toolchain_dir/lib/clang/1000 -internal-isystem %S/Inputs/toolchain_dir/lib/clang/1000/include \ diff --git a/clang/test/CAS/fcas-include-tree-with-pch.c b/clang/test/CAS/fcas-include-tree-with-pch.c index 234a18baf3ab0..18e7064bacb32 100644 --- a/clang/test/CAS/fcas-include-tree-with-pch.c +++ b/clang/test/CAS/fcas-include-tree-with-pch.c @@ -8,11 +8,11 @@ // RUN: %clang_cc1 -x c-header %t/prefix.h -I %t/inc -DCMD_MACRO=1 -emit-pch -o %t/prefix1.pch // RUN: %clang_cc1 %t/t1.c -include-pch %t/prefix1.pch -emit-llvm -o %t/source.ll -I %t/inc -DCMD_MACRO=1 -// RUN: %clang -cc1depscan -o %t/pch.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args \ +// RUN: %clang -cc1depscan -o %t/pch.rsp -fdepscan=inline -cc1-args \ // RUN: -cc1 -emit-pch -x c-header %t/prefix.h -I %t/inc -DCMD_MACRO=1 -fcas-path %t/cas // RUN: %clang @%t/pch.rsp -o %t/prefix2.pch -// RUN: %clang -cc1depscan -o %t/tu.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args \ +// RUN: %clang -cc1depscan -o %t/tu.rsp -fdepscan=inline -cc1-args \ // RUN: -cc1 -emit-llvm %t/t1.c -include-pch %t/prefix2.pch -I %t/inc -DCMD_MACRO=1 -fcas-path %t/cas // RUN: rm %t/prefix2.pch @@ -26,11 +26,11 @@ // RUN: %clang_cc1 -x c-header prefix.h -I %t/inc -DCMD_MACRO=1 -emit-pch -o prefix3.pch // RUN: %clang_cc1 t1.c -include-pch prefix3.pch -emit-llvm -o source-rel.ll -I inc -DCMD_MACRO=1 -// RUN: %clang -cc1depscan -o pch2.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args \ +// RUN: %clang -cc1depscan -o pch2.rsp -fdepscan=inline -cc1-args \ // RUN: -cc1 -emit-pch -x c-header prefix.h -I %t/inc -DCMD_MACRO=1 -fcas-path %t/cas // RUN: %clang @pch2.rsp -o prefix4.pch -// RUN: %clang -cc1depscan -o tu2.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args \ +// RUN: %clang -cc1depscan -o tu2.rsp -fdepscan=inline -cc1-args \ // RUN: -cc1 -emit-llvm t1.c -include-pch prefix4.pch -I inc -DCMD_MACRO=1 -fcas-path %t/cas // RUN: rm %t/prefix4.pch @@ -38,7 +38,7 @@ // RUN: diff -u source-rel.ll tree-rel.ll // Check that -coverage-notes-file and -coverage-data-file are stripped -// RUN: %clang -cc1depscan -o pch3.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args \ +// RUN: %clang -cc1depscan -o pch3.rsp -fdepscan=inline -cc1-args \ // RUN: -cc1 -emit-pch -x c-header prefix.h -I %t/inc -DCMD_MACRO=1 -fcas-path %t/cas \ // RUN: -coverage-notes-file=%t/pch.gcno -coverage-data-file=%t/pch.gcda // RUN: FileCheck %s -check-prefix=COVERAGE -input-file %t/pch3.rsp diff --git a/clang/test/CAS/fcas-include-tree.c b/clang/test/CAS/fcas-include-tree.c index ad95e4ae13b24..9a7709fab816a 100644 --- a/clang/test/CAS/fcas-include-tree.c +++ b/clang/test/CAS/fcas-include-tree.c @@ -4,11 +4,11 @@ // RUN: %clang_cc1 %t/t1.c -E -P -o %t/source.i -isystem %t -DCMD_MACRO=1 -Werror // RUN: %clang_cc1 %t/t1.c -emit-llvm -o %t/source.ll -isystem %t -DCMD_MACRO=1 -Werror -dependency-file %t/t1-source.d -MT deps -// RUN: %clang -cc1depscan -o %t/inline.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args \ +// RUN: %clang -cc1depscan -o %t/inline.rsp -fdepscan=inline -cc1-args \ // RUN: -cc1 -E -P %t/t1.c -isystem %t -DCMD_MACRO=1 -fcas-path %t/cas -Werror // RUN: %clang @%t/inline.rsp -o %t/tree.i // RUN: diff -u %t/source.i %t/tree.i -// RUN: %clang -cc1depscan -o %t/inline2.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args \ +// RUN: %clang -cc1depscan -o %t/inline2.rsp -fdepscan=inline -cc1-args \ // RUN: -cc1 -emit-llvm %t/t1.c -isystem %t -DCMD_MACRO=1 -fcas-path %t/cas -Werror -dependency-file %t/t1-tree.d -MT deps // RUN: %clang @%t/inline2.rsp -o %t/tree.ll // RUN: diff -u %t/source.ll %t/tree.ll diff --git a/clang/test/CAS/fmodule-file-cache-key-errors.c b/clang/test/CAS/fmodule-file-cache-key-errors.c deleted file mode 100644 index 1879069a1f3cc..0000000000000 --- a/clang/test/CAS/fmodule-file-cache-key-errors.c +++ /dev/null @@ -1,106 +0,0 @@ -// Checks error conditions related to -fmodule-file-cache-key, e.g. missing -// cache entry, invalid id, etc. - -// REQUIRES: ondisk_cas - -// RUN: rm -rf %t %t.cas %t.cas_2 -// RUN: split-file %s %t - -// RUN: llvm-cas --cas %t.cas --ingest %t > %t/casid - -// RUN: not %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: -fmodule-file-cache-key=INVALID \ -// RUN: -fsyntax-only %t/tu.c \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/invalid.txt -// RUN: cat %t/invalid.txt | FileCheck %s -check-prefix=INVALID - -// INVALID: error: unknown argument: '-fmodule-file-cache-key=INVALID' - -// RUN: not %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: -fmodule-file-cache-key INVALID \ -// RUN: -fsyntax-only %t/tu.c \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/invalid2.txt -// RUN: FileCheck %s -check-prefix=INVALID2 -input-file=%t/invalid2.txt - -// INVALID2: error: module file 'INVALID' not found: unloadable module cache key -fsyntax-only: invalid cas-id '-fsyntax-only' - -// RUN: not %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: -fmodule-file-cache-key INVALID ALSO_INVALID MORE_INVALID \ -// RUN: -fsyntax-only %t/tu.c \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/invalid3.txt -// RUN: FileCheck %s -check-prefix=INVALID3 -input-file=%t/invalid3.txt - -// INVALID3: error: error reading 'MORE_INVALID' - -// RUN: not %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: -fmodule-file-cache-key PATH KEY \ -// RUN: -fsyntax-only %t/tu.c \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/bad_key.txt -// RUN: cat %t/bad_key.txt | FileCheck %s -check-prefix=BAD_KEY - -// BAD_KEY: error: module file 'PATH' not found: unloadable module cache key KEY: invalid cas-id 'KEY' - -// RUN: echo -n '-fmodule-file-cache-key PATH ' > %t/bad_key2.rsp -// RUN: cat %t/casid >> %t/bad_key2.rsp - -// RUN: not %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: @%t/bad_key2.rsp \ -// RUN: -fsyntax-only %t/tu.c \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/bad_key2.txt -// RUN: cat %t/bad_key2.txt | FileCheck %s -check-prefix=BAD_KEY2 - -// BAD_KEY2: error: module file 'PATH' not found: missing module cache key {{.*}}: module file is not available in the CAS - -// == Build A - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fmodule-name=A -fno-implicit-modules \ -// RUN: -emit-module %t/module.modulemap -o %t/A.pcm \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/A.out.txt -// RUN: cat %t/A.out.txt | FileCheck %s --check-prefix=CACHE-MISS -// CACHE-MISS: remark: compile job cache miss -// RUN: cat %t/A.out.txt | sed -E "s:^.*cache [a-z]+ for '([^']+)'.*$:\1:" > %t/A.key - -// == Try to import A with an empty action cache, simulating a missing module - -// RUN: llvm-cas --cas %t.cas_2 --import --upstream-cas %t.cas @%t/A.key - -// RUN: echo -n '-fmodule-file-cache-key PATH ' > %t/not_in_cache.rsp -// RUN: cat %t/A.key >> %t/not_in_cache.rsp - -// RUN: not %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: @%t/not_in_cache.rsp \ -// RUN: -fsyntax-only %t/tu.c \ -// RUN: -fcas-path %t.cas_2 -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/not_in_cache.txt -// RUN: cat %t/not_in_cache.txt | FileCheck %s -check-prefix=NOT_IN_CACHE -DPREFIX=%/t - -// NOT_IN_CACHE: error: module file 'PATH' not found: missing module cache key {{.*}}: expected to be produced by: -// NOT_IN_CACHE: command-line: -// NOT_IN_CACHE: -cc1 -// NOT_IN_CACHE: filesystem: -// NOT_IN_CACHE: file llvmcas://{{.*}} [[PREFIX]]/A.h - -//--- module.modulemap -module A { header "A.h" } - -//--- A.h -void A(void); - -//--- tu.c -#include "A.h" -void tu(void) { - A(); -} diff --git a/clang/test/CAS/fmodule-file-cache-key-lazy.c b/clang/test/CAS/fmodule-file-cache-key-lazy.c deleted file mode 100644 index 12132d84d6bf0..0000000000000 --- a/clang/test/CAS/fmodule-file-cache-key-lazy.c +++ /dev/null @@ -1,77 +0,0 @@ -// Tests for combining -fmodule-file-cache-key with lazy-loading modules via -// -fmodule-file==. - -// REQUIRES: ondisk_cas - -// RUN: rm -rf %t %t.cas -// RUN: split-file %s %t - -// RUN: llvm-cas --cas %t.cas --ingest %t > %t/casid - -// == Build B - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fmodule-name=B -fno-implicit-modules \ -// RUN: -emit-module %t/module.modulemap -o %t/B.pcm \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/B.out.txt -// RUN: cat %t/B.out.txt | FileCheck %s --check-prefix=CACHE-MISS -// RUN: cat %t/B.out.txt | sed -E "s:^.*cache [a-z]+ for '([^']+)'.*$:\1:" > %t/B.key - -// == Build A, importing B - -// RUN: echo -n '-fmodule-file-cache-key %t/B.pcm ' > %t/B.import.rsp -// RUN: cat %t/B.key >> %t/B.import.rsp - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fmodule-name=A -fno-implicit-modules \ -// RUN: @%t/B.import.rsp -fmodule-file=B=%t/B.pcm \ -// RUN: -emit-module %t/module.modulemap -o %t/A.pcm \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/A.out.txt -// RUN: cat %t/A.out.txt | FileCheck %s --check-prefix=CACHE-MISS -// RUN: cat %t/A.out.txt | sed -E "s:^.*cache [a-z]+ for '([^']+)'.*$:\1:" > %t/A.key - -// == Build tu, importing A (implicitly importing B) - -// RUN: echo -n '-fmodule-file-cache-key %t/A.pcm ' > %t/A.import.rsp -// RUN: cat %t/A.key >> %t/A.import.rsp - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: @%t/A.import.rsp -fmodule-file=A=%t/A.pcm \ -// RUN: -fsyntax-only %t/tu.c \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/tu.out.txt -// RUN: cat %t/tu.out.txt | FileCheck %s --check-prefix=CACHE-MISS - -// == Ensure we're reading pcm from cache - -// RUN: rm %t/*.pcm - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: @%t/A.import.rsp -fmodule-file=A=%t/A.pcm \ -// RUN: -fsyntax-only %t/tu.c \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/tu.out.2.txt -// RUN: cat %t/tu.out.2.txt | FileCheck %s --check-prefix=CACHE-HIT - -// CACHE-HIT: remark: compile job cache hit -// CACHE-MISS: remark: compile job cache miss - -//--- module.modulemap -module A { header "A.h" export * } -module B { header "B.h" } - -//--- A.h -#include "B.h" - -//--- B.h -void B(void); - -//--- tu.c -#include "A.h" -void tu(void) { - B(); -} diff --git a/clang/test/CAS/fmodule-file-cache-key-with-pch.c b/clang/test/CAS/fmodule-file-cache-key-with-pch.c deleted file mode 100644 index f1ef288a46cbf..0000000000000 --- a/clang/test/CAS/fmodule-file-cache-key-with-pch.c +++ /dev/null @@ -1,117 +0,0 @@ -// Check that -fmodule-file-cache-key works with mixed PCH+modules builds. -// This test mimics the way the dep scanner handles PCH (ie. treat it as a file -// input, ingested into the cas fs). - -// REQUIRES: ondisk_cas - -// RUN: rm -rf %t %t.cas -// RUN: split-file %s %t - -// RUN: llvm-cas --cas %t.cas --ingest %t > %t/casid - -// == Build B - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fmodule-name=B -fno-implicit-modules \ -// RUN: -fmodule-related-to-pch \ -// RUN: -emit-module %t/module.modulemap -o %t/B.pcm \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/B.out.txt -// RUN: cat %t/B.out.txt | FileCheck %s --check-prefix=CACHE-MISS -// RUN: cat %t/B.out.txt | sed -E "s:^.*cache [a-z]+ for '([^']+)'.*$:\1:" > %t/B.key - -// == Build A, importing B - -// RUN: echo -n '-fmodule-file-cache-key %t/B.pcm ' > %t/B.import.rsp -// RUN: cat %t/B.key >> %t/B.import.rsp - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fmodule-name=A -fno-implicit-modules \ -// RUN: -fmodule-related-to-pch \ -// RUN: @%t/B.import.rsp -fmodule-file=%t/B.pcm \ -// RUN: -emit-module %t/module.modulemap -o %t/A.pcm \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/A.out.txt -// RUN: cat %t/A.out.txt | FileCheck %s --check-prefix=CACHE-MISS -// RUN: cat %t/A.out.txt | sed -E "s:^.*cache [a-z]+ for '([^']+)'.*$:\1:" > %t/A.key - -// == Build C, importing B - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fmodule-name=C -fno-implicit-modules \ -// RUN: -fmodule-related-to-pch \ -// RUN: @%t/B.import.rsp -fmodule-file=%t/B.pcm \ -// RUN: -emit-module %t/module.modulemap -o %t/C.pcm \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/C.out.txt -// RUN: cat %t/C.out.txt | FileCheck %s --check-prefix=CACHE-MISS -// RUN: cat %t/C.out.txt | sed -E "s:^.*cache [a-z]+ for '([^']+)'.*$:\1:" > %t/C.key - -// == Build PCH, importing A (implicitly importing B) - -// RUN: echo -n '-fmodule-file-cache-key %t/A.pcm ' > %t/A.import.rsp -// RUN: cat %t/A.key >> %t/A.import.rsp - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: @%t/A.import.rsp -fmodule-file=%t/A.pcm \ -// RUN: -emit-pch -x c-header %t/prefix.h -o %t/prefix.pch \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/prefix.out.txt -// RUN: cat %t/prefix.out.txt | FileCheck %s --check-prefix=CACHE-MISS - -// == Clear pcms to ensure they load from cache, and re-ingest with pch - -// RUN: rm %t/*.pcm -// RUN: llvm-cas --cas %t.cas --ingest %t > %t/casid -// RUN: rm %t/*.pch - -// == Build tu - -// RUN: echo -n '-fmodule-file-cache-key %t/C.pcm ' > %t/C.import.rsp -// RUN: cat %t/C.key >> %t/C.import.rsp - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: @%t/C.import.rsp -fmodule-file=%t/C.pcm -include-pch %t/prefix.pch \ -// RUN: -fsyntax-only %t/tu.c \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/tu.out.txt -// RUN: cat %t/tu.out.txt | FileCheck %s --check-prefix=CACHE-MISS - -// == Ensure we're reading pcm from cache - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: @%t/C.import.rsp -fmodule-file=%t/C.pcm -include-pch %t/prefix.pch \ -// RUN: -fsyntax-only %t/tu.c \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/tu.out.2.txt -// RUN: cat %t/tu.out.2.txt | FileCheck %s --check-prefix=CACHE-HIT - -// CACHE-HIT: remark: compile job cache hit -// CACHE-MISS: remark: compile job cache miss - -//--- module.modulemap -module A { header "A.h" export * } -module B { header "B.h" } -module C { header "C.h" export * } - -//--- A.h -#include "B.h" - -//--- B.h -void B(void); - -//--- C.h -#include "B.h" -void B(void); - -//--- prefix.h -#include "A.h" - -//--- tu.c -#include "C.h" -void tu(void) { - B(); -} diff --git a/clang/test/CAS/fmodule-file-cache-key.c b/clang/test/CAS/fmodule-file-cache-key.c deleted file mode 100644 index b44b40184ee00..0000000000000 --- a/clang/test/CAS/fmodule-file-cache-key.c +++ /dev/null @@ -1,77 +0,0 @@ -// Tests for providing the contents of pcm files via -fmodule-file-cache-key and -// previously cached module compilations. - -// REQUIRES: ondisk_cas - -// RUN: rm -rf %t %t.cas -// RUN: split-file %s %t - -// RUN: llvm-cas --cas %t.cas --ingest %t > %t/casid - -// == Build B - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fmodule-name=B -fno-implicit-modules \ -// RUN: -emit-module %t/module.modulemap -o %t/B.pcm \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/B.out.txt -// RUN: cat %t/B.out.txt | FileCheck %s --check-prefix=CACHE-MISS -// RUN: cat %t/B.out.txt | sed -E "s:^.*cache [a-z]+ for '([^']+)'.*$:\1:" > %t/B.key - -// == Build A, importing B - -// RUN: echo -n '-fmodule-file-cache-key %t/B.pcm ' > %t/B.import.rsp -// RUN: cat %t/B.key >> %t/B.import.rsp - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fmodule-name=A -fno-implicit-modules \ -// RUN: @%t/B.import.rsp -fmodule-file=%t/B.pcm \ -// RUN: -emit-module %t/module.modulemap -o %t/A.pcm \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/A.out.txt -// RUN: cat %t/A.out.txt | FileCheck %s --check-prefix=CACHE-MISS -// RUN: cat %t/A.out.txt | sed -E "s:^.*cache [a-z]+ for '([^']+)'.*$:\1:" > %t/A.key - -// == Build tu, importing A (implicitly importing B) - -// RUN: echo -n '-fmodule-file-cache-key %t/A.pcm ' > %t/A.import.rsp -// RUN: cat %t/A.key >> %t/A.import.rsp - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: @%t/A.import.rsp -fmodule-file=%t/A.pcm\ -// RUN: -fsyntax-only %t/tu.c \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/tu.out.txt -// RUN: cat %t/tu.out.txt | FileCheck %s --check-prefix=CACHE-MISS - -// == Ensure we're reading pcm from cache - -// RUN: rm %t/*.pcm - -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fno-implicit-modules \ -// RUN: @%t/A.import.rsp -fmodule-file=%t/A.pcm\ -// RUN: -fsyntax-only %t/tu.c \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/tu.out.2.txt -// RUN: cat %t/tu.out.2.txt | FileCheck %s --check-prefix=CACHE-HIT - -// CACHE-HIT: remark: compile job cache hit -// CACHE-MISS: remark: compile job cache miss - -//--- module.modulemap -module A { header "A.h" export * } -module B { header "B.h" } - -//--- A.h -#include "B.h" - -//--- B.h -void B(void); - -//--- tu.c -#include "A.h" -void tu(void) { - B(); -} diff --git a/clang/test/CAS/include-tree-with-include-next.c b/clang/test/CAS/include-tree-with-include-next.c index 333571302e20f..308febdc7c235 100644 --- a/clang/test/CAS/include-tree-with-include-next.c +++ b/clang/test/CAS/include-tree-with-include-next.c @@ -4,7 +4,7 @@ // Normal compilation for baseline. // RUN: %clang_cc1 %t/t.c -I %t/inc -I %t/inc2 -fsyntax-only -Werror -// RUN: %clang -cc1depscan -o %t/tu.rsp -fdepscan=inline -fdepscan-include-tree -cc1-args \ +// RUN: %clang -cc1depscan -o %t/tu.rsp -fdepscan=inline -cc1-args \ // RUN: -cc1 -fsyntax-only -Werror -fcas-path %t/cas %t/t.c -I %t/inc -I %t/inc2 -Werror // RUN: %clang @%t/tu.rsp diff --git a/clang/test/CAS/indexing.c b/clang/test/CAS/indexing.c index 2e74a521b1cb2..fa696362e0bb4 100644 --- a/clang/test/CAS/indexing.c +++ b/clang/test/CAS/indexing.c @@ -3,7 +3,7 @@ // RUN: rm -rf %t && mkdir %t -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t/t.rsp -cc1-args \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t/t.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macos12 -fcas-path %t/cas -emit-obj %s -o %t/t.o // RUN: %clang @%t/t.rsp -Rcompile-job-cache -index-store-path %t/idx -index-unit-output-path t.o 2>&1 \ diff --git a/clang/test/CAS/libclang-prune-data.c b/clang/test/CAS/libclang-prune-data.c index 1a2fad431393a..6de5e22b250a1 100644 --- a/clang/test/CAS/libclang-prune-data.c +++ b/clang/test/CAS/libclang-prune-data.c @@ -5,7 +5,7 @@ // RUN: rm -rf %t && mkdir -p %t -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t/t.rsp -cc1-args \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t/t.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macos12 -fcas-path %t/cas -emit-obj %s -o %t/output.o // RUN: %clang @%t/t.rsp // RUN: ls %t/cas | wc -l | grep 2 @@ -35,7 +35,7 @@ // RUN: rm -rf %t/cas -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t/t.rsp -cc1-args \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t/t.rsp -cc1-args \ // RUN: -cc1 -triple x86_64-apple-macos12 -fcas-path %t/cas -emit-obj %s -o %t/output.o \ // RUN: -fcas-plugin-path %llvmshlibdir/libCASPluginTest%pluginext // RUN: %clang @%t/t.rsp diff --git a/clang/test/CAS/output-path-create-directories.c b/clang/test/CAS/output-path-create-directories.c index d4b5ae1125c9c..74efcc2ff29f2 100644 --- a/clang/test/CAS/output-path-create-directories.c +++ b/clang/test/CAS/output-path-create-directories.c @@ -1,30 +1,31 @@ // RUN: rm -rf %t %t.cas // RUN: split-file %s %t -// RUN: llvm-cas --cas %t.cas --ingest %t > %t/casid + +// TODO: Figure out why this fails to create the .i and .dia files. +// XFAIL: * // RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fmodule-name=Mod -fno-implicit-modules \ -// RUN: -emit-module %t/module.modulemap -o %t/out/B.pcm \ -// RUN: -serialize-diagnostic-file %t/out/B.dia +// RUN: -E %t/tu.c -o %t/out/tu.i \ +// RUN: -serialize-diagnostic-file %t/out/tu.dia // RUN: ls %t/out/B.pcm // RUN: ls %t/out/B.dia -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fmodule-name=Mod -fno-implicit-modules \ -// RUN: -emit-module %t/module.modulemap -o %t/out_miss/B.pcm \ -// RUN: -serialize-diagnostic-file %t/out_miss/B.dia \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/B.out.txt +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos11 \ +// RUN: -E %t/tu.c -o %t/out_miss/tu.i \ +// RUN: -serialize-diagnostic-file %t/out_miss/tu.dia \ +// RUN: -fcas-path %t.cas +// RUN: %clang @%t.rsp -fcache-compile-job -Rcompile-job-cache &> %t/B.out.txt // RUN: cat %t/B.out.txt | FileCheck %s -check-prefix=CACHE-MISS // RUN: ls %t/out_miss/B.pcm // RUN: ls %t/out_miss/B.dia -// RUN: %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fmodule-name=Mod -fno-implicit-modules \ -// RUN: -emit-module %t/module.modulemap -o %t/out_hit/B.pcm \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos11 \ +// RUN: -E %t/tu.c -o %t/out_hit/tu.i \ // RUN: -serialize-diagnostic-file %t/out_hit/B.dia \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/B.out.hit.txt +// RUN: -fcas-path %t.cas +// RUN: %clang @%t.rsp -fcache-compile-job -Rcompile-job-cache &> %t/B.out.hit.txt // RUN: cat %t/B.out.hit.txt | FileCheck %s -check-prefix=CACHE-HIT // RUN: ls %t/out_hit/B.pcm // RUN: ls %t/out_hit/B.dia @@ -32,7 +33,4 @@ // CACHE-HIT: remark: compile job cache hit // CACHE-MISS: remark: compile job cache miss -//--- module.modulemap -module Mod { header "Header.h" } - -//--- Header.h +//--- tu.c diff --git a/clang/test/CAS/output-path-error.c b/clang/test/CAS/output-path-error.c index a221f3bb29bf0..47606c06d6bf4 100644 --- a/clang/test/CAS/output-path-error.c +++ b/clang/test/CAS/output-path-error.c @@ -3,20 +3,17 @@ // REQUIRES: shell // RUN: rm -rf %t && mkdir -p %t -// RUN: llvm-cas --cas %t/cas --ingest %s > %t/casid -// RUN: %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas -fcas-fs @%t/casid -fcache-compile-job \ -// RUN: -Rcompile-job-cache -emit-obj %s -o %t/output.o 2>&1 \ -// RUN: | FileCheck %s --allow-empty --check-prefix=CACHE-MISS +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args \ +// RUN: -cc1 -triple x86_64-apple-macos11 \ +// RUN: -fcas-path %t/cas -fcache-compile-job \ +// RUN: -Rcompile-job-cache -emit-obj %s -o %t/output.o +// RUN: %clang @%t.rsp 2>&1 | FileCheck %s --allow-empty --check-prefix=CACHE-MISS // Remove only the CAS, but leave the ActionCache. // RUN: rm -rf %t/cas -// RUN: not %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas -fcas-fs @%t/casid -fcache-compile-job \ -// RUN: -Rcompile-job-cache -emit-obj %s -o %t/output.o &> %t/output.txt -// RUN: cat %t/output.txt | FileCheck %s --check-prefix=ERROR +// RUN: not %clang @%t.rsp 2>&1 | FileCheck %s --allow-empty --check-prefix=ERROR // CACHE-MISS: remark: compile job cache miss -// ERROR: fatal error: CAS filesystem cannot be initialized from root-id 'llvmcas://{{.*}}': cannot get reference to root FS +// ERROR: fatal error: CAS filesystem cannot be initialized from root-id 'llvmcas://{{.*}}': include-tree CASID does not exist diff --git a/clang/test/CAS/pgo-profile-with-pch.c b/clang/test/CAS/pgo-profile-with-pch.c index 7f098dd2c1ea3..2c3297a82e2d9 100644 --- a/clang/test/CAS/pgo-profile-with-pch.c +++ b/clang/test/CAS/pgo-profile-with-pch.c @@ -3,7 +3,7 @@ // Check that use of profile data for PCH is ignored // RUN: llvm-profdata merge -o %t.profdata %S/Inputs/pgo.profraw -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t-pch.rsp -cc1-args -cc1 -triple x86_64-apple-macosx12.0.0 -emit-pch -O3 -Rcompile-job-cache \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t-pch.rsp -cc1-args -cc1 -triple x86_64-apple-macosx12.0.0 -emit-pch -O3 -Rcompile-job-cache \ // RUN: -x c-header %s -o %t.h.pch -fcas-path %t.dir/cas -fprofile-instrument-use=llvm -fprofile-instrument-use-path=%t.profdata // RUN: %clang @%t-pch.rsp 2>&1 | FileCheck %s --check-prefix=CACHE-MISS // RUN: FileCheck %s -check-prefix=PCHPROF -input-file %t-pch.rsp @@ -13,14 +13,14 @@ // RUN: llvm-profdata merge -o %t.profdata %S/Inputs/pgo2.profraw // Use the modified profdata file for the main file along with the PCH. -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t.rsp -cc1-args -cc1 -triple x86_64-apple-macosx12.0.0 -emit-obj -O3 -Rcompile-job-cache \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args -cc1 -triple x86_64-apple-macosx12.0.0 -emit-obj -O3 -Rcompile-job-cache \ // RUN: -x c %s -o %t.o -fcas-path %t.dir/cas -fprofile-instrument-use=llvm -fprofile-instrument-use-path=%t.profdata -include-pch %t.h.pch // RUN: %clang @%t.rsp 2>&1 | FileCheck %s --check-prefix=CACHE-MISS // RUN: FileCheck %s -check-prefix=TUPROF -input-file %t.rsp // TUPROF: -fprofile-instrument-use-path // Check that the modified profdata is ignored when re-scanning for the PCH. -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t-pch2.rsp -cc1-args -cc1 -triple x86_64-apple-macosx12.0.0 -emit-pch -O3 -Rcompile-job-cache \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t-pch2.rsp -cc1-args -cc1 -triple x86_64-apple-macosx12.0.0 -emit-pch -O3 -Rcompile-job-cache \ // RUN: -x c-header %s -o %t.h.pch -fcas-path %t.dir/cas -fprofile-instrument-use=llvm -fprofile-instrument-use-path=%t.profdata // RUN: diff -u %t-pch.rsp %t-pch2.rsp diff --git a/clang/test/CAS/pgo-profile.c b/clang/test/CAS/pgo-profile.c index a474754d69726..846a839de7ace 100644 --- a/clang/test/CAS/pgo-profile.c +++ b/clang/test/CAS/pgo-profile.c @@ -2,17 +2,7 @@ /// Check use pgo profile. // RUN: llvm-profdata merge -o %t.profdata %S/Inputs/pgo.profraw -// RUN: %clang -cc1depscan -fdepscan=inline -o %t.rsp -cc1-args -cc1 -triple x86_64-apple-macosx12.0.0 -emit-obj -O3 -Rcompile-job-cache \ -// RUN: -x c %s -o %t.o -fcas-path %t.dir/cas -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata - -/// Remove profile data to make sure the cc1 command is not reading from file system. -// RUN: rm %t.profdata -// RUN: %clang @%t.rsp 2>&1 | FileCheck %s --check-prefix=CACHE-MISS -// RUN: %clang @%t.rsp 2>&1 | FileCheck %s --check-prefix=CACHE-HIT - -/// Check include tree. -// RUN: llvm-profdata merge -o %t.profdata %S/Inputs/pgo.profraw -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t1.rsp -cc1-args -cc1 -triple x86_64-apple-macosx12.0.0 -emit-obj -O3 -Rcompile-job-cache \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t1.rsp -cc1-args -cc1 -triple x86_64-apple-macosx12.0.0 -emit-obj -O3 -Rcompile-job-cache \ // RUN: -x c %s -o %t.o -fcas-path %t.dir/cas -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata // RUN: rm %t.profdata // RUN: %clang @%t1.rsp 2>&1 | FileCheck %s --check-prefix=CACHE-MISS @@ -25,11 +15,6 @@ // RUN: not diff %t.rsp %t2.rsp // RUN: %clang @%t2.rsp 2>&1 | FileCheck %s --check-prefix=CACHE-MISS -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t3.rsp -cc1-args -cc1 -triple x86_64-apple-macosx12.0.0 -emit-obj -O3 -Rcompile-job-cache \ -// RUN: -x c %s -o %t.o -fcas-path %t.dir/cas -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata -// RUN: not diff %t1.rsp %t3.rsp -// RUN: %clang @%t3.rsp 2>&1 | FileCheck %s --check-prefix=CACHE-MISS - // CACHE-MISS: remark: compile job cache miss // CACHE-HIT: remark: compile job cache hit @@ -46,29 +31,12 @@ // RUN: %clang @%t5.rsp 2>&1 | FileCheck %s --check-prefix=CACHE-HIT // RUN: cat %t4.rsp | sed \ -// RUN: -e "s/^.*\"-fcas-fs\" \"//" \ +// RUN: -e "s/^.*\"-fcas-include-tree\" \"//" \ // RUN: -e "s/\" .*$//" > %t.dir/cache-key1 // RUN: cat %t5.rsp | sed \ -// RUN: -e "s/^.*\"-fcas-fs\" \"//" \ +// RUN: -e "s/^.*\"-fcas-include-tree\" \"//" \ // RUN: -e "s/\" .*$//" > %t.dir/cache-key2 // RUN: grep llvmcas %t.dir/cache-key1 // RUN: diff -u %t.dir/cache-key1 %t.dir/cache-key2 -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t4.inc.rsp -cc1-args -cc1 -triple x86_64-apple-macosx12.0.0 -emit-obj -O3 -Rcompile-job-cache -fdepscan-prefix-map %t.dir/a /^testdir \ -// RUN: -x c %s -o %t.o -fcas-path %t.dir/cas -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.dir/a/a.profdata -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t5.inc.rsp -cc1-args -cc1 -triple x86_64-apple-macosx12.0.0 -emit-obj -O3 -Rcompile-job-cache -fdepscan-prefix-map %t.dir/b /^testdir \ -// RUN: -x c %s -o %t.o -fcas-path %t.dir/cas -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.dir/b/a.profdata -// RUN: cat %t4.inc.rsp | FileCheck %s --check-prefix=REMAP -// RUN: %clang @%t4.inc.rsp 2>&1 | FileCheck %s --check-prefix=CACHE-MISS -// RUN: %clang @%t5.inc.rsp 2>&1 | FileCheck %s --check-prefix=CACHE-HIT - -// RUN: cat %t4.inc.rsp | sed \ -// RUN: -e "s/^.*\"-fcas-include-tree\" \"//" \ -// RUN: -e "s/\" .*$//" > %t.dir/inc-cache-key1 -// RUN: cat %t5.inc.rsp | sed \ -// RUN: -e "s/^.*\"-fcas-include-tree\" \"//" \ -// RUN: -e "s/\" .*$//" > %t.dir/inc-cache-key2 -// RUN: grep llvmcas %t.dir/inc-cache-key1 -// RUN: diff -u %t.dir/inc-cache-key1 %t.dir/inc-cache-key2 - // REMAP: -fprofile-instrument-use-path=/^testdir/a.profdata diff --git a/clang/test/CAS/print-compile-job-cache-key.c b/clang/test/CAS/print-compile-job-cache-key.c index 2532ad5606589..aeb2fafccc5cd 100644 --- a/clang/test/CAS/print-compile-job-cache-key.c +++ b/clang/test/CAS/print-compile-job-cache-key.c @@ -1,42 +1,8 @@ // REQUIRES: shell // RUN: rm -rf %t && mkdir -p %t -// RUN: llvm-cas --cas %t/cas --ingest %s > %t/casid -// -// RUN: %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas -fcas-fs @%t/casid -fcache-compile-job \ -// RUN: -Rcompile-job-cache-miss -emit-obj -o %t/output.o %s 2> %t/output.txt -// -// RUN: cat %t/output.txt | sed \ -// RUN: -e "s/^.*miss for '//" \ -// RUN: -e "s/' .*$//" > %t/cache-key -// -// RUN: not clang-cas-test -print-compile-job-cache-key -cas %t/cas 2>&1 | FileCheck %s -check-prefix=NO_KEY -// NO_KEY: missing compile-job cache key -// -// RUN: not clang-cas-test -print-compile-job-cache-key -cas %t/cas asdf 2>&1 | FileCheck %s -check-prefix=INVALID_KEY -// INVALID_KEY: invalid cas-id 'asdf' -// -// RUN: not clang-cas-test -print-compile-job-cache-key -cas %t/cas @%t/casid 2>&1 | FileCheck %s -check-prefix=NOT_A_KEY -// NOT_A_KEY: not a valid cache key -// -// RUN: clang-cas-test -print-compile-job-cache-key -cas %t/cas @%t/cache-key | FileCheck %s -// -// CHECK: command-line: llvmcas:// -// CHECK: -cc1 -// CHECK: -fcas-path llvm.cas.builtin.v2[BLAKE3] -// CHECK: -fcas-fs llvmcas:// -// CHECK: -x c {{.*}}print-compile-job-cache-key.c -// CHECK: computation: llvmcas:// -// CHECK: -cc1 -// CHECK: filesystem: llvmcas:// -// CHECK: file llvmcas:// -// CHECK: version: llvmcas:// -// CHECK: clang version - -// Print a key containing an include-tree. -// RUN: %clang -cc1depscan -fdepscan=inline -fdepscan-include-tree -o %t/inc.rsp -cc1-args -cc1 -triple x86_64-apple-macos11 -emit-obj \ +// RUN: %clang -cc1depscan -fdepscan=inline -o %t/inc.rsp -cc1-args -cc1 -triple x86_64-apple-macos11 -emit-obj \ // RUN: %s -o %t/output.o -fcas-path %t/cas // RUN: %clang @%t/inc.rsp -Rcompile-job-cache 2> %t/output-tree.txt @@ -60,13 +26,11 @@ // RUN: clang-cas-test -print-include-tree -cas %t/cas @%t/include-tree-id | FileCheck %s -check-prefix=INCLUDE_TREE -DSRC_FILE=%s // Print key from plugin CAS. -// RUN: llvm-cas --cas plugin://%llvmshlibdir/libCASPluginTest%pluginext?ondisk-path=%t/cas-plugin --ingest %s > %t/casid-plugin -// RUN: %clang -cc1 -triple x86_64-apple-macos11 \ -// RUN: -fcas-path %t/cas-plugin -fcas-fs @%t/casid-plugin -fcache-compile-job \ -// RUN: -fcas-plugin-path %llvmshlibdir/libCASPluginTest%pluginext \ -// RUN: -Rcompile-job-cache-miss -emit-obj -o %t/output.o %s 2> %t/output-plugin.txt +// RUN: %clang -cc1depscan -fdepscan=inline -o %t/inc-plugin.rsp -cc1-args -cc1 -triple x86_64-apple-macos11 -emit-obj \ +// RUN: %s -o %t/output-plugin.o -fcas-path %t/cas-plugin -fcas-plugin-path %llvmshlibdir/libCASPluginTest%pluginext +// RUN: %clang @%t/inc-plugin.rsp -Rcompile-job-cache-miss 2> %t/output-plugin.txt // RUN: cat %t/output-plugin.txt | sed \ // RUN: -e "s/^.*miss for '//" \ // RUN: -e "s/' .*$//" > %t/cache-key-plugin // RUN: clang-cas-test -print-compile-job-cache-key -cas %t/cas-plugin @%t/cache-key-plugin \ -// RUN: -fcas-plugin-path %llvmshlibdir/libCASPluginTest%pluginext | FileCheck %s +// RUN: -fcas-plugin-path %llvmshlibdir/libCASPluginTest%pluginext | FileCheck %s -check-prefix=INCLUDE_TREE_KEY -check-prefix=INCLUDE_TREE -DSRC_FILE=%s diff --git a/clang/test/CAS/test-for-deterministic-module.c b/clang/test/CAS/test-for-deterministic-module.c deleted file mode 100644 index 9c5f528d4f7b7..0000000000000 --- a/clang/test/CAS/test-for-deterministic-module.c +++ /dev/null @@ -1,27 +0,0 @@ -// REQUIRES: ondisk_cas - -// RUN: rm -rf %t %t.cas -// RUN: split-file %s %t -// RUN: llvm-cas --cas %t.cas --ingest %t > %t/casid -// -// RUN: not %clang_cc1 -triple x86_64-apple-macos11 \ -// RUN: -fmodules -fmodule-name=A -fno-implicit-modules \ -// RUN: -emit-module %t/module.modulemap -o %t/A.pcm \ -// RUN: -fcas-path %t.cas -fcas-fs @%t/casid \ -// RUN: -fcache-compile-job -Rcompile-job-cache &> %t/A.out.txt -// RUN: FileCheck %s --input-file=%t/A.out.txt - -// CHECK: remark: compile job cache miss -// CHECK: error: encountered non-reproducible token, caching failed -// CHECK: error: encountered non-reproducible token, caching failed -// CHECK: error: encountered non-reproducible token, caching failed - -//--- module.modulemap -module A { header "A.h" } - -//--- A.h -void getit(const char **p1, const char **p2, const char **p3) { - *p1 = __DATE__; - *p2 = __TIMESTAMP__; - *p3 = __TIME__; -} diff --git a/clang/test/ClangScanDeps/cas-case-sensitivity.c b/clang/test/ClangScanDeps/cas-case-sensitivity.c deleted file mode 100644 index d4d426478e3f4..0000000000000 --- a/clang/test/ClangScanDeps/cas-case-sensitivity.c +++ /dev/null @@ -1,58 +0,0 @@ -// REQUIRES: case_insensitive_build_dir,ondisk_cas - -// RUN: rm -rf %t -// RUN: split-file %s %t -// RUN: sed -e "s|DIR|%/t|g" %t/cdb1.json.template > %t/cdb1.json -// RUN: sed -e "s|DIR|%/t|g" %t/cdb2.json.template > %t/cdb2.json - -// RUN: clang-scan-deps -compilation-database %t/cdb1.json -cas-path %t/cas -format experimental-tree -mode preprocess-dependency-directives > %t/result1.txt -// RUN: clang-scan-deps -compilation-database %t/cdb2.json -cas-path %t/cas -format experimental-tree -mode preprocess > %t/result2.txt -// RUN: sed -e 's/^.*llvmcas/llvmcas/' -e 's/ for.*$//' %t/result1.txt > %t/casid1 -// RUN: sed -e 's/^.*llvmcas/llvmcas/' -e 's/ for.*$//' %t/result2.txt > %t/casid2 - -// RUN: llvm-cas --cas %t/cas --ls-tree-recursive @%t/casid1 | FileCheck -check-prefix=TREE %s -DPREFIX=%{t-tree-/} -// RUN: llvm-cas --cas %t/cas --ls-tree-recursive @%t/casid2 | FileCheck -check-prefix=TREE %s -DPREFIX=%{t-tree-/} - -// asdf: FileCheck -check-prefix=TREE %s -input-file %t/result1.txt -DPREFIX=%/t - -// TREE: file llvmcas://{{.*}} [[PREFIX]]{{/|\\}}Header.h -// TREE: syml llvmcas://{{.*}} [[PREFIX]]{{/|\\}}header.h -> Header -// TREE: file llvmcas://{{.*}} [[PREFIX]]{{/|\\}}t{{[12]}}.c - -//--- cdb1.json.template -[ - { - "directory": "DIR", - "command": "clang -fsyntax-only DIR/t1.c", - "file": "DIR/t1.c" - } -] - -//--- cdb2.json.template -[ - { - "directory": "DIR", - "command": "clang -fsyntax-only DIR/t2.c", - "file": "DIR/t2.c" - } -] - -//--- t1.c -#include "header.h" -#include "Header.h" - -void bar1(void) { - foo(); -} - -//--- t2.c -#include "Header.h" -#include "header.h" - -void bar2(void) { - foo(); -} - -//--- Header.h -#pragma once -void foo(void); diff --git a/clang/test/ClangScanDeps/cas-clang-cl.c b/clang/test/ClangScanDeps/cas-clang-cl.c index b7e2ffae4603e..e53a7729054d5 100644 --- a/clang/test/ClangScanDeps/cas-clang-cl.c +++ b/clang/test/ClangScanDeps/cas-clang-cl.c @@ -3,12 +3,12 @@ // RUN: rm -rf %t // RUN: split-file %s %t -// RUN: %clang_cl -c /clang:-fdepscan=inline /clang:-fdepscan-include-tree -Xclang -fcas-path -Xclang %t/cas -Xclang -Rcompile-job-cache -- %t/test.c 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// RUN: %clang_cl -c /clang:-fdepscan=inline /clang:-fdepscan-include-tree -Xclang -fcas-path -Xclang %t/cas -Xclang -Rcompile-job-cache -- %t/test.c 2>&1 | FileCheck %s -check-prefix=CACHE-HIT +// RUN: %clang_cl -c /clang:-fdepscan=inline -Xclang -fcas-path -Xclang %t/cas -Xclang -Rcompile-job-cache -- %t/test.c 2>&1 | FileCheck %s -check-prefix=CACHE-MISS +// RUN: %clang_cl -c /clang:-fdepscan=inline -Xclang -fcas-path -Xclang %t/cas -Xclang -Rcompile-job-cache -- %t/test.c 2>&1 | FileCheck %s -check-prefix=CACHE-HIT // In debug mode -// RUN: %clang_cl -c /clang:-fdepscan=inline /clang:-fdepscan-include-tree -Xclang -fcas-path -Xclang %t/cas -Xclang -Rcompile-job-cache /Z7 -- %t/test.c 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// RUN: %clang_cl -c /clang:-fdepscan=inline /clang:-fdepscan-include-tree -Xclang -fcas-path -Xclang %t/cas -Xclang -Rcompile-job-cache /Z7 -- %t/test.c 2>&1 | FileCheck %s -check-prefix=CACHE-HIT +// RUN: %clang_cl -c /clang:-fdepscan=inline -Xclang -fcas-path -Xclang %t/cas -Xclang -Rcompile-job-cache /Z7 -- %t/test.c 2>&1 | FileCheck %s -check-prefix=CACHE-MISS +// RUN: %clang_cl -c /clang:-fdepscan=inline -Xclang -fcas-path -Xclang %t/cas -Xclang -Rcompile-job-cache /Z7 -- %t/test.c 2>&1 | FileCheck %s -check-prefix=CACHE-HIT // CACHE-HIT: remark: compile job cache hit // CACHE-MISS: remark: compile job cache miss diff --git a/clang/test/ClangScanDeps/cas-fs-multiple-commands.c b/clang/test/ClangScanDeps/cas-fs-multiple-commands.c deleted file mode 100644 index 40b7d8cf40bbb..0000000000000 --- a/clang/test/ClangScanDeps/cas-fs-multiple-commands.c +++ /dev/null @@ -1,270 +0,0 @@ -// Test scanning when the driver requires multiple jobs. E.g. with -save-temps -// there will be separate -E, -emit-llvm-bc, -S, and -cc1as jobs, which should -// each result in a "command" in the output. - -// REQUIRES: ondisk_cas - -// We use an x86_64-apple-darwin target to avoid host-dependent behaviour in -// the driver. Platforms without an integrated assembler have different commands -// REQUIRES: x86-registered-target - -// RUN: rm -rf %t -// RUN: split-file %s %t - -// RUN: mv %t/tu_define_foo_0.c %t/tu.c -// RUN: clang-scan-deps -format experimental-tree-full -cas-path %t/cas -module-files-dir %t/modules \ -// RUN: -- %clang -target x86_64-apple-darwin -c %t/tu.c -save-temps=obj -o %t/tu.o \ -// RUN: -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=%t/cache \ -// RUN: > %t/deps.0.json - -// RUN: cat %t/deps.0.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t - -// RUN: env CLANG_CACHE_USE_CASFS_DEPSCAN=1 c-index-test core -scan-deps -working-dir %t -cas-path %t/cas -output-dir %t/modules -- \ -// RUN: %clang -target x86_64-apple-darwin -c %t/tu.c -save-temps=obj -o %t/tu.o \ -// RUN: -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=%t/cache \ -// RUN: > %t/deps.txt - -// RUN: cat %t/deps.txt | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK-LIBCLANG - -// RUN: %deps-to-rsp %t/deps.0.json --module-name=Mod > %t/Mod.0.rsp -// RUN: %deps-to-rsp %t/deps.0.json --tu-index 0 --tu-cmd-index 0 > %t/tu-cpp.0.rsp -// RUN: %deps-to-rsp %t/deps.0.json --tu-index 0 --tu-cmd-index 1 > %t/tu-emit-ir.0.rsp -// RUN: %deps-to-rsp %t/deps.0.json --tu-index 0 --tu-cmd-index 2 > %t/tu-emit-asm.0.rsp -// RUN: %deps-to-rsp %t/deps.0.json --tu-index 0 --tu-cmd-index 3 > %t/tu-cc1as.0.rsp -// RUN: %clang @%t/Mod.0.rsp -Rcompile-job-cache 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// RUN: %clang @%t/tu-cpp.0.rsp -Rcompile-job-cache 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// RUN: %clang @%t/tu-emit-ir.0.rsp -Rcompile-job-cache 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// RUN: %clang @%t/tu-emit-asm.0.rsp -Rcompile-job-cache 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// RUN: %clang @%t/tu-cc1as.0.rsp -// RUN: mv %t/tu.i %t/tu.0.i -// RUN: mv %t/tu.bc %t/tu.0.bc -// RUN: mv %t/tu.s %t/tu.0.s -// RUN: mv %t/tu.o %t/tu.0.o - -// RUN: mv %t/tu_define_foo_1.c %t/tu.c -// RUN: clang-scan-deps -format experimental-tree-full -cas-path %t/cas -module-files-dir %t/modules \ -// RUN: -- %clang -target x86_64-apple-darwin -c %t/tu.c -save-temps=obj -o %t/tu.o \ -// RUN: -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=%t/cache \ -// RUN: > %t/deps.1.json - -// The dependency graph has identical structure, just the FS root ID and dependent cache keys are different. -// RUN: cat %t/deps.1.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -// RUN: not diff %t/deps.1.json %t/deps.0.json - -// RUN: %deps-to-rsp %t/deps.1.json --module-name=Mod > %t/Mod.1.rsp -// RUN: %deps-to-rsp %t/deps.1.json --tu-index 0 --tu-cmd-index 0 > %t/tu-cpp.1.rsp -// RUN: %deps-to-rsp %t/deps.1.json --tu-index 0 --tu-cmd-index 1 > %t/tu-emit-ir.1.rsp -// RUN: %deps-to-rsp %t/deps.1.json --tu-index 0 --tu-cmd-index 2 > %t/tu-emit-asm.1.rsp -// RUN: %deps-to-rsp %t/deps.1.json --tu-index 0 --tu-cmd-index 3 > %t/tu-cc1as.1.rsp -// RUN: %clang @%t/Mod.1.rsp -Rcompile-job-cache 2>&1 | FileCheck %s -check-prefix=CACHE-HIT -// RUN: %clang @%t/tu-cpp.1.rsp -Rcompile-job-cache 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// RUN: %clang @%t/tu-emit-ir.1.rsp -Rcompile-job-cache 2>&1 | FileCheck %s -check-prefix=CACHE-HIT -// RUN: %clang @%t/tu-emit-asm.1.rsp -Rcompile-job-cache 2>&1 | FileCheck %s -check-prefix=CACHE-HIT -// RUN: %clang @%t/tu-cc1as.1.rsp -// RUN: mv %t/tu.i %t/tu.1.i -// RUN: mv %t/tu.bc %t/tu.1.bc -// RUN: mv %t/tu.s %t/tu.1.s -// RUN: mv %t/tu.o %t/tu.1.o - -// RUN: diff %t/tu.1.i %t/tu.0.i -// RUN: diff %t/tu.1.bc %t/tu.0.bc -// RUN: diff %t/tu.1.s %t/tu.0.s -// RUN: diff %t/tu.1.o %t/tu.0.o - -// CACHE-HIT: remark: compile job cache hit -// CACHE-MISS: remark: compile job cache miss - -// CHECK: "modules": [ -// CHECK-NEXT: { -// CHECK-NEXT: "cache-key": "[[M_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// CHECK-NEXT: "casfs-root-id": "[[M_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK-NEXT: "clang-module-deps": [] -// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap" -// CHECK-NEXT: "command-line": [ -// CHECK: "-fcas-fs" -// CHECK-NEXT: "[[M_ROOT_ID]]" -// CHECK: ] -// CHECK: "name": "Mod" -// CHECK-NEXT: } -// CHECK-NEXT: ] -// CHECK-NEXT: "translation-units": [ -// CHECK-NEXT: { -// CHECK: "commands": [ -// CHECK-NEXT: { -// CHECK-NEXT: "cache-key": "[[CPP_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// CHECK-NEXT: "casfs-root-id": "[[CPP_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK-NEXT: "clang-context-hash": "{{.*}}" -// CHECK-NEXT: "clang-module-deps": [ -// CHECK-NEXT: { -// CHECK-NEXT: "context-hash": "{{.*}} -// CHECK-NEXT: "module-name": "Mod" -// CHECK-NEXT: } -// CHECK-NEXT: ] -// CHECK-NEXT: "command-line": [ -// CHECK-NEXT: "-cc1" -// CHECK: "-fcas-fs" -// CHECK-NEXT: "[[CPP_ROOT_ID]]" -// CHECK: "-o" -// CHECK-NEXT: "[[PREFIX]]/tu.i" -// CHECK-NOT: "-fcas-input-file-cache-key" -// CHECK: "-E" -// CHECK: "-fmodule-file-cache-key" -// CHECK-NEXT: "Mod-{{.*}}.pcm" -// CHECK-NEXT: "[[M_CACHE_KEY]]" -// CHECK: "-x" -// CHECK-NEXT: "c" -// CHECK: "[[PREFIX]]/tu.c" -// CHECK: "-fmodule-file=Mod=Mod-{{.*}}.pcm" -// CHECK: ] -// CHECK: "file-deps": [ -// CHECK-NEXT: "[[PREFIX]]/tu.c" -// CHECK-NEXT: ] -// CHECK: "input-file": "[[PREFIX]]/tu.c" -// CHECK-NEXT: } -// CHECK-NEXT: { -// CHECK-NEXT: "cache-key": "[[COMPILER_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// CHECK-NEXT: "casfs-root-id": "{{.*}}" -// CHECK-NEXT: "clang-context-hash": "{{.*}}" -// CHECK-NEXT: "clang-module-deps": [ -// CHECK-NEXT: { -// CHECK-NEXT: "context-hash": "{{.*}} -// CHECK-NEXT: "module-name": "Mod" -// CHECK-NEXT: } -// CHECK-NEXT: ] -// CHECK-NEXT: "command-line": [ -// CHECK-NEXT: "-cc1" -// CHECK: "-o" -// CHECK-NEXT: "[[PREFIX]]/tu.bc" -// CHECK: "-fcas-input-file-cache-key" -// CHECK-NEXT: "[[CPP_CACHE_KEY]]" -// CHECK: "-emit-llvm-bc" -// CHECK: "-fmodule-file-cache-key" -// CHECK-NEXT: "Mod-{{.*}}.pcm" -// CHECK-NEXT: "[[M_CACHE_KEY]]" -// CHECK: "-x" -// CHECK-NEXT: "c-cpp-output" -// CHECK-NOT: "{{.*}}tu.i" -// CHECK: "-fmodule-file=Mod=Mod-{{.*}}.pcm" -// CHECK: ] -// CHECK: "input-file": "[[PREFIX]]{{.}}tu.c" -// CHECK-NEXT: } -// CHECK-NEXT: { -// CHECK-NEXT: "cache-key": "[[BACKEND_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// CHECK-NEXT: "casfs-root-id": "{{.*}}" -// CHECK-NEXT: "clang-context-hash": "{{.*}}" -// FIXME: This should be empty. -// CHECK-NEXT: "clang-module-deps": [ -// CHECK-NEXT: { -// CHECK-NEXT: "context-hash": "{{.*}} -// CHECK-NEXT: "module-name": "Mod" -// CHECK-NEXT: } -// CHECK-NEXT: ] -// CHECK-NEXT: "command-line": [ -// CHECK-NEXT: "-cc1" -// CHECK: "-o" -// CHECK-NEXT: "[[PREFIX]]/tu.s" -// CHECK: "-fcas-input-file-cache-key" -// CHECK-NEXT: "[[COMPILER_CACHE_KEY]]" -// CHECK: "-S" -// CHECK: "-x" -// CHECK-NEXT: "ir" -// CHECK: ] -// CHECK: "input-file": "[[PREFIX]]{{.}}tu.c" -// CHECK-NEXT: } -// CHECK-NEXT: { -// CHECK-NEXT: "casfs-root-id": "{{.*}}" -// CHECK-NEXT: "clang-context-hash": "{{.*}}" -// FIXME: This should be empty. -// CHECK-NEXT: "clang-module-deps": [ -// CHECK-NEXT: { -// CHECK: "module-name": "Mod" -// CHECK-NEXT: } -// CHECK-NEXT: ] -// CHECK-NEXT: "command-line": [ -// CHECK-NEXT: "-cc1as" -// CHECK: "-o" -// CHECK-NEXT: "[[PREFIX]]/tu.o" -// FIXME: The integrated assembler should support caching too. -// CHECK: "[[PREFIX]]/tu.s" -// CHECK: ] -// CHECK: "input-file": "[[PREFIX]]/tu.c" -// CHECK-NEXT: } -// CHECK-NEXT: ] -// CHECK-NEXT: } -// CHECK-NEXT: ] - -// CHECK-LIBCLANG: modules: -// CHECK-LIBCLANG-NEXT: module: -// CHECK-LIBCLANG-NEXT: name: Mod -// CHECK-LIBCLANG-NEXT: context-hash: {{.*}} -// CHECK-LIBCLANG-NEXT: cwd-ignored: 0 -// CHECK-LIBCLANG-NEXT: module-map-path: [[PREFIX]]/module.modulemap -// CHECK-LIBCLANG-NEXT: casfs-root-id: [[M_ROOT_ID:llvmcas://[[:xdigit:]]+]] -// CHECK-LIBCLANG-NEXT: cache-key: [[M_CACHE_KEY:llvmcas://[[:xdigit:]]+]] -// CHECK-LIBCLANG-NEXT: module-deps: -// CHECK-LIBCLANG-NEXT: file-deps: -// CHECK-LIBCLANG-NEXT: [[PREFIX]]/module.modulemap -// CHECK-LIBCLANG-NEXT: [[PREFIX]]/module.h -// CHECK-LIBCLANG-NEXT: build-args: -cc1 {{.*}} -fcas-fs [[M_ROOT_ID]] -// CHECK-LIBCLANG-NEXT: dependencies: -// CHECK-LIBCLANG-NEXT: command 0: -// CHECK-LIBCLANG-NEXT: context-hash: {{.*}} -// CHECK-LIBCLANG-NEXT: casfs-root-id: [[CPP_ROOT_ID:llvmcas://[[:xdigit:]]+]] -// CHECK-LIBCLANG-NEXT: cache-key: [[CPP_CACHE_KEY:llvmcas://[[:xdigit:]]+]] -// CHECK-LIBCLANG-NEXT: module-deps: -// CHECK-LIBCLANG-NEXT: Mod:{{.*}} -// CHECK-LIBCLANG-NEXT: file-deps: -// CHECK-LIBCLANG-NEXT: [[PREFIX]]/tu.c -// CHECK-LIBCLANG-NOT: -fcas-input-file-cache-key -// CHECK-LIBCLANG-NOT: {{.*}}tu.c -// CHECK-LIBCLANG-NEXT: build-args: -cc1 {{.*}} -o [[PREFIX]]/tu.i {{.*}} -E -fmodule-file-cache-key {{.*}} [[M_CACHE_KEY]] -x c {{.*}} -fmodule-file=Mod=Mod_{{.*}}.pcm -// CHECK-LIBCLANG-NEXT: command 1: -// CHECK-LIBCLANG-NEXT: context-hash: {{.*}} -// FIXME: This should be empty. -// CHECK-LIBCLANG-NEXT: casfs-root-id: {{.*}} -// CHECK-LIBCLANG-NEXT: cache-key: [[COMPILER_CACHE_KEY:llvmcas://[[:xdigit:]]+]] -// CHECK-LIBCLANG-NEXT: module-deps: -// CHECK-LIBCLANG-NEXT: Mod:{{.*}} -// CHECK-LIBCLANG-NEXT: file-deps: -// CHECK-LIBCLANG-NEXT: [[PREFIX]]/tu.c -// CHECK-LIBCLANG-NOT: -fcas-fs -// CHECK-LIBCLANG-NOT: {{.*}}tu.i -// CHECK-LIBCLANG-NEXT: build-args: -cc1 {{.*}} -o [[PREFIX]]/tu.bc {{.*}} -fcas-input-file-cache-key [[CPP_CACHE_KEY]] {{.*}} -emit-llvm-bc -fmodule-file-cache-key {{.*}} [[M_CACHE_KEY]] -x c-cpp-output {{.*}} -fmodule-file=Mod=Mod_{{.*}}.pcm -// CHECK-LIBCLANG-NEXT: command 2: -// CHECK-LIBCLANG-NEXT: context-hash: {{.*}} -// FIXME: This should be empty. -// CHECK-LIBCLANG-NEXT: casfs-root-id: {{.*}} -// CHECK-LIBCLANG-NEXT: cache-key: [[BACKEND_CACHE_KEY:llvmcas://[[:xdigit:]]+]] -// FIXME: This should be empty. -// CHECK-LIBCLANG-NEXT: module-deps: -// CHECK-LIBCLANG-NEXT: Mod:{{.*}} -// CHECK-LIBCLANG-NEXT: file-deps: -// CHECK-LIBCLANG-NEXT: [[PREFIX]]/tu.c -// CHECK-LIBCLANG-NEXT: build-args: -cc1 {{.*}} -o [[PREFIX]]/tu.s {{.*}} -fcas-input-file-cache-key [[COMPILER_CACHE_KEY]] {{.*}} -S -x ir -// CHECK-LIBCLANG-NEXT: command 3: -// CHECK-LIBCLANG-NEXT: context-hash: {{.*}} -// FIXME: This should be empty. -// CHECK-LIBCLANG-NEXT: casfs-root-id: {{.*}} -// FIXME: This should be empty. -// CHECK-LIBCLANG-NEXT: module-deps: -// CHECK-LIBCLANG-NEXT: Mod:{{.*}} -// CHECK-LIBCLANG-NEXT: file-deps: -// CHECK-LIBCLANG-NEXT: [[PREFIX]]/tu.c -// FIXME: The integrated assembler should support caching too. -// CHECK-LIBCLANG-NEXT: build-args: -cc1as {{.*}} -o [[PREFIX]]/tu.o [[PREFIX]]/tu.s - -//--- module.h -void bar(void); - -//--- module.modulemap -module Mod { header "module.h" } - -//--- tu_define_foo_0.c -#include "module.h" -#define FOO 0 -void tu_save_temps(void) { bar(); } - -//--- tu_define_foo_1.c -#include "module.h" -#define FOO 1 -void tu_save_temps(void) { bar(); } diff --git a/clang/test/ClangScanDeps/cas-fs-prefix-mapping.c b/clang/test/ClangScanDeps/cas-fs-prefix-mapping.c deleted file mode 100644 index 134032e050271..0000000000000 --- a/clang/test/ClangScanDeps/cas-fs-prefix-mapping.c +++ /dev/null @@ -1,97 +0,0 @@ -// Test path prefix-mapping when using a cas-fs with clang-scan-deps in -// tree, full-tree, and full dependencies modes. - -// REQUIRES: ondisk_cas -// RUN: rm -rf %t -// RUN: split-file %s %t -// RUN: sed -e "s|DIR|%/t|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/cdb.json - -// == Tree -// Ensure the filesystem has the mapped paths. - -// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-tree -cas-path %t/cas \ -// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \ -// RUN: | sed -E 's/tree ([^ ]+) for.*/\1/' > %t/tree_id.txt -// RUN: llvm-cas -cas %t/cas -ls-tree-recursive @%t/tree_id.txt > %t/tree_result.txt -// RUN: FileCheck %s -input-file %t/tree_result.txt -DROOT=%{/roott} -check-prefix=FILES - -// FILES: file llvmcas://{{.*}} [[ROOT]]^sdk/usr/include/stdlib.h -// FILES: file llvmcas://{{.*}} [[ROOT]]^src/t.c -// FILES: file llvmcas://{{.*}} [[ROOT]]^src/top.h -// FILES: file llvmcas://{{.*}} [[ROOT]]^tc/lib/clang/{{.*}}/include/stdarg.h - -// == Full Tree -// This should have the same filesystem as above, and we also check the command- -// line. - -// RUN: cat %t/tree_id.txt > %t/full_tree_result.txt -// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-tree-full -cas-path %t/cas \ -// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \ -// RUN: >> %t/full_tree_result.txt -// RUN: cat %t/full_tree_result.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize SDK_PREFIX=%/S/Inputs/SDK --sanitize ROOT^=%/root^ --enable-yaml-compatibility %s - -// == Full -// Same as full tree. - -// RUN: cat %t/tree_id.txt > %t/full_result.txt -// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -cas-path %t/cas \ -// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \ -// RUN: >> %t/full_result.txt -// RUN: cat %t/full_result.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize SDK_PREFIX=%/S/Inputs/SDK --sanitize ROOT^=%/root^ --enable-yaml-compatibility %s - -// CHECK: [[MAPPED_FS_ID:llvmcas://[[:xdigit:]]+]] -// CHECK: "modules": [] -// CHECK: "translation-units": [ -// CHECK: { -// CHECK: "commands": [ -// CHECK: { -// CHECK: "casfs-root-id": "[[MAPPED_FS_ID]]" -// CHECK: "clang-module-deps": [] -// CHECK: "command-line": [ -// CHECK: "-fcas-path" -// CHECK-NEXT: "PREFIX{{/|\\\\}}cas" -// CHECK: "-fcas-fs" -// CHECK-NEXT: "[[MAPPED_FS_ID]]" -// CHECK: "-fcas-fs-working-directory" -// CHECK-NEXT: "ROOT^src" -// CHECK: "-x" -// CHECK-NEXT: "c" -// CHECK-NEXT: "ROOT^src{{/|\\\\}}t.c" -// CHECK: "-isysroot" -// CHECK-NEXT: "ROOT^sdk" -// CHECK: "-resource-dir" -// CHECK-NEXT: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}" -// CHECK: "-isystem" -// CHECK-NEXT: "ROOT^sdk{{/|\\\\}}usr{{/|\\\\}}local{{/|\\\\}}include -// CHECK: "-isystem" -// CHECK-NEXT: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}{{/|\\\\}}include" -// CHECK: "-internal-externc-isystem" -// CHECK-NEXT: "ROOT^sdk{{/|\\\\}}usr{{/|\\\\}}include" -// CHECK: "-fdebug-compilation-dir=ROOT^src" -// CHECK: "-fcoverage-compilation-dir=ROOT^src" -// CHECK-NOT: PREFIX -// CHECK-NOT: SDK_PREFIX -// CHECK: ] -// CHECK: "file-deps": [ -// CHECK: "PREFIX{{/|\\\\}}t.c" -// CHECK: "PREFIX{{/|\\\\}}top.h" -// CHECK: "{{.*}}include{{/|\\\\}}stdarg.h" -// CHECK: "SDK_PREFIX{{/|\\\\}}usr{{/|\\\\}}include{{/|\\\\}}stdlib.h" -// CHECK: ] -// CHECK: "input-file": "PREFIX{{/|\\\\}}t.c" - -//--- cdb.json.template -[ - { - "directory": "DIR", - "command": "CLANG -fsyntax-only DIR/t.c -target x86_64-apple-macos11 -isysroot SDK", - "file": "DIR/t.c" - } -] - -//--- t.c -#include "top.h" - -//--- top.h -#include -#include diff --git a/clang/test/ClangScanDeps/cas-trees.c b/clang/test/ClangScanDeps/cas-trees.c deleted file mode 100644 index b49893623a670..0000000000000 --- a/clang/test/ClangScanDeps/cas-trees.c +++ /dev/null @@ -1,143 +0,0 @@ -// REQUIRES: ondisk_cas -// RUN: rm -rf %t -// RUN: split-file %s %t -// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json - -// RUN: clang-scan-deps -compilation-database %t/cdb.json -cas-path %t/cas -format experimental-tree -mode preprocess-dependency-directives > %t/result1.txt -// RUN: clang-scan-deps -compilation-database %t/cdb.json -cas-path %t/cas -format experimental-tree -mode preprocess > %t/result2.txt -// RUN: diff -u %t/result1.txt %t/result2.txt -// RUN: cat %t/result1.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t %s - -// CHECK: tree {{.*}} for 'PREFIX{{/|\\}}t1.c' -// CHECK-NEXT: tree {{.*}} for 'PREFIX{{/|\\}}t2.c' - -// RUN: clang-scan-deps -compilation-database %t/cdb.json -cas-path %t/cas -format experimental-tree-full -mode preprocess > %t/full_result.json -// RUN: cat %t/full_result.json | %PathSanitizingFileCheck --sanitize PREFIX=%/t --enable-yaml-compatibility %s --check-prefix=FULL-TREE - -// FULL-TREE: { -// FULL-TREE-NEXT: "modules": [], -// FULL-TREE-NEXT: "translation-units": [ -// FULL-TREE-NEXT: { -// FULL-TREE: "cache-key": "[[T1_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// FULL-TREE-NEXT: "casfs-root-id": "[[T1_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// FULL-TREE-NEXT: "clang-context-hash": "{{[A-Z0-9]+}}", -// FULL-TREE-NEXT: "clang-module-deps": [], -// FULL-TREE-NEXT: "command-line": [ -// FULL-TREE: "-fcas-path" -// FULL-TREE-NEXT: "PREFIX{{/|\\\\}}cas" -// FULL-TREE: "-fcas-fs" -// FULL-TREE-NEXT: "[[T1_ROOT_ID]]" -// FULL-TREE: "-fcache-compile-job" -// FULL-TREE: ], -// FULL-TREE: "file-deps": [ -// FULL-TREE-NEXT: "PREFIX{{/|\\\\}}t1.c", -// FULL-TREE-NEXT: "PREFIX{{/|\\\\}}top.h", -// FULL-TREE-NEXT: "PREFIX{{/|\\\\}}n1.h" -// FULL-TREE-NEXT: ], -// FULL-TREE-NEXT: "input-file": "PREFIX{{/|\\\\}}t1.c" -// FULL-TREE-NEXT: } -// FULL-TREE: { -// FULL-TREE: "cache-key": "[[T2_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// FULL-TREE-NEXT: "casfs-root-id": "[[T2_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// FULL-TREE-NEXT: "clang-context-hash": "{{[A-Z0-9]+}}", -// FULL-TREE-NEXT: "clang-module-deps": [], -// FULL-TREE-NEXT: "command-line": [ -// FULL-TREE: "-fcas-path" -// FULL-TREE-NEXT: "PREFIX{{/|\\\\}}cas" -// FULL-TREE: "-fcas-fs" -// FULL-TREE-NEXT: "[[T2_ROOT_ID]]" -// FULL-TREE: "-fcache-compile-job" -// FULL-TREE: ], -// FULL-TREE: "file-deps": [ -// FULL-TREE-NEXT: "PREFIX{{/|\\\\}}t2.c", -// FULL-TREE-NEXT: "PREFIX{{/|\\\\}}n1.h" -// FULL-TREE-NEXT: ], -// FULL-TREE-NEXT: "input-file": "PREFIX{{/|\\\\}}t2.c" -// FULL-TREE-NEXT: } - -// Build with caching -// RUN: %deps-to-rsp %t/full_result.json --tu-index 0 > %t/t1.cc1.rsp -// RUN: %deps-to-rsp %t/full_result.json --tu-index 1 > %t/t2.cc1.rsp -// RUN: %clang @%t/t1.cc1.rsp -Rcompile-job-cache 2> %t/t1-miss.err -// RUN: FileCheck %s -input-file=%t/t1-miss.err -check-prefix=CACHE-MISS -// RUN: %clang @%t/t1.cc1.rsp -Rcompile-job-cache 2>&1 | FileCheck %s -check-prefix=CACHE-HIT -// RUN: %clang @%t/t2.cc1.rsp -Rcompile-job-cache 2> %t/t2-miss.err -// RUN: FileCheck %s -input-file=%t/t2-miss.err -check-prefix=CACHE-MISS -// RUN: %clang @%t/t2.cc1.rsp -Rcompile-job-cache 2>&1 | FileCheck %s -check-prefix=CACHE-HIT -// CACHE-HIT: remark: compile job cache hit -// CACHE-MISS: remark: compile job cache miss - -// Check cache keys. -// RUN: cp %t/full_result.json %t/combined.txt -// RUN: cat %t/t1-miss.err >> %t/combined.txt -// RUN: cat %t/t2-miss.err >> %t/combined.txt -// RUN: FileCheck %s -input-file=%t/combined.txt -check-prefix=COMBINED - -// COMBINED: "commands": [ -// COMBINED-NEXT: { -// COMBINED-NEXT: "cache-key": "[[T1_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// COMBINED: } -// COMBINED: "commands": [ -// COMBINED: { -// COMBINED-NEXT: "cache-key": "[[T2_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// COMBINED: remark: compile job cache miss for '[[T1_CACHE_KEY]]' -// COMBINED-NEXT: remark: compile job cache miss for '[[T2_CACHE_KEY]]' - -// RUN: clang-scan-deps -compilation-database %t/cdb.json -cas-path %t/cas -format experimental-tree -emit-cas-compdb | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize CLANG=%/clang --enable-yaml-compatibility %s -check-prefix=COMPDB -// COMPDB: [ -// COMPDB: { -// COMPDB: "file": "PREFIX{{/|\\\\}}t1.c", -// COMPDB: "directory": "PREFIX", -// COMPDB: "arguments": [ -// COMPDB: "CLANG", -// COMPDB: "-cc1", -// COMPDB: "-fcas-path", -// COMPDB: "PREFIX{{/|\\\\}}cas", -// COMPDB: "-fcas-fs", -// COMPDB: { -// COMPDB: "file": "PREFIX{{/|\\\\}}t2.c", -// COMPDB: "directory": "PREFIX", -// COMPDB: "arguments": [ - - -//--- cdb.json.template -[ - { - "directory": "DIR", - "command": "clang -fsyntax-only DIR/t1.c", - "file": "DIR/t1.c" - }, - { - "directory": "DIR", - "command": "clang -fsyntax-only DIR/t2.c", - "file": "DIR/t2.c" - } -] - -//--- t1.c -#include "top.h" -#include "n1.h" - -//--- t2.c -#include "n1.h" - -//--- top.h -#ifndef _TOP_H_ -#define _TOP_H_ - -#define WHATEVER 1 -#include "n1.h" - -struct S { - int x; -}; - -#endif - -//--- n1.h -#ifndef _N1_H_ -#define _N1_H_ - -int x1; - -#endif diff --git a/clang/test/ClangScanDeps/include-tree-vfs-overlay.c b/clang/test/ClangScanDeps/include-tree-vfs-overlay.c index 35c4ca08a8486..63262bdb7e71e 100644 --- a/clang/test/ClangScanDeps/include-tree-vfs-overlay.c +++ b/clang/test/ClangScanDeps/include-tree-vfs-overlay.c @@ -6,7 +6,7 @@ // RUN: split-file %s %t // RUN: sed -e "s|DIR|%/t|g" %t/vfs-overlay.yaml.template > %t/vfs-overlay.yaml -// RUN: %clang -I%t -fdepscan=inline -fdepscan-include-tree -Xclang -fcas-path -Xclang %t/cas -Xclang -ivfsoverlay -Xclang %t/vfs-overlay.yaml -c %t/test.c +// RUN: %clang -I%t -fdepscan=inline -Xclang -fcas-path -Xclang %t/cas -Xclang -ivfsoverlay -Xclang %t/vfs-overlay.yaml -c %t/test.c //--- test.c #include "header.h" diff --git a/clang/test/ClangScanDeps/include-tree-with-pch.c b/clang/test/ClangScanDeps/include-tree-with-pch.c index f056a13ed4b8d..68652b85c559e 100644 --- a/clang/test/ClangScanDeps/include-tree-with-pch.c +++ b/clang/test/ClangScanDeps/include-tree-with-pch.c @@ -3,7 +3,7 @@ // RUN: split-file %s %t // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json -// RUN: %clang -x c-header %t/prefix.h -target x86_64-apple-macos12 -o %t/prefix.pch -fdepscan=inline -fdepscan-include-tree -Xclang -fcas-path -Xclang %t/cas +// RUN: %clang -x c-header %t/prefix.h -target x86_64-apple-macos12 -o %t/prefix.pch -fdepscan=inline -Xclang -fcas-path -Xclang %t/cas // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-include-tree -cas-path %t/cas > %t/result.txt // RUN: cat %t/result.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t %s diff --git a/clang/test/ClangScanDeps/modules-cas-fs-prefix-mapping-caching.c b/clang/test/ClangScanDeps/modules-cas-fs-prefix-mapping-caching.c deleted file mode 100644 index 064d9f0d20783..0000000000000 --- a/clang/test/ClangScanDeps/modules-cas-fs-prefix-mapping-caching.c +++ /dev/null @@ -1,73 +0,0 @@ -// Test that we get cache hits across directories with modules. - -// REQUIRES: ondisk_cas - -// RUN: rm -rf %t -// RUN: split-file %s %t -// RUN: cp -r %t/dir1 %t/dir2 -// RUN: sed -e "s|DIR|%/t/dir1|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/dir1/cdb.json -// RUN: sed -e "s|DIR|%/t/dir2|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/dir2/cdb.json - -// RUN: clang-scan-deps -compilation-database %t/dir1/cdb.json -format experimental-full \ -// RUN: -cas-path %t/cas -module-files-dir %t/dir1/modules \ -// RUN: -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \ -// RUN: -prefix-map=%t/dir1/modules=%/root^modules -prefix-map=%t/dir1=%/root^src -optimize-args=none \ -// RUN: > %t/dir1.txt - -// RUN: clang-scan-deps -compilation-database %t/dir2/cdb.json -format experimental-full \ -// RUN: -cas-path %t/cas -module-files-dir %t/dir2/modules \ -// RUN: -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \ -// RUN: -prefix-map=%t/dir2/modules=%/root^modules -prefix-map=%t/dir2=%/root^src -optimize-args=none \ -// RUN: > %t/dir2.txt - -// Extract individual commands. -// RUN: %deps-to-rsp %t/dir1.txt --module-name=B > %t/dir1/B.cc1.rsp -// RUN: %deps-to-rsp %t/dir1.txt --module-name=A > %t/dir1/A.cc1.rsp -// RUN: %deps-to-rsp %t/dir1.txt --tu-index 0 > %t/dir1/tu.cc1.rsp - -// RUN: %deps-to-rsp %t/dir2.txt --module-name=B > %t/dir2/B.cc1.rsp -// RUN: %deps-to-rsp %t/dir2.txt --module-name=A > %t/dir2/A.cc1.rsp -// RUN: %deps-to-rsp %t/dir2.txt --tu-index 0 > %t/dir2/tu.cc1.rsp - -// RUN: cd %t/dir1 && %clang @B.cc1.rsp > %t/miss-B.txt 2>&1 -// RUN: cat %t/miss-B.txt | FileCheck %s -check-prefix=CACHE-MISS -// RUN: cd %t/dir1 && %clang @A.cc1.rsp > %t/miss-A.txt 2>&1 -// RUN: cat %t/miss-A.txt | FileCheck %s -check-prefix=CACHE-MISS -// RUN: cd %t/dir1 && %clang @tu.cc1.rsp > %t/miss-tu.txt 2>&1 -// RUN: cat %t/miss-tu.txt | FileCheck %s -check-prefix=CACHE-MISS - -// CACHE-MISS: compile job cache miss - -// RUN: cd %t/dir2 && %clang @B.cc1.rsp > %t/hit-B.txt 2>&1 -// RUN: cat %t/hit-B.txt | FileCheck %s -check-prefix=CACHE-HIT -// RUN: cd %t/dir2 && %clang @A.cc1.rsp > %t/hit-A.txt 2>&1 -// RUN: cat %t/hit-B.txt | FileCheck %s -check-prefix=CACHE-HIT -// RUN: cd %t/dir2 && %clang @tu.cc1.rsp > %t/hit-tu.txt 2>&1 -// RUN: cat %t/hit-tu.txt | FileCheck %s -check-prefix=CACHE-HIT - -// CACHE-HIT: compile job cache hit - -// RUN: diff -r -u %t/dir1/modules %t/dir2/modules - -//--- cdb.json.template -[ - { - "directory": "DIR", - "command": "CLANG -fsyntax-only DIR/t.c -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/mcp -target x86_64-apple-macos11 -isysroot SDK -Rcompile-job-cache", - "file": "DIR/t.c" - } -] - -//--- dir1/t.c -#include "a.h" - -//--- dir1/module.modulemap -module A { header "a.h" } -module B { header "b.h" } - -//--- dir1/a.h -#include "b.h" - -//--- dir1/b.h -#include -#include diff --git a/clang/test/ClangScanDeps/modules-cas-fs-prefix-mapping.c b/clang/test/ClangScanDeps/modules-cas-fs-prefix-mapping.c deleted file mode 100644 index dbf5c00a50646..0000000000000 --- a/clang/test/ClangScanDeps/modules-cas-fs-prefix-mapping.c +++ /dev/null @@ -1,188 +0,0 @@ -// Test path prefix-mapping when using a cas-fs with clang-scan-deps in -// modules. - -// REQUIRES: ondisk_cas - -// RUN: rm -rf %t -// RUN: split-file %s %t -// RUN: sed -e "s|DIR|%/t|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/cdb.json - -// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \ -// RUN: -cas-path %t/cas -module-files-dir %t/modules \ -// RUN: -prefix-map=%t/modules=%/root^modules -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \ -// RUN: > %t/full_result.txt - -// Check the command-lines. -// RUN: cat %t/full_result.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize SDK_PREFIX=%/S/Inputs/SDK --sanitize ROOT^=%/root^ --enable-yaml-compatibility %s - -// Extract individual commands. -// RUN: %deps-to-rsp %t/full_result.txt --module-name=B > %t/B.cc1.rsp -// RUN: %deps-to-rsp %t/full_result.txt --module-name=A > %t/A.cc1.rsp -// RUN: %deps-to-rsp %t/full_result.txt --tu-index 0 > %t/tu.cc1.rsp - -// Check the casfs. -// RUN: cat %t/B.cc1.rsp | sed -E 's/.* "-fcas-fs" "([^ ]+)" .*/\1/' > %t/B_id.txt -// RUN: cat %t/A.cc1.rsp | sed -E 's/.* "-fcas-fs" "([^ ]+)" .*/\1/' > %t/A_id.txt -// RUN: cat %t/tu.cc1.rsp | sed -E 's/.* "-fcas-fs" "([^ ]+)" .*/\1/' > %t/tu_id.txt -// RUN: llvm-cas -cas %t/cas -ls-tree-recursive @%t/B_id.txt > %t/B_fs.txt -// RUN: llvm-cas -cas %t/cas -ls-tree-recursive @%t/A_id.txt > %t/A_fs.txt -// RUN: llvm-cas -cas %t/cas -ls-tree-recursive @%t/tu_id.txt > %t/tu_fs.txt -// RUN: FileCheck %s -input-file %t/A_fs.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK -DROOT=%{/roott} -check-prefixes=FS_NEG,FS -// RUN: FileCheck %s -input-file %t/B_fs.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK -DROOT=%{/roott} -check-prefixes=FS_NEG,FS -// RUN: FileCheck %s -input-file %t/tu_fs.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK -DROOT=%{/roott} -check-prefixes=FS_NEG,FS - -// FS_NEG-NOT: [[PREFIX]] -// FS_NEG-NOT: [[SDK_PREFIX]] -// FS_NEG-NOT: .pcm{{$}} -// FS: file llvmcas://{{.*}} [[ROOT]]^sdk/usr/include/stdlib.h -// FS: file llvmcas://{{.*}} [[ROOT]]^src/a.h -// FS: file llvmcas://{{.*}} [[ROOT]]^src/b.h -// FS: file llvmcas://{{.*}} [[ROOT]]^src/module.modulemap -// FS: file llvmcas://{{.*}} [[ROOT]]^tc/lib/clang/{{.*}}/include/stdarg.h - -// Check that it builds. -// RUN: %clang @%t/B.cc1.rsp -// RUN: %clang @%t/A.cc1.rsp -// RUN: %clang @%t/tu.cc1.rsp - -// CHECK: { -// CHECK: "modules": [ -// CHECK: { -// CHECK: "casfs-root-id": "[[A_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK: "clang-module-deps": [ -// CHECK: { -// CHECK: "module-name": "B" -// CHECK: } -// CHECK: ] -// CHECK: "clang-modulemap-file": "PREFIX{{/|\\\\}}module.modulemap" -// CHECK: "command-line": [ -// CHECK: "-fcas-path" -// CHECK: "PREFIX{{/|\\\\}}cas" -// CHECK: "-fcas-fs" -// CHECK: "[[A_ROOT_ID]]" -// CHECK: "-fcas-fs-working-directory" -// CHECK: "ROOT^src" -// CHECK: "-fmodule-map-file=ROOT^src{{/|\\\\}}module.modulemap" -// CHECK: "-o" -// CHECK: "PREFIX{{/|\\\\}}modules{{/|\\\\}}{{.*}}{{/|\\\\}}A-{{.*}}.pcm" -// CHECK: "-fmodule-file-cache-key" -// CHECK: "B-[[B_CONTEXT_HASH:[^.]+]].pcm" -// CHECK: "llvmcas://{{.*}}" -// CHECK: "-x" -// CHECK: "c" -// CHECK: "ROOT^src{{/|\\\\}}module.modulemap" -// CHECK: "-isysroot" -// CHECK: "ROOT^sdk" -// CHECK: "-resource-dir" -// CHECK: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}" -// CHECK: "-fmodule-file=B=B-[[B_CONTEXT_HASH]].pcm" -// CHECK: "-isystem" -// CHECK: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}{{/|\\\\}}include" -// CHECK: "-internal-externc-isystem" -// CHECK: "ROOT^sdk{{/|\\\\}}usr{{/|\\\\}}include" -// CHECK: ] -// CHECK: "file-deps": [ -// CHECK: "PREFIX{{/|\\\\}}module.modulemap" -// CHECK: "PREFIX{{/|\\\\}}a.h" -// CHECK: ] -// CHECK: "name": "A" -// CHECK: } -// CHECK: { -// CHECK: "casfs-root-id": "[[B_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK: "clang-module-deps": [], -// CHECK: "clang-modulemap-file": "PREFIX{{/|\\\\}}module.modulemap" -// CHECK: "command-line": [ -// CHECK: "-fcas-path" -// CHECK: "PREFIX{{/|\\\\}}cas" -// CHECK: "-fcas-fs" -// CHECK: "[[B_ROOT_ID]]" -// CHECK: "-fcas-fs-working-directory" -// CHECK: "ROOT^src" -// CHECK: "-o" -// CHECK: "PREFIX{{/|\\\\}}modules{{/|\\\\}}{{.*}}{{/|\\\\}}B-[[B_CONTEXT_HASH]].pcm" -// CHECK: "-x" -// CHECK: "c" -// CHECK: "ROOT^src{{/|\\\\}}module.modulemap" -// CHECK: "-isysroot" -// CHECK: "ROOT^sdk" -// CHECK: "-resource-dir" -// CHECK: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}" -// CHECK: "-isystem" -// CHECK: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}{{/|\\\\}}include" -// CHECK: "-internal-externc-isystem" -// CHECK: "ROOT^sdk{{/|\\\\}}usr{{/|\\\\}}include" -// CHECK: ] -// CHECK: "context-hash": "[[B_CONTEXT_HASH]]" -// CHECK: "file-deps": [ -// Note: PREFIX, SDK_PREFIX and toolchain path are unordered -// CHECK-DAG: "PREFIX{{/|\\\\}}module.modulemap" -// CHECK-DAG: "PREFIX{{/|\\\\}}b.h" -// CHECK-DAG: "{{.*}}{{/|\\\\}}include{{/|\\\\}}stdarg.h" -// CHECK-DAG: "SDK_PREFIX{{/|\\\\}}usr{{/|\\\\}}include{{/|\\\\}}stdlib.h" -// CHECK: ] -// CHECK: "name": "B" -// CHECK: } -// CHECK: ] -// CHECK: "translation-units": [ -// CHECK: { -// CHECK: "commands": [ -// CHECK: { -// CHECK: "casfs-root-id": "[[TU_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK: "clang-module-deps": [ -// CHECK: { -// CHECK: "module-name": "A" -// CHECK: } -// CHECK: ] -// CHECK: "command-line": [ -// CHECK: "-fcas-path" -// CHECK: "PREFIX{{/|\\\\}}cas" -// CHECK: "-fcas-fs" -// CHECK: "[[TU_ROOT_ID]]" -// CHECK: "-fcas-fs-working-directory" -// CHECK: "ROOT^src" -// CHECK: "-fmodule-map-file=ROOT^src{{/|\\\\}}module.modulemap" -// CHECK: "-fmodule-file-cache-key" -// CHECK: "{{.*}}A-{{.*}}.pcm" -// CHECK: "llvmcas://{{.*}}" -// CHECK: "-x" -// CHECK: "c" -// CHECK: "ROOT^src{{/|\\\\}}t.c" -// CHECK: "-isysroot" -// CHECK: "ROOT^sdk" -// CHECK: "-resource-dir" -// CHECK: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}" -// CHECK: "-fmodule-file=A=A-{{.*}}.pcm" -// CHECK: "-isystem" -// CHECK: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}{{/|\\\\}}include" -// CHECK: "-internal-externc-isystem" -// CHECK: "ROOT^sdk{{/|\\\\}}usr{{/|\\\\}}include" -// CHECK: ], -// CHECK: "file-deps": [ -// CHECK: "PREFIX{{/|\\\\}}t.c" -// CHECK: ] -// CHECK: "input-file": "PREFIX{{/|\\\\}}t.c" -// CHECK: } - - -//--- cdb.json.template -[ - { - "directory": "DIR", - "command": "CLANG -fsyntax-only DIR/t.c -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/mcp -target x86_64-apple-macos11 -isysroot SDK", - "file": "DIR/t.c" - } -] - -//--- t.c -#include "a.h" - -//--- module.modulemap -module A { header "a.h" } -module B { header "b.h" } - -//--- a.h -#include "b.h" - -//--- b.h -#include -#include diff --git a/clang/test/ClangScanDeps/modules-cas-full-by-mod-name.c b/clang/test/ClangScanDeps/modules-cas-full-by-mod-name.c deleted file mode 100644 index e58ecae649d35..0000000000000 --- a/clang/test/ClangScanDeps/modules-cas-full-by-mod-name.c +++ /dev/null @@ -1,101 +0,0 @@ -// UNSUPPORTED: target=powerpc64-ibm-aix{{.*}} -// REQUIRES: ondisk_cas - -// RUN: rm -rf %t -// RUN: split-file %s %t - -//--- module.modulemap -module root { header "root.h" } -module direct { header "direct.h" } -module transitive { header "transitive.h" } -//--- root.h -#include "direct.h" -#include "root/textual.h" -//--- direct.h -#include "transitive.h" -//--- transitive.h -// empty - -//--- root/textual.h -// This is here to verify that the "root" directory doesn't clash with name of -// the "root" module. - -//--- cdb.json.template -[{ - "file": "", - "directory": "DIR", - "command": "clang -fmodules -fmodules-cache-path=DIR/cache -I DIR -x c" -}] - -// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json -// RUN: clang-scan-deps -compilation-database %t/cdb.json \ -// RUN: -cas-path %t/cas -format experimental-full -module-names=root > %t/result.json -// RUN: cat %t/result.json | %PathSanitizingFileCheck --sanitize PREFIX=%/t --enable-yaml-compatibility %s - -// CHECK: { -// CHECK-NEXT: "modules": [ -// CHECK-NEXT: { -// CHECK-NEXT: "cache-key": "[[DIRECT_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// CHECK-NEXT: "casfs-root-id": "[[LEFT_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK-NEXT: "clang-module-deps": [ -// CHECK-NEXT: { -// CHECK-NEXT: "context-hash": "{{.*}}", -// CHECK-NEXT: "module-name": "transitive" -// CHECK-NEXT: } -// CHECK-NEXT: ], -// CHECK-NEXT: "clang-modulemap-file": "PREFIX{{/|\\\\}}module.modulemap", -// CHECK-NEXT: "command-line": [ -// CHECK: "-fmodule-file-cache-key" -// CHECK-NEXT: "{{.*transitive-.*\.pcm}}" -// CHECK-NEXT: "[[TRANSITIVE_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// CHECK: ], -// CHECK-NEXT: "context-hash": "{{.*}}", -// CHECK-NEXT: "file-deps": [ -// CHECK-NEXT: "PREFIX{{/|\\\\}}module.modulemap" -// CHECK-NEXT: "PREFIX{{/|\\\\}}direct.h" -// CHECK-NEXT: ], -// CHECK-NEXT: "link-libraries": [], -// CHECK-NEXT: "name": "direct" -// CHECK-NEXT: }, -// CHECK-NEXT: { -// CHECK-NEXT: "cache-key": "[[ROOT_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// CHECK-NEXT: "casfs-root-id": "[[ROOT_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK-NEXT: "clang-module-deps": [ -// CHECK-NEXT: { -// CHECK-NEXT: "context-hash": "{{.*}}", -// CHECK-NEXT: "module-name": "direct" -// CHECK-NEXT: } -// CHECK-NEXT: ], -// CHECK-NEXT: "clang-modulemap-file": "PREFIX{{/|\\\\}}module.modulemap", -// CHECK-NEXT: "command-line": [ -// CHECK: "-fmodule-file-cache-key" -// CHECK-NEXT: "{{.*direct-.*\.pcm}}" -// CHECK-NEXT: "[[DIRECT_CACHE_KEY]]" -// CHECK: ], -// CHECK-NEXT: "context-hash": "{{.*}}", -// CHECK-NEXT: "file-deps": [ -// CHECK-NEXT: "PREFIX{{/|\\\\}}module.modulemap" -// CHECK-NEXT: "PREFIX{{/|\\\\}}root.h" -// CHECK-NEXT: "PREFIX{{/|\\\\}}root{{/|\\\\}}textual.h" -// CHECK-NEXT: ], -// CHECK-NEXT: "link-libraries": [], -// CHECK-NEXT: "name": "root" -// CHECK-NEXT: }, -// CHECK-NEXT: { -// CHECK-NEXT: "cache-key": "[[TRANSITIVE_CACHE_KEY]]" -// CHECK-NEXT: "casfs-root-id": "[[LEFT_ROOT_ID]]" -// CHECK-NEXT: "clang-module-deps": [], -// CHECK-NEXT: "clang-modulemap-file": "PREFIX{{/|\\\\}}module.modulemap", -// CHECK-NEXT: "command-line": [ -// CHECK: ], -// CHECK-NEXT: "context-hash": "{{.*}}", -// CHECK-NEXT: "file-deps": [ -// CHECK-NEXT: "PREFIX{{/|\\\\}}module.modulemap" -// CHECK-NEXT: "PREFIX{{/|\\\\}}transitive.h" -// CHECK-NEXT: ], -// CHECK-NEXT: "link-libraries": [], -// CHECK-NEXT: "name": "transitive" -// CHECK-NEXT: } -// CHECK-NEXT: ], -// CHECK-NEXT: "translation-units": [] -// CHECK-NEXT: } diff --git a/clang/test/ClangScanDeps/modules-cas-module-cache-hash.c b/clang/test/ClangScanDeps/modules-cas-module-cache-hash.c deleted file mode 100644 index c4d4f5b289cb6..0000000000000 --- a/clang/test/ClangScanDeps/modules-cas-module-cache-hash.c +++ /dev/null @@ -1,33 +0,0 @@ -// Check that using the same module cache does not cause errors when switching -// between cas-fs and include-tree. - -// REQUIRES: ondisk_cas -// RUN: rm -rf %t -// RUN: split-file %s %t -// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json - -// RUN: clang-scan-deps -compilation-database %t/cdb.json \ -// RUN: -cas-path %t/cas -module-files-dir %t/outputs \ -// RUN: -format experimental-include-tree-full | FileCheck %s -check-prefix=INCLUDE_TREE - -// RUN: clang-scan-deps -compilation-database %t/cdb.json \ -// RUN: -cas-path %t/cas -module-files-dir %t/outputs \ -// RUN: -format experimental-full | FileCheck %s -check-prefix=CAS_FS - -// INCLUDE_TREE: "-fcas-include-tree" -// CAS_FS: "-fcas-fs" - -//--- cdb.json.template -[{ - "file": "DIR/tu.c", - "directory": "DIR", - "command": "clang -fsyntax-only -fmodules -fimplicit-modules -fmodules-cache-path=DIR/mcp DIR/tu.c" -}] - -//--- module.modulemap -module M { header "M.h" } - -//--- M.h - -//--- tu.c -#include "M.h" diff --git a/clang/test/ClangScanDeps/modules-cas-trees-cwd.c b/clang/test/ClangScanDeps/modules-cas-trees-cwd.c deleted file mode 100644 index 2491ce885437c..0000000000000 --- a/clang/test/ClangScanDeps/modules-cas-trees-cwd.c +++ /dev/null @@ -1,61 +0,0 @@ -// Ensure the working directory is correctly captured in cas-fs when compiling -// with caching from outside the source directory. -// FIXME: ideally we could further canonicalize the working directory when it -// is irrelevant to the compilation, but for now ensure we can compile at all. - -// REQUIRES: ondisk_cas - -// RUN: rm -rf %t -// RUN: split-file %s %t -// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json -// RUN: mkdir -p %t/B - -// RUN: clang-scan-deps -compilation-database %t/cdb.json \ -// RUN: -cas-path %t/cas -module-files-dir %t/outputs \ -// RUN: -format experimental-full -mode preprocess-dependency-directives \ -// RUN: > %t/deps.json - -// RUN: %deps-to-rsp %t/deps.json --module-name Mod > %t/Mod.rsp -// RUN: %deps-to-rsp %t/deps.json --tu-index 0 > %t/tu.rsp - -// RUN: %clang @%t/Mod.rsp -// RUN: %clang @%t/tu.rsp - -// Check specifics of the command-line -// RUN: cat %t/deps.json | %PathSanitizingFileCheck --sanitize PREFIX=%/t --enable-yaml-compatibility %s - -// CHECK: { -// CHECK-NEXT: "modules": [ -// CHECK-NEXT: { -// CHECK: "command-line": [ -// CHECK: "-fcas-fs-working-directory" -// CHECK-NEXT: "PREFIX{{/|\\\\}}B" -// CHECK: ] -// CHECK: "name": "Mod" -// CHECK: } -// CHECK-NEXT: ] -// CHECK: "translation-units": [ -// CHECK: { -// CHECK: "commands": [ -// CHECK: { -// CHECK: "command-line": [ -// CHECK: "-fcas-fs-working-directory" -// CHECK-NEXT: "PREFIX{{/|\\\\}}B" -// CHECK: ] - -//--- cdb.json.template -[{ - "directory" : "DIR/B", - "command" : "clang_tool -fsyntax-only DIR/A/tu.c -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/A/module-cache -Rcompile-job-cache", - "file" : "DIR/A/tu.c" -}] - -//--- A/module.modulemap -module Mod { header "Mod.h" } - -//--- A/Mod.h -#pragma once -void Top(void); - -//--- A/tu.c -#include "Mod.h" diff --git a/clang/test/ClangScanDeps/modules-cas-trees-with-pch.c b/clang/test/ClangScanDeps/modules-cas-trees-with-pch.c deleted file mode 100644 index b9dddf5d738ae..0000000000000 --- a/clang/test/ClangScanDeps/modules-cas-trees-with-pch.c +++ /dev/null @@ -1,230 +0,0 @@ -// Check that we can scan pch + modules with caching enabled and build the -// resulting commands. - -// REQUIRES: ondisk_cas - -// RUN: rm -rf %t -// RUN: split-file %s %t -// RUN: sed "s|DIR|%/t|g" %t/cdb_pch.json.template > %t/cdb_pch.json -// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json - -// == Scan PCH -// RUN: clang-scan-deps -compilation-database %t/cdb_pch.json \ -// RUN: -cas-path %t/cas -module-files-dir %t/outputs \ -// RUN: -format experimental-full -mode preprocess-dependency-directives \ -// RUN: > %t/deps_pch.json - -// == Check specifics of the command-line -// RUN: cat %t/deps_pch.json | %PathSanitizingFileCheck --sanitize PREFIX=%/t --enable-yaml-compatibility %s -check-prefix=PCH - -// == Build PCH -// RUN: %deps-to-rsp %t/deps_pch.json --module-name A > %t/A.rsp -// RUN: %deps-to-rsp %t/deps_pch.json --module-name B > %t/B.rsp -// RUN: %deps-to-rsp %t/deps_pch.json --tu-index 0 > %t/pch.rsp - -// RUN: %clang @%t/B.rsp 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// RUN: %clang @%t/A.rsp 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// Ensure we load pcms from action cache -// RUN: rm -rf %t/outputs -// RUN: %clang @%t/pch.rsp 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// RUN: %clang @%t/pch.rsp 2>&1 | FileCheck %s -check-prefix=CACHE-HIT - -// == Scan TU, including PCH -// RUN: clang-scan-deps -compilation-database %t/cdb.json \ -// RUN: -cas-path %t/cas -module-files-dir %t/outputs \ -// RUN: -format experimental-full -mode preprocess-dependency-directives \ -// RUN: > %t/deps.json - -// == Check specifics of the command-line -// RUN: cat %t/deps.json | %PathSanitizingFileCheck --sanitize PREFIX=%/t --enable-yaml-compatibility %s - -// == Build TU, including PCH -// RUN: %deps-to-rsp %t/deps.json --module-name C > %t/C.rsp -// RUN: %deps-to-rsp %t/deps.json --tu-index 0 > %t/tu.rsp - -// RUN: %clang @%t/C.rsp 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// Ensure we load pcms from action cache -// RUN: rm -rf %t/outputs -// RUN: %clang @%t/tu.rsp 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// RUN: %clang @%t/tu.rsp 2>&1 | FileCheck %s -check-prefix=CACHE-HIT - -// PCH: { -// PCH-NEXT: "modules": [ -// PCH-NEXT: { -// PCH: "casfs-root-id": "[[A_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// PCH: "clang-module-deps": [ -// PCH: { -// PCH: "module-name": "B" -// PCH: } -// PCH-NEXT: ] -// PCH: "command-line": [ -// PCH-NEXT: "-cc1" -// PCH: "-fcas-path" -// PCH-NEXT: "PREFIX{{/|\\\\}}cas" -// PCH: "-fcas-fs" -// PCH-NEXT: "[[A_ROOT_ID]]" -// PCH: "-o" -// PCH-NEXT: "{{.*}}[[A_PCM:A-.*\.pcm]]" -// PCH: "-fcache-compile-job" -// PCH: "-emit-module" -// PCH: "-fmodule-file-cache-key" -// PCH: "[[B_PCM:B-.*\.pcm]]" -// PCH: "[[B_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// PCH: "-fmodule-file={{(B=)?}}[[B_PCM]]" -// PCH: ] -// PCH: "file-deps": [ -// PCH-NEXT: "PREFIX{{/|\\\\}}module.modulemap" -// PCH-NEXT: "PREFIX{{/|\\\\}}A.h" -// PCH-NEXT: ] -// PCH: "name": "A" -// PCH: } -// PCH-NEXT: { -// PCH: "casfs-root-id": "[[B_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// PCH: "clang-module-deps": [] -// PCH: "command-line": [ -// PCH-NEXT: "-cc1" -// PCH: "-fcas-path" -// PCH-NEXT: "PREFIX{{/|\\\\}}cas" -// PCH: "-fcas-fs" -// PCH-NEXT: "[[B_ROOT_ID]]" -// PCH: "-o" -// PCH-NEXT: "{{.*}}[[B_PCM]]" -// PCH: "-fcache-compile-job" -// PCH: "-emit-module" -// PCH: ] -// PCH: "file-deps": [ -// PCH-NEXT: "PREFIX{{/|\\\\}}module.modulemap" -// PCH-NEXT: "PREFIX{{/|\\\\}}B.h" -// PCH-NEXT: ] -// PCH: "name": "B" -// PCH: } -// PCH-NEXT: ] -// PCH: "translation-units": [ -// PCH: { -// PCH: "commands": [ -// PCH: { -// PCH: "casfs-root-id": "[[PCH_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// PCH: "clang-module-deps": [ -// PCH: { -// PCH: "module-name": "A" -// PCH: } -// PCH-NEXT: ] -// PCH: "command-line": [ -// PCH-NEXT: "-cc1" -// PCH: "-fcas-path" -// PCH-NEXT: "PREFIX{{/|\\\\}}cas" -// PCH: "-fcas-fs" -// PCH-NEXT: "[[PCH_ROOT_ID]]" -// PCH: "-fno-pch-timestamp" -// PCH: "-fcache-compile-job" -// PCH: "-emit-pch" -// PCH: "-fmodule-file-cache-key" -// PCH: "[[A_PCM]]" -// PCH: "{{llvmcas://[[:xdigit:]]+}}" -// PCH: "-fmodule-file={{(A=)?}}[[A_PCM]]" -// PCH: ] -// PCH: "file-deps": [ -// PCH-NEXT: "PREFIX{{/|\\\\}}prefix.h" -// PCH-NEXT: ] -// PCH: } - -// CHECK: { -// CHECK-NEXT: "modules": [ -// CHECK-NEXT: { -// CHECK: "casfs-root-id": "[[C_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK: "clang-module-deps": [] -// CHECK: "command-line": [ -// CHECK-NEXT: "-cc1" -// CHECK: "-fcas-path" -// CHECK-NEXT: "PREFIX{{/|\\\\}}cas" -// CHECK: "-fcas-fs" -// CHECK-NEXT: "[[C_ROOT_ID]]" -// CHECK: "-o" -// CHECK-NEXT: "{{.*}}[[C_PCM:C-.*\.pcm]]" -// CHECK: "-fcache-compile-job" -// CHECK: "-emit-module" -// CHECK: "-fmodule-file={{(B=)?}}[[B_PCM:B-.*\.pcm]]" -// CHECK: "-fmodule-file-cache-key" -// CHECK: "[[B_PCM]]" -// CHECK: "[[B_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// CHECK: ] -// CHECK: "file-deps": [ -// CHECK-NEXT: "PREFIX{{/|\\\\}}module.modulemap" -// CHECK-NEXT: "PREFIX{{/|\\\\}}C.h" -// CHECK-NEXT: ] -// CHECK: "name": "C" -// CHECK: } -// CHECK-NEXT: ] -// CHECK: "translation-units": [ -// CHECK: { -// CHECK: "commands": [ -// CHECK: { -// CHECK: "casfs-root-id": "[[TU_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK: "clang-module-deps": [ -// CHECK: { -// CHECK: "module-name": "C" -// CHECK: } -// CHECK-NEXT: ] -// CHECK: "command-line": [ -// CHECK-NEXT: "-cc1" -// CHECK: "-fcas-path" -// CHECK-NEXT: "PREFIX{{/|\\\\}}cas" -// CHECK: "-fcas-fs" -// CHECK-NEXT: "[[TU_ROOT_ID]]" -// CHECK: "-fno-pch-timestamp" -// CHECK: "-fcache-compile-job" -// CHECK: "-fmodule-file-cache-key" -// CHECK: "[[C_PCM]]" -// CHECK: "{{llvmcas://[[:xdigit:]]+}}" -// CHECK: "-fmodule-file={{(C=)?}}[[C_PCM]]" -// CHECK: ] -// CHECK: "file-deps": [ -// CHECK-NEXT: "PREFIX{{/|\\\\}}tu.c" -// CHECK-NEXT: "PREFIX{{/|\\\\}}prefix.h.pch" -// CHECK-NEXT: ] -// CHECK: } - -// CACHE-HIT: remark: compile job cache hit -// CACHE-MISS: remark: compile job cache miss - -//--- cdb_pch.json.template -[ - { - "directory" : "DIR", - "command" : "clang_tool -x c-header DIR/prefix.h -o DIR/prefix.h.pch -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache -Rcompile-job-cache", - "file" : "DIR/prefix.h" - }, -] - -//--- cdb.json.template -[ - { - "directory" : "DIR", - "command" : "clang_tool -fsyntax-only DIR/tu.c -include DIR/prefix.h -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache -Rcompile-job-cache", - "file" : "DIR/tu.c" - }, -] - -//--- module.modulemap -module A { header "A.h" export * } -module B { header "B.h" } -module C { header "C.h" export * } - -//--- A.h -#include "B.h" - -//--- B.h -void B(void); - -//--- C.h -#include "B.h" -void B(void); - -//--- prefix.h -#include "A.h" - -//--- tu.c -#include "C.h" -void tu(void) { - B(); -} diff --git a/clang/test/ClangScanDeps/modules-cas-trees.c b/clang/test/ClangScanDeps/modules-cas-trees.c deleted file mode 100644 index 1d17865219b88..0000000000000 --- a/clang/test/ClangScanDeps/modules-cas-trees.c +++ /dev/null @@ -1,217 +0,0 @@ -// Check that we can scan modules with caching enabled and build the resulting -// commands. - -// REQUIRES: ondisk_cas - -// RUN: rm -rf %t -// RUN: split-file %s %t -// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json - -// RUN: clang-scan-deps -compilation-database %t/cdb.json \ -// RUN: -cas-path %t/cas -module-files-dir %t/outputs \ -// RUN: -format experimental-full -mode preprocess-dependency-directives \ -// RUN: > %t/deps.json - -// Full and tree-full modes are identical here. -// RUN: clang-scan-deps -compilation-database %t/cdb.json \ -// RUN: -cas-path %t/cas -module-files-dir %t/outputs \ -// RUN: -format experimental-tree-full -mode preprocess-dependency-directives \ -// RUN: > %t/deps_tree.json -// RUN: diff -u %t/deps_tree.json %t/deps.json - -// Disabling/re-enabling the cas should not be cached in the implicit pcms -// RUN: clang-scan-deps -compilation-database %t/cdb.json \ -// RUN: -module-files-dir %t/outputs \ -// RUN: -format experimental-full -mode preprocess-dependency-directives \ -// RUN: > %t/deps_no_cas.json -// RUN: cat %t/deps_no_cas.json | FileCheck %s -check-prefix=NO_CAS -// NO_CAS-NOT: fcas -// NO_CAS-NOT: faction-cache -// NO_CAS-NOT: fcache-compile-job -// RUN: clang-scan-deps -compilation-database %t/cdb.json \ -// RUN: -cas-path %t/cas -module-files-dir %t/outputs \ -// RUN: -format experimental-full -mode preprocess-dependency-directives \ -// RUN: > %t/deps_cas_2.json -// RUN: diff -u %t/deps_cas_2.json %t/deps.json - -// RUN: %deps-to-rsp %t/deps.json --module-name Top > %t/Top.rsp -// RUN: %deps-to-rsp %t/deps.json --module-name Left > %t/Left.rsp -// RUN: %deps-to-rsp %t/deps.json --module-name Right > %t/Right.rsp -// RUN: %deps-to-rsp %t/deps.json --tu-index 0 > %t/tu.rsp - -// Missing pcm in action cache -// RUN: not %clang @%t/Left.rsp 2> %t/error.txt -// RUN: cat %t/error.txt | FileCheck %s -check-prefix=MISSING -// MISSING: error: module file '{{.*}}.pcm' not found: missing module cache key {{.*}}: expected to be produced by: - -// Build everything -// RUN: %clang @%t/Top.rsp 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// RUN: %clang @%t/Left.rsp 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// RUN: %clang @%t/Left.rsp 2>&1 | FileCheck %s -check-prefix=CACHE-HIT -// RUN: %clang @%t/Right.rsp 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// RUN: %clang @%t/Right.rsp 2>&1 | FileCheck %s -check-prefix=CACHE-HIT -// Ensure we load pcms from action cache -// RUN: rm -rf %t/outputs -// RUN: %clang @%t/tu.rsp 2>&1 | FileCheck %s -check-prefix=CACHE-MISS -// RUN: %clang @%t/tu.rsp 2>&1 | FileCheck %s -check-prefix=CACHE-HIT - -// CACHE-HIT: remark: compile job cache hit -// CACHE-MISS: remark: compile job cache miss - -// Check specifics of the command-line -// RUN: cat %t/deps.json | %PathSanitizingFileCheck --sanitize PREFIX=%/t --enable-yaml-compatibility %s - -// CHECK: { -// CHECK-NEXT: "modules": [ -// CHECK-NEXT: { -// CHECK: "cache-key": "[[LEFT_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// CHECK: "casfs-root-id": "[[LEFT_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK: "clang-module-deps": [ -// CHECK: { -// CHECK: "module-name": "Top" -// CHECK: } -// CHECK-NEXT: ] -// CHECK: "command-line": [ -// CHECK-NEXT: "-cc1" -// CHECK: "-fcas-path" -// CHECK-NEXT: "PREFIX{{/|\\\\}}cas" -// CHECK: "-fcas-fs" -// CHECK-NEXT: "[[LEFT_ROOT_ID]]" -// CHECK: "-o" -// CHECK-NEXT: "{{.*}}[[LEFT_PCM:Left-.*\.pcm]]" -// CHECK: "-fcache-compile-job" -// CHECK: "-emit-module" -// CHECK: "-fmodule-file-cache-key" -// CHECK: "{{.*}}[[TOP_PCM:Top-.*\.pcm]]" -// CHECK: "[[TOP_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// CHECK: "-fmodule-file={{(Top=)?}}[[TOP_PCM]]" -// CHECK: ] -// CHECK: "file-deps": [ -// CHECK-NEXT: "PREFIX{{/|\\\\}}module.modulemap" -// CHECK-NEXT: "PREFIX{{/|\\\\}}Left.h" -// CHECK-NEXT: ] -// CHECK: "name": "Left" -// CHECK: } -// CHECK-NEXT: { -// CHECK: "cache-key": "[[RIGHT_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// CHECK: "casfs-root-id": "[[RIGHT_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK: "clang-module-deps": [ -// CHECK: { -// CHECK: "module-name": "Top" -// CHECK: } -// CHECK-NEXT: ] -// CHECK: "command-line": [ -// CHECK-NEXT: "-cc1" -// CHECK: "-fcas-path" -// CHECK-NEXT: "PREFIX{{/|\\\\}}cas" -// CHECK: "-fcas-fs" -// CHECK-NEXT: "[[RIGHT_ROOT_ID]]" -// CHECK: "-o" -// CHECK-NEXT: "{{.*}}[[RIGHT_PCM:Right-.*\.pcm]]" -// CHECK: "-fcache-compile-job" -// CHECK: "-emit-module" -// CHECK: "-fmodule-file-cache-key" -// CHECK: "[[TOP_PCM]]" -// CHECK: "[[TOP_CACHE_KEY]]" -// CHECK: "-fmodule-file={{(Top=)?}}[[TOP_PCM]]" -// CHECK: ] -// CHECK: "file-deps": [ -// CHECK-NEXT: "PREFIX{{/|\\\\}}module.modulemap" -// CHECK-NEXT: "PREFIX{{/|\\\\}}Right.h" -// CHECK: ] -// CHECK: "name": "Right" -// CHECK: } -// CHECK-NEXT: { -// CHECK: "cache-key": "[[TOP_CACHE_KEY]]" -// CHECK: "casfs-root-id": "[[TOP_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK: "clang-module-deps": [] -// CHECK: "command-line": [ -// CHECK-NEXT: "-cc1" -// CHECK: "-fcas-path" -// CHECK-NEXT: "PREFIX{{/|\\\\}}cas" -// CHECK: "-fcas-fs" -// CHECK-NEXT: "[[TOP_ROOT_ID]]" -// CHECK: "-o" -// CHECK-NEXT: "{{.*}}[[TOP_PCM]]" -// CHECK: "-fcache-compile-job" -// CHECK: "-emit-module" -// CHECK: ] -// CHECK: "file-deps": [ -// CHECK-NEXT: "PREFIX{{/|\\\\}}module.modulemap" -// CHECK-NEXT: "PREFIX{{/|\\\\}}Top.h" -// CHECK: ] -// CHECK: "name": "Top" -// CHECK: } -// CHECK-NEXT: ] -// CHECK: "translation-units": [ -// CHECK: { -// CHECK: "commands": [ -// CHECK: { -// CHECK: "cache-key": "[[TU_CACHE_KEY:llvmcas://[[:xdigit:]]+]]" -// CHECK: "casfs-root-id": "[[TU_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK: "clang-module-deps": [ -// CHECK: { -// CHECK: "module-name": "Left" -// CHECK: } -// CHECK: { -// CHECK: "module-name": "Right" -// CHECK: } -// CHECK-NEXT: ] -// CHECK: "command-line": [ -// CHECK-NEXT: "-cc1" -// CHECK: "-fcas-path" -// CHECK-NEXT: "PREFIX{{/|\\\\}}cas" -// CHECK: "-fcas-fs" -// CHECK-NEXT: "[[TU_ROOT_ID]]" -// CHECK: "-fcache-compile-job" -// CHECK: "-fmodule-file-cache-key" -// CHECK: "[[LEFT_PCM]]" -// CHECK: "[[LEFT_CACHE_KEY]]" -// CHECK: "-fmodule-file-cache-key" -// CHECK: "[[RIGHT_PCM]]" -// CHECK: "[[RIGHT_CACHE_KEY]]" -// CHECK: "-fmodule-file={{(Left=)?}}[[LEFT_PCM]]" -// CHECK: "-fmodule-file={{(Right=)?}}[[RIGHT_PCM]]" -// CHECK: ] -// CHECK: "file-deps": [ -// CHECK-NEXT: "PREFIX{{/|\\\\}}tu.c" -// CHECK-NEXT: ] -// CHECK: } - - - -//--- cdb.json.template -[{ - "directory" : "DIR", - "command" : "clang_tool -fsyntax-only DIR/tu.c -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache -Rcompile-job-cache", - "file" : "DIR/tu.c" -}] - -//--- module.modulemap -module Top { header "Top.h" export * } -module Left { header "Left.h" export * } -module Right { header "Right.h" export * } - -//--- Top.h -#pragma once -void Top(void); - -//--- Left.h -#pragma once -#include "Top.h" -void Left(void); - -//--- Right.h -#pragma once -#include "Top.h" -void Right(void); - -//--- tu.c -#include "Left.h" -#include "Right.h" - -void tu(void) { - Top(); - Left(); - Right(); -} diff --git a/clang/test/ClangScanDeps/modules-cas.cpp b/clang/test/ClangScanDeps/modules-cas.cpp deleted file mode 100644 index 3070dabdd3c1c..0000000000000 --- a/clang/test/ClangScanDeps/modules-cas.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// REQUIRES: ondisk_cas -// RUN: rm -rf %t.dir -// RUN: rm -rf %t.cdb -// RUN: rm -rf %t_clangcl.cdb -// RUN: rm -rf %t.module-cache -// RUN: rm -rf %t.module-cache_clangcl -// RUN: mkdir -p %t.dir -// RUN: cp %s %t.dir/modules_cdb_input.cpp -// RUN: cp %s %t.dir/modules_cdb_input2.cpp -// RUN: mkdir %t.dir/Inputs -// RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h -// RUN: cp %S/Inputs/header2.h %t.dir/Inputs/header2.h -// RUN: cp %S/Inputs/module.modulemap %t.dir/Inputs/module.modulemap -// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb.json > %t.cdb -// -// RUN: clang-scan-deps -cas-path %t.dir/cas -format experimental-tree -compilation-database %t.cdb -j 1 -mode preprocess-dependency-directives | \ -// RUN: FileCheck %s - -#include "header.h" - -/// Check simple output tree output. There are 4 entries in the cdb, -/// First one is for modules_cdb_input2.cpp -// CHECK: tree llvmcas://{{[[:xdigit:]]+}} -// CHECK-SAME: modules_cdb_input2.cpp - -/// Second one is for modules_cdb_input1.cpp, but it needs to load the header and the module. -// CHECK: tree llvmcas://{{[[:xdigit:]]+}} -// CHECK-SAME: modules_cdb_input.cpp - -/// Third and fourth only need to load module, thus they return the same hash. -// CHECK: tree [[HASH:llvmcas://[[:xdigit:]]+]] -// CHECK-SAME: modules_cdb_input.cpp -// CHECK: tree {{.*}}[[HASH]] -// CHECK-SAME: modules_cdb_input.cpp diff --git a/clang/test/ClangScanDeps/modules-pch-cas-fs-prefix-mapping-caching.c b/clang/test/ClangScanDeps/modules-pch-cas-fs-prefix-mapping-caching.c deleted file mode 100644 index b68a623fe3774..0000000000000 --- a/clang/test/ClangScanDeps/modules-pch-cas-fs-prefix-mapping-caching.c +++ /dev/null @@ -1,115 +0,0 @@ -// Test that we get cache hits across directories with modules and PCH. - -// REQUIRES: ondisk_cas - -// RUN: rm -rf %t -// RUN: split-file %s %t -// RUN: cp -r %t/dir1 %t/dir2 -// RUN: sed -e "s|DIR|%/t/dir1|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/dir1/cdb.json -// RUN: sed -e "s|DIR|%/t/dir1|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb_pch.json.template > %t/dir1/cdb_pch.json -// RUN: sed -e "s|DIR|%/t/dir2|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/dir2/cdb.json -// RUN: sed -e "s|DIR|%/t/dir2|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb_pch.json.template > %t/dir2/cdb_pch.json - -// == Scan PCH -// RUN: clang-scan-deps -compilation-database %t/dir1/cdb_pch.json -format experimental-full -optimize-args=none \ -// RUN: -cas-path %t/cas -module-files-dir %t/dir1/modules \ -// RUN: -prefix-map=%t/dir1/modules=%/root^modules -prefix-map=%t/dir1=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \ -// RUN: > %t/pch_dir1.txt - -// RUN: clang-scan-deps -compilation-database %t/dir2/cdb_pch.json -format experimental-full -optimize-args=none \ -// RUN: -cas-path %t/cas -module-files-dir %t/dir2/modules \ -// RUN: -prefix-map=%t/dir2/modules=%/root^modules -prefix-map=%t/dir2=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \ -// RUN: > %t/pch_dir2.txt - -// == Build PCH -// RUN: %deps-to-rsp %t/pch_dir1.txt --module-name=B > %t/dir1/B.cc1.rsp -// RUN: %deps-to-rsp %t/pch_dir1.txt --module-name=A > %t/dir1/A.cc1.rsp -// RUN: %deps-to-rsp %t/pch_dir1.txt --tu-index 0 > %t/dir1/pch.cc1.rsp -// RUN: cd %t/dir1 && %clang @B.cc1.rsp > %t/miss-B.txt 2>&1 -// RUN: cat %t/miss-B.txt | FileCheck %s -check-prefix=CACHE-MISS -// RUN: cd %t/dir1 && %clang @A.cc1.rsp > %t/miss-A.txt 2>&1 -// RUN: cat %t/miss-A.txt | FileCheck %s -check-prefix=CACHE-MISS -// RUN: cd %t/dir1 && %clang @pch.cc1.rsp > %t/miss-pch.txt 2>&1 -// RUN: cat %t/miss-pch.txt | FileCheck %s -check-prefix=CACHE-MISS - -// CACHE-MISS: compile job cache miss - -// RUN: %deps-to-rsp %t/pch_dir2.txt --module-name=B > %t/dir2/B.cc1.rsp -// RUN: %deps-to-rsp %t/pch_dir2.txt --module-name=A > %t/dir2/A.cc1.rsp -// RUN: %deps-to-rsp %t/pch_dir2.txt --tu-index 0 > %t/dir2/pch.cc1.rsp -// RUN: cd %t/dir2 && %clang @B.cc1.rsp > %t/hit-B.txt 2>&1 -// RUN: cat %t/hit-B.txt | FileCheck %s -check-prefix=CACHE-HIT -// RUN: cd %t/dir2 && %clang @A.cc1.rsp > %t/hit-A.txt 2>&1 -// RUN: cat %t/hit-B.txt | FileCheck %s -check-prefix=CACHE-HIT -// RUN: cd %t/dir2 && %clang @pch.cc1.rsp > %t/hit-pch.txt 2>&1 -// RUN: cat %t/hit-pch.txt | FileCheck %s -check-prefix=CACHE-HIT - -// CACHE-HIT: compile job cache hit - -// == Scan TU, including PCH -// RUN: clang-scan-deps -compilation-database %t/dir1/cdb.json -format experimental-full -optimize-args=none \ -// RUN: -cas-path %t/cas -module-files-dir %t/dir1/modules \ -// RUN: -prefix-map=%t/dir1/modules=%/root^modules -prefix-map=%t/dir1=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \ -// RUN: > %t/dir1.txt - -// RUN: clang-scan-deps -compilation-database %t/dir2/cdb.json -format experimental-full -optimize-args=none \ -// RUN: -cas-path %t/cas -module-files-dir %t/dir2/modules \ -// RUN: -prefix-map=%t/dir2/modules=%/root^modules -prefix-map=%t/dir2=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \ -// RUN: > %t/dir2.txt - -// == Build TU -// RUN: %deps-to-rsp %t/dir1.txt --module-name=C > %t/dir1/C.cc1.rsp -// RUN: %deps-to-rsp %t/dir1.txt --tu-index 0 > %t/dir1/tu.cc1.rsp -// RUN: cd %t/dir1 && %clang @C.cc1.rsp > %t/c-miss.txt 2>&1 -// RUN: cat %t/c-miss.txt | FileCheck %s -check-prefix=CACHE-MISS -// RUN: cd %t/dir1 && %clang @tu.cc1.rsp > %t/tu-miss.txt 2>&1 -// RUN: cat %t/tu-miss.txt | FileCheck %s -check-prefix=CACHE-MISS - -// RUN: %deps-to-rsp %t/dir2.txt --module-name=C > %t/dir2/C.cc1.rsp -// RUN: %deps-to-rsp %t/dir2.txt --tu-index 0 > %t/dir2/tu.cc1.rsp -// RUN: cd %t/dir2 && %clang @C.cc1.rsp > %t/c-hit.txt 2>&1 -// RUN: cat %t/c-hit.txt | FileCheck %s -check-prefix=CACHE-HIT -// RUN: cd %t/dir2 && %clang @tu.cc1.rsp > %t/tu-hit.txt 2>&1 -// RUN: cat %t/tu-hit.txt | FileCheck %s -check-prefix=CACHE-HIT - -// RUN: diff -u %t/dir1/prefix.h.pch %t/dir2/prefix.h.pch -// RUN: diff -r -u %t/dir1/modules %t/dir2/modules - -//--- cdb.json.template -[ - { - "directory": "DIR", - "command": "CLANG -fsyntax-only DIR/t.c -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/mcp -target x86_64-apple-macos11 -isysroot SDK -include DIR/prefix.h -Rcompile-job-cache", - "file": "DIR/t.c" - } -] - -//--- cdb_pch.json.template -[ - { - "directory" : "DIR", - "command" : "CLANG -x c-header DIR/prefix.h -o DIR/prefix.h.pch -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/mcp -target x86_64-apple-macos11 -isysroot SDK -Rcompile-job-cache", - "file" : "DIR/prefix.h" - }, -] - -//--- dir1/t.c -#include "c.h" - -//--- dir1/prefix.h -#include "a.h" - -//--- dir1/module.modulemap -module A { header "a.h" } -module B { header "b.h" } -module C { header "c.h" } - -//--- dir1/a.h -#include "b.h" - -//--- dir1/b.h -#include -#include - -//--- dir1/c.h -#include "b.h" diff --git a/clang/test/ClangScanDeps/modules-pch-cas-fs-prefix-mapping.c b/clang/test/ClangScanDeps/modules-pch-cas-fs-prefix-mapping.c deleted file mode 100644 index bee4720c7a921..0000000000000 --- a/clang/test/ClangScanDeps/modules-pch-cas-fs-prefix-mapping.c +++ /dev/null @@ -1,310 +0,0 @@ -// Test path prefix-mapping when using a cas-fs with clang-scan-deps in -// modules with a PCH. - -// REQUIRES: ondisk_cas - -// RUN: rm -rf %t -// RUN: split-file %s %t -// RUN: sed -e "s|DIR|%/t|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/cdb.json -// RUN: sed -e "s|DIR|%/t|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb_pch.json.template > %t/cdb_pch.json - -// == Scan PCH -// RUN: clang-scan-deps -compilation-database %t/cdb_pch.json -format experimental-full \ -// RUN: -cas-path %t/cas -module-files-dir %t/modules \ -// RUN: -prefix-map=%t/modules=%/root^modules -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \ -// RUN: > %t/pch_result.txt - -// == Check specifics of the PCH command-line -// RUN: cat %t/pch_result.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize SDK_PREFIX=%/S/Inputs/SDK --sanitize ROOT^=%/root^ --enable-yaml-compatibility %s -check-prefix=PCH - -// == Build PCH -// RUN: %deps-to-rsp %t/pch_result.txt --module-name=B > %t/B.cc1.rsp -// RUN: %deps-to-rsp %t/pch_result.txt --module-name=A > %t/A.cc1.rsp -// RUN: %deps-to-rsp %t/pch_result.txt --tu-index 0 > %t/pch.cc1.rsp -// RUN: %clang @%t/B.cc1.rsp -// RUN: %clang @%t/A.cc1.rsp -// Ensure we load pcms from action cache -// RUN: rm -rf %t/modules -// RUN: %clang @%t/pch.cc1.rsp - -// == Scan TU, including PCH -// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \ -// RUN: -cas-path %t/cas -module-files-dir %t/modules \ -// RUN: -prefix-map=%t/modules=%/root^modules -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \ -// RUN: > %t/result.txt - -// == Check specifics of the TU command-line -// RUN: cat %t/result.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize SDK_PREFIX=%/S/Inputs/SDK --sanitize ROOT^=%/root^ --enable-yaml-compatibility %s - -// == Build TU -// RUN: %deps-to-rsp %t/result.txt --module-name=C > %t/C.cc1.rsp -// RUN: %deps-to-rsp %t/result.txt --tu-index 0 > %t/tu.cc1.rsp -// RUN: %clang @%t/C.cc1.rsp -// RUN: %clang @%t/tu.cc1.rsp - -// == Check the casfs. -// RUN: cat %t/A.cc1.rsp | sed -E 's/.* "-fcas-fs" "([^ ]+)" .*/\1/' > %t/A_id.txt -// RUN: cat %t/B.cc1.rsp | sed -E 's/.* "-fcas-fs" "([^ ]+)" .*/\1/' > %t/B_id.txt -// RUN: cat %t/C.cc1.rsp | sed -E 's/.* "-fcas-fs" "([^ ]+)" .*/\1/' > %t/C_id.txt -// RUN: cat %t/pch.cc1.rsp | sed -E 's/.* "-fcas-fs" "([^ ]+)" .*/\1/' > %t/pch_id.txt -// RUN: cat %t/tu.cc1.rsp | sed -E 's/.* "-fcas-fs" "([^ ]+)" .*/\1/' > %t/tu_id.txt - -// RUN: llvm-cas -cas %t/cas -ls-tree-recursive @%t/A_id.txt > %t/A_fs.txt -// RUN: llvm-cas -cas %t/cas -ls-tree-recursive @%t/B_id.txt > %t/B_fs.txt -// RUN: llvm-cas -cas %t/cas -ls-tree-recursive @%t/C_id.txt > %t/C_fs.txt -// RUN: llvm-cas -cas %t/cas -ls-tree-recursive @%t/pch_id.txt > %t/pch_fs.txt -// RUN: llvm-cas -cas %t/cas -ls-tree-recursive @%t/tu_id.txt > %t/tu_fs.txt - -// RUN: FileCheck %s -input-file %t/A_fs.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK -DROOT=%{/roott} -check-prefixes=FS_NEG,FS -// RUN: FileCheck %s -input-file %t/B_fs.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK -DROOT=%{/roott} -check-prefixes=FS_NEG,FS -// RUN: FileCheck %s -input-file %t/C_fs.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK -DROOT=%{/roott} -check-prefixes=FS_NEG,FS -// RUN: FileCheck %s -input-file %t/pch_fs.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK -DROOT=%{/roott} -check-prefixes=FS_NEG,FS -// RUN: FileCheck %s -input-file %t/tu_fs.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK -DROOT=%{/roott} -check-prefixes=FS_NEG,FS - -// FS_NEG-NOT: [[PREFIX]] -// FS_NEG-NOT: [[SDK_PREFIX]] -// FS_NEG-NOT: .pcm{{$}} -// FS: file llvmcas://{{.*}} [[ROOT]]^sdk/usr/include/stdlib.h -// FS: file llvmcas://{{.*}} [[ROOT]]^src/a.h -// FS: file llvmcas://{{.*}} [[ROOT]]^src/b.h -// FS: file llvmcas://{{.*}} [[ROOT]]^src/module.modulemap -// FS: file llvmcas://{{.*}} [[ROOT]]^tc/lib/clang/{{.*}}/include/stdarg.h - -// Check that it builds. -// RUN: %clang @%t/B.cc1.rsp -// RUN: %clang @%t/A.cc1.rsp -// RUN: %clang @%t/tu.cc1.rsp - -// PCH: { -// PCH: "modules": [ -// PCH: { -// PCH: "casfs-root-id": "[[A_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// PCH: "clang-module-deps": [ -// PCH: { -// PCH: "module-name": "B" -// PCH: } -// PCH: ] -// PCH: "clang-modulemap-file": "PREFIX{{/|\\\\}}module.modulemap" -// PCH: "command-line": [ -// PCH: "-fcas-path" -// PCH: "PREFIX{{/|\\\\}}cas" -// PCH: "-fcas-fs" -// PCH: "[[A_ROOT_ID]]" -// PCH: "-fcas-fs-working-directory" -// PCH: "ROOT^src" -// PCH: "-fmodule-map-file=ROOT^src{{/|\\\\}}module.modulemap" -// PCH: "-o" -// PCH: "PREFIX{{/|\\\\}}modules{{/|\\\\}}{{.*}}{{/|\\\\}}A-{{.*}}.pcm" -// PCH: "-fmodule-file-cache-key" -// PCH: "B-[[B_CONTEXT_HASH:[^.]+]].pcm" -// PCH: "llvmcas://{{.*}}" -// PCH: "-x" -// PCH: "c" -// PCH: "ROOT^src{{/|\\\\}}module.modulemap" -// PCH: "-isysroot" -// PCH: "ROOT^sdk" -// PCH: "-resource-dir" -// PCH: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}" -// PCH: "-fmodule-file=B=B-[[B_CONTEXT_HASH]].pcm" -// PCH: "-isystem" -// PCH: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}{{/|\\\\}}include" -// PCH: "-internal-externc-isystem" -// PCH: "ROOT^sdk{{/|\\\\}}usr{{/|\\\\}}include" -// PCH: ] -// PCH: "file-deps": [ -// PCH: "PREFIX{{/|\\\\}}module.modulemap" -// PCH: "PREFIX{{/|\\\\}}a.h" -// PCH: ] -// PCH: "name": "A" -// PCH: } -// PCH: { -// PCH: "casfs-root-id": "[[B_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// PCH: "clang-module-deps": [], -// PCH: "clang-modulemap-file": "PREFIX{{/|\\\\}}module.modulemap" -// PCH: "command-line": [ -// PCH: "-fcas-path" -// PCH: "PREFIX{{/|\\\\}}cas" -// PCH: "-fcas-fs" -// PCH: "[[B_ROOT_ID]]" -// PCH: "-fcas-fs-working-directory" -// PCH: "ROOT^src" -// PCH: "-o" -// PCH: "PREFIX{{/|\\\\}}modules{{/|\\\\}}{{.*}}{{/|\\\\}}B-[[B_CONTEXT_HASH]].pcm" -// PCH: "-x" -// PCH: "c" -// PCH: "ROOT^src{{/|\\\\}}module.modulemap" -// PCH: "-isysroot" -// PCH: "ROOT^sdk" -// PCH: "-resource-dir" -// PCH: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}" -// PCH: "-isystem" -// PCH: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}{{/|\\\\}}include" -// PCH: "-internal-externc-isystem" -// PCH: "ROOT^sdk{{/|\\\\}}usr{{/|\\\\}}include" -// PCH: ] -// PCH: "context-hash": "[[B_CONTEXT_HASH]]" -// PCH: "file-deps": [ -// Note: PREFIX, SDK_PREFIX and toolchain path are unordered -// PCH-DAG: "PREFIX{{/|\\\\}}module.modulemap" -// PCH-DAG: "PREFIX{{/|\\\\}}b.h" -// PCH-DAG: "SDK_PREFIX{{/|\\\\}}usr{{/|\\\\}}include{{/|\\\\}}stdlib.h" -// PCH-DAG: "{{.*}}{{/|\\\\}}include{{/|\\\\}}stdarg.h" -// PCH: ] -// PCH: "name": "B" -// PCH: } -// PCH: ] -// PCH: "translation-units": [ -// PCH: { -// PCH: "commands": [ -// PCH: { -// PCH: "casfs-root-id": "[[TU_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// PCH: "clang-module-deps": [ -// PCH: { -// PCH: "module-name": "A" -// PCH: } -// PCH: ] -// PCH: "command-line": [ -// PCH: "-fcas-path" -// PCH: "PREFIX{{/|\\\\}}cas" -// PCH: "-fcas-fs" -// PCH: "[[TU_ROOT_ID]]" -// PCH: "-fcas-fs-working-directory" -// PCH: "ROOT^src" -// PCH: "-fmodule-map-file=ROOT^src{{/|\\\\}}module.modulemap" -// PCH: "-fmodule-file-cache-key" -// PCH: "{{.*}}A-{{.*}}.pcm" -// PCH: "llvmcas://{{.*}}" -// PCH: "-x" -// PCH: "c-header" -// PCH: "ROOT^src{{/|\\\\}}prefix.h" -// PCH: "-isysroot" -// PCH: "ROOT^sdk" -// PCH: "-resource-dir" -// PCH: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}" -// PCH: "-fmodule-file=A=A-{{.*}}.pcm" -// PCH: "-isystem" -// PCH: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}{{/|\\\\}}include" -// PCH: "-internal-externc-isystem" -// PCH: "ROOT^sdk{{/|\\\\}}usr{{/|\\\\}}include" -// PCH: ], -// PCH: "file-deps": [ -// PCH: "PREFIX{{/|\\\\}}prefix.h" -// PCH: ] -// PCH: "input-file": "PREFIX{{/|\\\\}}prefix.h" -// PCH: } - -// CHECK: { -// CHECK-NEXT: "modules": [ -// CHECK-NEXT: { -// CHECK: "casfs-root-id": "[[C_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK: "clang-module-deps": [] -// CHECK: "command-line": [ -// CHECK-NEXT: "-cc1" -// CHECK: "-fcas-path" -// CHECK-NEXT: "PREFIX{{.}}cas" -// CHECK: "-fcas-fs" -// CHECK-NEXT: "[[C_ROOT_ID]]" -// CHECK: "-fcas-fs-working-directory" -// CHECK-NEXT: "ROOT^src" -// CHECK: "-fcache-compile-job" -// CHECK: "-emit-module" -// CHECK: "-fmodule-file=B-{{.*}}.pcm" -// CHECK: "-fmodule-file-cache-key" -// CHECK: "B-{{.*}}.pcm" -// CHECK: "llvmcas://{{.*}}" -// CHECK: "-x" -// CHECK-NEXT: "c" -// CHECK-NEXT: "ROOT^src{{/|\\\\}}module.modulemap" -// CHECK: "-isysroot" -// CHECK-NEXT: "ROOT^sdk" -// CHECK: "-resource-dir" -// CHECK-NEXT: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}" -// CHECK-NOT: PREFIX -// CHECK-NOT: SDK_PREFIX -// CHECK: ] -// CHECK: "name": "C" -// CHECK: } -// CHECK-NEXT: ] -// CHECK: "translation-units": [ -// CHECK: { -// CHECK: "commands": [ -// CHECK: { -// CHECK: "casfs-root-id": "[[TU_ROOT_ID:llvmcas://[[:xdigit:]]+]]" -// CHECK: "clang-module-deps": [ -// CHECK: { -// CHECK: "module-name": "C" -// CHECK: } -// CHECK: ] -// CHECK: "command-line": [ -// CHECK: "-fcas-path" -// CHECK-NEXT: "PREFIX{{/|\\\\}}cas" -// CHECK: "-fcas-fs" -// CHECK-NEXT: "[[TU_ROOT_ID]]" -// CHECK: "-fcas-fs-working-directory" -// CHECK-NEXT: "ROOT^src" -// CHECK: "-fmodule-map-file=ROOT^src{{/|\\\\}}module.modulemap" -// CHECK: "-fmodule-file-cache-key" -// CHECK: "C-{{.*}}.pcm" -// CHECK: "llvmcas://{{.*}}" -// CHECK: "-x" -// CHECK-NEXT: "c" -// CHECK-NEXT: "ROOT^src{{/|\\\\}}t.c" -// CHECK: "-isysroot" -// CHECK-NEXT: "ROOT^sdk" -// CHECK: "-resource-dir" -// CHECK-NEXT: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}" -// CHECK: "-fmodule-file=C=C-{{.*}}.pcm" -// CHECK: "-isystem" -// CHECK-NEXT: "ROOT^sdk{{/|\\\\}}usr{{/|\\\\}}local{{/|\\\\}}include" -// CHECK: "-isystem" -// CHECK-NEXT: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}{{/|\\\\}}include" -// CHECK: "-internal-externc-isystem" -// CHECK-NEXT: "ROOT^sdk{{/|\\\\}}usr{{/|\\\\}}include" -// CHECK: "-include-pch" -// CHECK-NEXT: "ROOT^src{{/|\\\\}}prefix.h.pch" -// CHECK: ], -// CHECK: "file-deps": [ -// CHECK: "PREFIX{{/|\\\\}}t.c" -// CHECK: "PREFIX{{/|\\\\}}prefix.h.pch" -// CHECK: ] -// CHECK: "input-file": "PREFIX{{/|\\\\}}t.c" -// CHECK: } - -//--- cdb.json.template -[ - { - "directory": "DIR", - "command": "CLANG -fsyntax-only DIR/t.c -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/mcp -target x86_64-apple-macos11 -isysroot SDK -include DIR/prefix.h", - "file": "DIR/t.c" - } -] - -//--- cdb_pch.json.template -[ - { - "directory" : "DIR", - "command" : "CLANG -x c-header DIR/prefix.h -o DIR/prefix.h.pch -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/mcp -target x86_64-apple-macos11 -isysroot SDK", - "file" : "DIR/prefix.h" - }, -] - -//--- t.c -#include "c.h" - -//--- prefix.h -#include "a.h" - -//--- module.modulemap -module A { header "a.h" } -module B { header "b.h" } -module C { header "c.h" } - -//--- a.h -#include "b.h" - -//--- b.h -#include -#include - -//--- c.h -#include "b.h" diff --git a/clang/test/Index/Core/scan-deps-cas.m b/clang/test/Index/Core/scan-deps-cas.m index dfc302abd9e99..eb0e7142833b4 100644 --- a/clang/test/Index/Core/scan-deps-cas.m +++ b/clang/test/Index/Core/scan-deps-cas.m @@ -8,12 +8,6 @@ // RUN: -o FoE.o -x objective-c %s > %t.result // RUN: cat %t.result | FileCheck %s -DPREFIX=%S -DOUTPUTS=%/t -check-prefix=INCLUDE_TREE -// RUN: env CLANG_CACHE_USE_CASFS_DEPSCAN=1 c-index-test core --scan-deps -working-dir %S -output-dir=%t -cas-path %t/cas \ -// RUN: -- %clang -c -I %S/Inputs/module \ -// RUN: -fmodules -fmodules-cache-path=%t/mcp \ -// RUN: -o FoE.o -x objective-c %s > %t.casfs.result -// RUN: cat %t.casfs.result | FileCheck %s -DPREFIX=%S -DOUTPUTS=%/t - // RUN: env CLANG_CACHE_USE_INCLUDE_TREE=1 c-index-test core --scan-deps -working-dir %S -output-dir=%t -cas-path %t/cas \ // RUN: -- %clang -c -I %S/Inputs/module \ // RUN: -fmodules -fmodules-cache-path=%t/mcpit \ diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp index 89cfe72c8a117..b7019ae3d8a14 100644 --- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp +++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp @@ -22,7 +22,6 @@ #include "llvm/ADT/Twine.h" #include "llvm/CAS/ActionCache.h" #include "llvm/CAS/CASProvidingFileSystem.h" -#include "llvm/CAS/CachingOnDiskFileSystem.h" #include "llvm/CAS/ObjectStore.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileUtilities.h" @@ -106,7 +105,6 @@ static bool EmitVisibleModules; static llvm::BumpPtrAllocator Alloc; static llvm::StringSaver Saver{Alloc}; static std::vector CommandLine; -static bool EmitCASCompDB; static std::string OnDiskCASPath; static std::string CASPluginPath; static std::vector> CASPluginOptions; @@ -163,10 +161,10 @@ static void ParseArgs(int argc, char **argv) { llvm::StringSwitch>(A->getValue()) .Case("make", ScanningOutputFormat::Make) .Case("p1689", ScanningOutputFormat::P1689) - .Case("experimental-tree", ScanningOutputFormat::Tree) - .Case("experimental-tree-full", ScanningOutputFormat::FullTree) - .Case("experimental-include-tree", ScanningOutputFormat::IncludeTree) - .Case("experimental-include-tree-full", ScanningOutputFormat::FullIncludeTree) + .Case("experimental-include-tree", + ScanningOutputFormat::IncludeTree) + .Case("experimental-include-tree-full", + ScanningOutputFormat::FullIncludeTree) .Case("experimental-full", ScanningOutputFormat::Full) .Default(std::nullopt); if (!FormatType) { @@ -258,7 +256,6 @@ static void ParseArgs(int argc, char **argv) { EmitVisibleModules = Args.hasArg(OPT_emit_visible_modules); - EmitCASCompDB = Args.hasArg(OPT_emit_cas_compdb); InMemoryCAS = Args.hasArg(OPT_in_memory_cas); if (const llvm::opt::Arg *A = Args.getLastArg(OPT_cas_path_EQ)) @@ -367,154 +364,6 @@ class ResourceDirectoryCache { } // end anonymous namespace -static bool emitCompilationDBWithCASTreeArguments( - std::shared_ptr DB, - std::vector Inputs, - DiagnosticConsumer &DiagsConsumer, DependencyScanningService &Service, - llvm::DefaultThreadPool &Pool, llvm::raw_ostream &OS) { - - // Follow `-cc1depscan` and also ignore diagnostics. - // FIXME: Seems not a good idea to do this.. - auto IgnoringDiagsConsumer = std::make_unique(); - - struct PerThreadState { - DependencyScanningTool Worker; - llvm::BumpPtrAllocator Alloc; - llvm::StringSaver Saver; - PerThreadState(DependencyScanningService &Service, - std::unique_ptr FS) - : Worker(Service, std::move(FS)), Saver(Alloc) {} - }; - std::vector> PerThreadStates; - for (unsigned I = 0, E = Pool.getMaxConcurrency(); I != E; ++I) { - std::unique_ptr FS = - llvm::cas::createCASProvidingFileSystem( - DB, llvm::vfs::createPhysicalFileSystem()); - PerThreadStates.push_back( - std::make_unique(Service, std::move(FS))); - } - - std::atomic HadErrors(false); - std::mutex Lock; - size_t Index = 0; - - struct CompDBEntry { - size_t Index; - std::string Filename; - std::string WorkDir; - SmallVector Args; - }; - std::vector CompDBEntries; - - for (unsigned I = 0, E = Pool.getMaxConcurrency(); I != E; ++I) { - Pool.async([&, I]() { - while (true) { - const tooling::CompileCommand *Input; - std::string Filename; - std::string CWD; - size_t LocalIndex; - // Take the next input. - { - std::unique_lock LockGuard(Lock); - if (Index >= Inputs.size()) - return; - LocalIndex = Index; - Input = &Inputs[Index++]; - Filename = std::move(Input->Filename); - CWD = std::move(Input->Directory); - } - - tooling::dependencies::DependencyScanningTool &WorkerTool = - PerThreadStates[I]->Worker; - - class ScanForCC1Action : public ToolAction { - llvm::cas::ObjectStore &DB; - tooling::dependencies::DependencyScanningTool &WorkerTool; - DiagnosticConsumer &DiagsConsumer; - StringRef CWD; - SmallVectorImpl &OutputArgs; - llvm::StringSaver &Saver; - - public: - ScanForCC1Action( - llvm::cas::ObjectStore &DB, - tooling::dependencies::DependencyScanningTool &WorkerTool, - DiagnosticConsumer &DiagsConsumer, StringRef CWD, - SmallVectorImpl &OutputArgs, - llvm::StringSaver &Saver) - : DB(DB), WorkerTool(WorkerTool), DiagsConsumer(DiagsConsumer), - CWD(CWD), OutputArgs(OutputArgs), Saver(Saver) {} - - bool - runInvocation(std::shared_ptr Invocation, - FileManager *Files, - std::shared_ptr PCHContainerOps, - DiagnosticConsumer *DiagConsumer) override { - Expected Root = scanAndUpdateCC1InlineWithTool( - WorkerTool, DiagsConsumer, /*VerboseOS*/ nullptr, *Invocation, - CWD, DB); - if (!Root) { - llvm::consumeError(Root.takeError()); - return false; - } - OutputArgs.push_back("-cc1"); - Invocation->generateCC1CommandLine(OutputArgs, [&](const Twine &T) { - return Saver.save(T).data(); - }); - return true; - } - }; - - SmallVector OutputArgs; - llvm::StringSaver &Saver = PerThreadStates[I]->Saver; - OutputArgs.push_back(Saver.save(Input->CommandLine.front()).data()); - ScanForCC1Action Action(*DB, WorkerTool, *IgnoringDiagsConsumer, CWD, - OutputArgs, Saver); - - llvm::IntrusiveRefCntPtr FileMgr = - WorkerTool.getOrCreateFileManager(); - ToolInvocation Invocation(Input->CommandLine, &Action, FileMgr.get(), - std::make_shared()); - if (!Invocation.run()) { - HadErrors = true; - continue; - } - - { - std::unique_lock LockGuard(Lock); - CompDBEntries.push_back({LocalIndex, std::move(Filename), - std::move(CWD), std::move(OutputArgs)}); - } - } - }); - } - Pool.wait(); - - std::sort(CompDBEntries.begin(), CompDBEntries.end(), - [](const CompDBEntry &LHS, const CompDBEntry &RHS) -> bool { - return LHS.Index < RHS.Index; - }); - - llvm::json::OStream J(OS, /*IndentSize*/ 2); - J.arrayBegin(); - for (const auto &Entry : CompDBEntries) { - J.objectBegin(); - J.attribute("file", Entry.Filename); - J.attribute("directory", Entry.WorkDir); - J.attributeBegin("arguments"); - J.arrayBegin(); - for (const char *Arg : Entry.Args) { - J.value(Arg); - } - J.arrayEnd(); - J.attributeEnd(); - J.objectEnd(); - } - J.arrayEnd(); - - return HadErrors; -} - /// Takes the result of a dependency scan and prints error / dependency files /// based on the result. /// @@ -537,25 +386,6 @@ handleMakeDependencyToolResult(const std::string &Input, return false; } -static bool handleTreeDependencyToolResult( - llvm::cas::ObjectStore &CAS, const std::string &Input, - llvm::Expected &MaybeTree, llvm::raw_ostream &OS, - SharedStream &Errs) { - if (!MaybeTree) { - llvm::handleAllErrors( - MaybeTree.takeError(), [&Input, &Errs](llvm::StringError &Err) { - Errs.applyLocked([&](raw_ostream &OS) { - OS << "Error while scanning dependencies for " << Input << ":\n"; - OS << Err.getMessage(); - OS << "\n"; - }); - }); - return true; - } - OS << "tree " << MaybeTree->getID() << " for '" << Input << "'\n"; - return false; -} - static bool handleIncludeTreeToolResult(llvm::cas::ObjectStore &CAS, const std::string &Input, @@ -592,13 +422,11 @@ handleIncludeTreeToolResult(llvm::cas::ObjectStore &CAS, static bool outputFormatRequiresCAS() { switch (Format) { - case ScanningOutputFormat::Tree: - case ScanningOutputFormat::FullTree: - case ScanningOutputFormat::IncludeTree: - case ScanningOutputFormat::FullIncludeTree: - return true; - default: - return false; + case ScanningOutputFormat::IncludeTree: + case ScanningOutputFormat::FullIncludeTree: + return true; + default: + return false; } } @@ -665,7 +493,6 @@ class FullDeps { ID.FileName = std::string(Input); ID.ContextHash = std::move(TUDeps.ID.ContextHash); ID.FileDeps = std::move(TUDeps.FileDeps); - ID.CASFileSystemRootID = std::move(TUDeps.CASFileSystemRootID); ID.IncludeTreeID = std::move(TUDeps.IncludeTreeID); ID.NamedModule = std::move(TUDeps.ID.ModuleName); ID.NamedModuleDeps = std::move(TUDeps.NamedModuleDeps); @@ -756,9 +583,6 @@ class FullDeps { if (MD.IncludeTreeID) JOS.attribute("cas-include-tree-id", StringRef(*MD.IncludeTreeID)); - if (MD.CASFileSystemRootID) - JOS.attribute("casfs-root-id", - StringRef(*MD.CASFileSystemRootID)); if (MD.IsInStableDirectories) JOS.attribute("is-in-stable-directories", @@ -797,9 +621,6 @@ class FullDeps { if (I.IncludeTreeID) JOS.attribute("cas-include-tree-id", StringRef(*I.IncludeTreeID)); - if (I.CASFileSystemRootID) - JOS.attribute("casfs-root-id", - StringRef(*I.CASFileSystemRootID)); JOS.attribute("clang-context-hash", StringRef(I.ContextHash)); @@ -825,9 +646,6 @@ class FullDeps { } } else { JOS.object([&] { - if (I.CASFileSystemRootID) - JOS.attribute("casfs-root-id", - StringRef(*I.CASFileSystemRootID)); if (I.IncludeTreeID) JOS.attribute("cas-include-tree-id", StringRef(*I.IncludeTreeID)); @@ -899,7 +717,6 @@ class FullDeps { std::string FileName; std::string ContextHash; std::vector FileDeps; - std::optional CASFileSystemRootID; std::optional IncludeTreeID; std::string NamedModule; std::vector NamedModuleDeps; @@ -1203,9 +1020,6 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) { auto ArgsAdjuster = [&ResourceDirCache](const tooling::CommandLineArguments &Args, StringRef FileName) { - if (EmitCASCompDB) - return Args; // Don't adjust. - std::string LastO; bool HasResourceDir = false; bool ClangCLMode = false; @@ -1312,7 +1126,6 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) { std::shared_ptr CAS; std::shared_ptr Cache; - IntrusiveRefCntPtr FS; if (useCAS()) { if (!InMemoryCAS) CASOpts.ensurePersistentCAS(); @@ -1320,21 +1133,6 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) { std::tie(CAS, Cache) = CASOpts.getOrCreateDatabases(Diags); if (!CAS) return 1; - if (Format != ScanningOutputFormat::IncludeTree && Format != ScanningOutputFormat::FullIncludeTree) - FS = llvm::cantFail(llvm::cas::createCachingOnDiskFileSystem(*CAS)); - } - - if (EmitCASCompDB) { - if (!CAS) { - llvm::errs() << "'-emit-cas-compdb' needs CAS setup\n"; - return 1; - } - DependencyScanningService Service(ScanMode, Format, CASOpts, CAS, Cache, FS, - OptimizeArgs, EagerLoadModules); - llvm::DefaultThreadPool Pool(llvm::hardware_concurrency(NumThreads)); - return emitCompilationDBWithCASTreeArguments( - CAS, AdjustingCompilations->getAllCompileCommands(), *DiagsConsumer, - Service, Pool, llvm::outs()); } std::vector Inputs = @@ -1354,7 +1152,6 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) { }; if (Format == ScanningOutputFormat::Full || - Format == ScanningOutputFormat::FullTree || Format == ScanningOutputFormat::FullIncludeTree) FD.emplace(!ModuleNames ? Inputs.size() : 0); @@ -1375,10 +1172,6 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) { }; SmallVector TreeResults; - if (Format == ScanningOutputFormat::Full || - Format == ScanningOutputFormat::FullTree) - FD.emplace(!ModuleNames ? Inputs.size() : 0); - std::atomic NumStatusCalls = 0; std::atomic NumOpenFileForReadCalls = 0; std::atomic NumDirBeginCalls = 0; @@ -1412,11 +1205,6 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) { if (handleMakeDependencyToolResult(Filename, MaybeFile, DependencyOS, Errs)) HadErrors = true; - } else if (Format == ScanningOutputFormat::Tree) { - auto MaybeTree = WorkerTool.getDependencyTree(Input->CommandLine, CWD); - std::unique_lock LockGuard(Lock); - TreeResults.emplace_back(LocalIndex, std::move(Filename), - std::move(MaybeTree)); } else if (Format == ScanningOutputFormat::IncludeTree) { auto MaybeTree = WorkerTool.getIncludeTree( *CAS, Input->CommandLine, CWD, LookupOutput); @@ -1545,7 +1333,7 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) { }; DependencyScanningService Service( - ScanMode, Format, CASOpts, CAS, Cache, FS, OptimizeArgs, EagerLoadModules, + ScanMode, Format, CASOpts, CAS, Cache, OptimizeArgs, EagerLoadModules, /*TraceVFS=*/Verbose, llvm::sys::toTimeT(std::chrono::system_clock::now()), CacheNegativeStats); @@ -1597,14 +1385,7 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) { [](const DepTreeResult &LHS, const DepTreeResult &RHS) -> bool { return LHS.Index < RHS.Index; }); - if (Format == ScanningOutputFormat::Tree) { - for (auto &TreeResult : TreeResults) { - if (handleTreeDependencyToolResult(*CAS, TreeResult.Filename, - *TreeResult.MaybeTree, - ThreadUnsafeDependencyOS, Errs)) - HadErrors = true; - } - } else if (Format == ScanningOutputFormat::IncludeTree) { + if (Format == ScanningOutputFormat::IncludeTree) { for (auto &TreeResult : TreeResults) { if (handleIncludeTreeToolResult(*CAS, TreeResult.Filename, *TreeResult.MaybeIncludeTree, @@ -1612,7 +1393,6 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) { HadErrors = true; } } else if (Format == ScanningOutputFormat::Full || - Format == ScanningOutputFormat::FullTree || Format == ScanningOutputFormat::FullIncludeTree) { FD->printFullOutput(ThreadUnsafeDependencyOS); } else if (Format == ScanningOutputFormat::P1689) diff --git a/clang/tools/clang-scan-deps/Opts.td b/clang/tools/clang-scan-deps/Opts.td index 26f3a9949e9f0..da9535d6e8406 100644 --- a/clang/tools/clang-scan-deps/Opts.td +++ b/clang/tools/clang-scan-deps/Opts.td @@ -38,8 +38,6 @@ def deprecated_driver_command : F<"deprecated-driver-command", "use a single dri defm resource_dir_recipe : Eq<"resource-dir-recipe", "How to produce missing '-resource-dir' argument">; -def emit_cas_compdb : F<"emit-cas-compdb", "Emit compilation DB with updated clang arguments for CAS based dependency scanning build.">; - defm cas_path : Eq<"cas-path", "Path for on-disk CAS.">; defm fcas_plugin_path : Eq<"fcas-plugin-path", "Path to a shared library implementing the LLVM CAS plugin API">; diff --git a/clang/tools/driver/CacheLauncherMode.cpp b/clang/tools/driver/CacheLauncherMode.cpp index aa66c80a1a093..302937b10b7ef 100644 --- a/clang/tools/driver/CacheLauncherMode.cpp +++ b/clang/tools/driver/CacheLauncherMode.cpp @@ -94,9 +94,6 @@ static int executeAsProcess(ArrayRef Args, /// functionalities. static void addCommonArgs(bool ForDriver, SmallVectorImpl &Args, llvm::StringSaver &Saver) { - if (!llvm::sys::Process::GetEnv("CLANG_CACHE_USE_CASFS_DEPSCAN")) { - Args.push_back("-fdepscan-include-tree"); - } auto addCC1Args = [&](ArrayRef NewArgs) { for (const char *Arg : NewArgs) { if (ForDriver) { diff --git a/clang/tools/driver/cc1depscan_main.cpp b/clang/tools/driver/cc1depscan_main.cpp index 79a461f81f833..404820243dad2 100644 --- a/clang/tools/driver/cc1depscan_main.cpp +++ b/clang/tools/driver/cc1depscan_main.cpp @@ -32,7 +32,6 @@ #include "llvm/CAS/ActionCache.h" #include "llvm/CAS/BuiltinUnifiedCASDatabases.h" #include "llvm/CAS/CASProvidingFileSystem.h" -#include "llvm/CAS/CachingOnDiskFileSystem.h" #include "llvm/CAS/HierarchicalTreeBuilder.h" #include "llvm/CAS/ObjectStore.h" #include "llvm/Option/ArgList.h" @@ -364,7 +363,6 @@ static int scanAndUpdateCC1Inline(const char *Exec, ArrayRef InputArgs, StringRef WorkingDirectory, SmallVectorImpl &OutputArgs, - bool ProduceIncludeTree, llvm::function_ref SaveArg, const CASOptions &CASOpts, DiagnosticsEngine &Diag, std::optional &RootID); @@ -522,13 +520,10 @@ static int scanAndUpdateCC1(const char *Exec, ArrayRef OldArgs, } #endif // LLVM_ON_UNIX - bool ProduceIncludeTree = Args.hasArg(options::OPT_fdepscan_include_tree); auto SaveArg = [&Args](const Twine &T) { return Args.MakeArgString(T); }; #ifdef LLVM_ON_UNIX CompilerInvocation::GenerateCASArgs(CASOpts, Sharing.CASArgs, SaveArg); - if (ProduceIncludeTree) - Sharing.CASArgs.push_back("-fdepscan-include-tree"); if (auto DaemonPath = makeDepscanDaemonPath(Mode, Sharing)) return scanAndUpdateCC1UsingDaemon(Exec, OldArgs, WorkingDirectory, NewArgs, @@ -537,8 +532,7 @@ static int scanAndUpdateCC1(const char *Exec, ArrayRef OldArgs, #endif // LLVM_ON_UNIX return scanAndUpdateCC1Inline(Exec, OldArgs, WorkingDirectory, NewArgs, - ProduceIncludeTree, SaveArg, CASOpts, Diag, - RootID); + SaveArg, CASOpts, Diag, RootID); } int cc1depscan_main(ArrayRef Argv, const char *Argv0, @@ -641,7 +635,6 @@ struct ScanServer { const char *Argv0 = nullptr; SmallString<128> BasePath; CASOptions CASOpts; - bool ProduceIncludeTree = true; int PidFD = -1; int ListenSocket = -1; /// \p std::nullopt means it runs indefinitely. @@ -832,8 +825,6 @@ void ScanServer::start(bool Exclusive, ArrayRef CASArgs) { Opts.ParseArgs(CASArgs, MissingArgIndex, MissingArgCount); CompilerInvocation::ParseCASArgs(CASOpts, ParsedCASArgs, Diags); CASOpts.ensurePersistentCAS(); - ProduceIncludeTree = - ParsedCASArgs.hasArg(clang::options::OPT_fdepscan_include_tree); static std::once_flag ValidateOnce; std::call_once(ValidateOnce, [&] { @@ -903,15 +894,10 @@ int ScanServer::listen() { if (!Cache) reportError("cannot create ActionCache"); - IntrusiveRefCntPtr FS; - if (!ProduceIncludeTree) - FS = llvm::cantFail(llvm::cas::createCachingOnDiskFileSystem(*CAS)); tooling::dependencies::DependencyScanningService Service( tooling::dependencies::ScanningMode::DependencyDirectivesScan, - ProduceIncludeTree - ? tooling::dependencies::ScanningOutputFormat::IncludeTree - : tooling::dependencies::ScanningOutputFormat::Tree, - CASOpts, CAS, Cache, FS); + tooling::dependencies::ScanningOutputFormat::IncludeTree, CASOpts, CAS, + Cache); std::atomic NumRunning(0); @@ -990,18 +976,13 @@ int ScanServer::listen() { OS << "\n"; }; - bool ProduceIncludeTree = - Service.getFormat() == - tooling::dependencies::ScanningOutputFormat::IncludeTree; - // Is this safe to reuse? Or does DependendencyScanningWorkerFileSystem // make some bad assumptions about relative paths? if (!Tool) { llvm::IntrusiveRefCntPtr UnderlyingFS = llvm::vfs::createPhysicalFileSystem(); - if (ProduceIncludeTree) - UnderlyingFS = llvm::cas::createCASProvidingFileSystem( - CAS, std::move(UnderlyingFS)); + UnderlyingFS = llvm::cas::createCASProvidingFileSystem( + CAS, std::move(UnderlyingFS)); Tool.emplace(Service, std::move(UnderlyingFS)); } @@ -1125,7 +1106,6 @@ static int scanAndUpdateCC1Inline(const char *Exec, ArrayRef InputArgs, StringRef WorkingDirectory, SmallVectorImpl &OutputArgs, - bool ProduceIncludeTree, llvm::function_ref SaveArg, const CASOptions &CASOpts, DiagnosticsEngine &Diag, std::optional &RootID) { @@ -1133,21 +1113,14 @@ scanAndUpdateCC1Inline(const char *Exec, ArrayRef InputArgs, if (!DB || !Cache) return 1; - IntrusiveRefCntPtr FS; - if (!ProduceIncludeTree) - FS = llvm::cantFail(llvm::cas::createCachingOnDiskFileSystem(*DB)); - tooling::dependencies::DependencyScanningService Service( tooling::dependencies::ScanningMode::DependencyDirectivesScan, - ProduceIncludeTree - ? tooling::dependencies::ScanningOutputFormat::IncludeTree - : tooling::dependencies::ScanningOutputFormat::Tree, - CASOpts, DB, Cache, FS); + tooling::dependencies::ScanningOutputFormat::IncludeTree, CASOpts, DB, + Cache); llvm::IntrusiveRefCntPtr UnderlyingFS = llvm::vfs::createPhysicalFileSystem(); - if (ProduceIncludeTree) - UnderlyingFS = - llvm::cas::createCASProvidingFileSystem(DB, std::move(UnderlyingFS)); + UnderlyingFS = + llvm::cas::createCASProvidingFileSystem(DB, std::move(UnderlyingFS)); tooling::dependencies::DependencyScanningTool Tool(Service, std::move(UnderlyingFS)); diff --git a/clang/tools/libclang/CDependencies.cpp b/clang/tools/libclang/CDependencies.cpp index d03216af9fdc7..337c5296921c9 100644 --- a/clang/tools/libclang/CDependencies.cpp +++ b/clang/tools/libclang/CDependencies.cpp @@ -25,7 +25,6 @@ #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h" #include "llvm/ADT/STLExtras.h" #include "llvm/CAS/CASProvidingFileSystem.h" -#include "llvm/CAS/CachingOnDiskFileSystem.h" #include "llvm/Support/Process.h" using namespace clang; @@ -169,12 +168,11 @@ void clang_experimental_DependencyScannerServiceOptions_setCacheNegativeStats( CXDependencyScannerService clang_experimental_DependencyScannerService_create_v0(CXDependencyMode Format) { - // FIXME: Pass default CASOpts and nullptr as CachingOnDiskFileSystem now. + // FIXME: Pass default CASOpts now. CASOptions CASOpts; - IntrusiveRefCntPtr FS; return wrap(new DependencyScanningService( ScanningMode::DependencyDirectivesScan, unwrap(Format), CASOpts, - /*CAS=*/nullptr, /*ActionCache=*/nullptr, FS)); + /*CAS=*/nullptr, /*ActionCache=*/nullptr)); } ScanningOutputFormat DependencyScannerServiceOptions::getFormat() const { @@ -184,36 +182,18 @@ ScanningOutputFormat DependencyScannerServiceOptions::getFormat() const { if (!CAS || !Cache) return ConfiguredFormat; - if (llvm::sys::Process::GetEnv("CLANG_CACHE_USE_INCLUDE_TREE")) - return ScanningOutputFormat::FullIncludeTree; - - if (llvm::sys::Process::GetEnv("CLANG_CACHE_USE_CASFS_DEPSCAN")) - return ScanningOutputFormat::FullTree; - - // Use include-tree by default. return ScanningOutputFormat::FullIncludeTree; } CXDependencyScannerService clang_experimental_DependencyScannerService_create_v1( CXDependencyScannerServiceOptions Opts) { - // FIXME: Pass default CASOpts and nullptr as CachingOnDiskFileSystem now. + // FIXME: Pass default CASOpts now. std::shared_ptr CAS = unwrap(Opts)->CAS; std::shared_ptr Cache = unwrap(Opts)->Cache; - IntrusiveRefCntPtr FS; - ScanningOutputFormat Format = unwrap(Opts)->getFormat(); - bool IsCASFSOutput = Format == ScanningOutputFormat::Tree || - Format == ScanningOutputFormat::FullTree; - if (CAS && Cache && IsCASFSOutput) { - assert(unwrap(Opts)->CASOpts.getKind() != CASOptions::UnknownCAS && - "CAS and ActionCache must match CASOptions"); - FS = llvm::cantFail( - llvm::cas::createCachingOnDiskFileSystem(CAS)); - } return wrap(new DependencyScanningService( - ScanningMode::DependencyDirectivesScan, Format, unwrap(Opts)->CASOpts, - std::move(CAS), std::move(Cache), std::move(FS), - unwrap(Opts)->OptimizeArgs, /*EagerLoadModules=*/false, + ScanningMode::DependencyDirectivesScan, unwrap(Opts)->getFormat(), unwrap(Opts)->CASOpts, + std::move(CAS), std::move(Cache), unwrap(Opts)->OptimizeArgs, /*EagerLoadModules=*/false, /*TraceVFS=*/false, llvm::sys::toTimeT(std::chrono::system_clock::now()), unwrap(Opts)->CacheNegativeStats ? *unwrap(Opts)->CacheNegativeStats : shouldCacheNegativeStatsDefault())); @@ -360,7 +340,6 @@ enum CXErrorCode clang_experimental_DependencyScannerWorker_getDepGraph( DependencyScanningWorker *Worker = unwrap(W); if (Worker->getScanningFormat() != ScanningOutputFormat::Full && - Worker->getScanningFormat() != ScanningOutputFormat::FullTree && Worker->getScanningFormat() != ScanningOutputFormat::FullIncludeTree) return CXError_InvalidArguments; @@ -474,9 +453,6 @@ clang_experimental_DepGraphModule_getBuildArguments(CXDepGraphModule CXDepMod) { const char *clang_experimental_DepGraphModule_getFileSystemRootID( CXDepGraphModule CXDepMod) { - const ModuleDeps &ModDeps = *unwrap(CXDepMod)->ModDeps; - if (ModDeps.CASFileSystemRootID) - return ModDeps.CASFileSystemRootID->c_str(); return nullptr; } @@ -551,9 +527,6 @@ CXCStringArray clang_experimental_DepGraph_getTUModuleDeps(CXDepGraph Graph) { const char * clang_experimental_DepGraph_getTUFileSystemRootID(CXDepGraph Graph) { - TranslationUnitDeps &TUDeps = unwrap(Graph)->TUDeps; - if (TUDeps.CASFileSystemRootID) - return TUDeps.CASFileSystemRootID->c_str(); return nullptr; } @@ -641,11 +614,6 @@ clang_experimental_DependencyScannerService_getFSCacheOutOfDateEntrySet( CXDependencyScannerService S) { DependencyScanningService &Service = *unwrap(S); - // FIXME: CAS FS currently does not use the shared cache, and cannot produce - // the same diagnostics. We should add such a diagnostics to CAS as well. - if (Service.useCASFS()) - return nullptr; - // Note that it is critical that this FS is the same as the default virtual // file system we pass to the DependencyScanningWorkers. llvm::IntrusiveRefCntPtr FS = @@ -802,10 +770,9 @@ enum CXErrorCode clang_experimental_DependencyScanner_generateReproducer( << "non-unique reproducer is allowed only in a custom location"; CASOptions CASOpts; - IntrusiveRefCntPtr FS; DependencyScanningService DepsService( ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::Full, - CASOpts, /*CAS=*/nullptr, /*ActionCache=*/nullptr, FS); + CASOpts, /*CAS=*/nullptr, /*ActionCache=*/nullptr); DependencyScanningTool DepsTool(DepsService); llvm::SmallString<128> ReproScriptPath; diff --git a/clang/unittests/CAS/IncludeTreeTest.cpp b/clang/unittests/CAS/IncludeTreeTest.cpp index 677f7a5c621d4..382a6a092815a 100644 --- a/clang/unittests/CAS/IncludeTreeTest.cpp +++ b/clang/unittests/CAS/IncludeTreeTest.cpp @@ -2,7 +2,6 @@ #include "clang/Tooling/DependencyScanning/DependencyScanningTool.h" #include "clang/Tooling/DependencyScanning/ScanAndUpdateArgs.h" #include "llvm/CAS/CASProvidingFileSystem.h" -#include "llvm/CAS/CachingOnDiskFileSystem.h" #include "llvm/CAS/ObjectStore.h" #include "llvm/Support/Error.h" #include "llvm/Support/VirtualFileSystem.h" @@ -52,7 +51,7 @@ TEST(IncludeTree, IncludeTreeScan) { DependencyScanningService Service(ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::IncludeTree, - CASOptions(), nullptr, nullptr, nullptr); + CASOptions(), nullptr, nullptr); DependencyScanningTool ScanTool(Service, std::move(VFS)); std::vector CommandLine = {"clang", diff --git a/clang/unittests/Tooling/CMakeLists.txt b/clang/unittests/Tooling/CMakeLists.txt index 2bf67cdd01186..51ca7f03a2615 100644 --- a/clang/unittests/Tooling/CMakeLists.txt +++ b/clang/unittests/Tooling/CMakeLists.txt @@ -4,7 +4,6 @@ add_clang_unittest(ToolingTests CastExprTest.cpp CommentHandlerTest.cpp CompilationDatabaseTest.cpp - DependencyScanningCASFilesystemTest.cpp DiagnosticsYamlTest.cpp ExecutionTest.cpp FixItTest.cpp diff --git a/clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp b/clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp index 47ba779ab69d2..8c54210e4ba7a 100644 --- a/clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp +++ b/clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp @@ -18,8 +18,8 @@ #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h" #include "clang/Tooling/Tooling.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/CAS/CASFileSystem.h" #include "llvm/CAS/CASProvidingFileSystem.h" -#include "llvm/CAS/CachingOnDiskFileSystem.h" #include "llvm/CAS/ObjectStore.h" #include "llvm/MC/TargetRegistry.h" #include "llvm/Support/FormatVariadic.h" @@ -237,7 +237,7 @@ TEST(DependencyScanner, ScanDepsWithFS) { DependencyScanningService Service(ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::Make, CASOptions(), - nullptr, nullptr, nullptr); + nullptr, nullptr); DependencyScanningTool ScanTool(Service, VFS); std::string DepFile; @@ -261,7 +261,7 @@ TEST(DependencyScanner, DepScanFSWithCASProvider) { DependencyScanningService Service(ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::Make, CASOptions(), - nullptr, nullptr, nullptr); + nullptr, nullptr); { DependencyScanningWorkerFilesystem DepFS(Service, std::move(CASFS)); llvm::ErrorOr> File = @@ -349,7 +349,7 @@ TEST(DependencyScanner, ScanDepsWithModuleLookup) { DependencyScanningService Service(ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::Make, CASOptions(), - nullptr, nullptr, nullptr); + nullptr, nullptr); DependencyScanningTool ScanTool(Service, InterceptFS); // This will fail with "fatal error: module 'Foo' not found" but it doesn't @@ -382,7 +382,7 @@ TEST(DependencyScanner, ScanDepsWithDiagConsumer) { DependencyScanningService Service(ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::Make, CASOptions(), - nullptr, nullptr, nullptr); + nullptr, nullptr); DependencyScanningWorker Worker(Service, VFS); llvm::DenseSet AlreadySeen; @@ -467,7 +467,7 @@ TEST(DependencyScanner, NoNegativeCache) { DependencyScanningService Service( ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::Make, - CASOptions(), nullptr, nullptr, nullptr, ScanningOptimizations::All, + CASOptions(), nullptr, nullptr, ScanningOptimizations::All, /*EagerLoadModules=*/false, /*TraceVFS=*/false, llvm::sys::toTimeT(std::chrono::system_clock::now()), /*CacheNegativeStats=*/false); @@ -526,7 +526,7 @@ TEST(DependencyScanner, NoNegativeCacheCAS) { DependencyScanningService Service( ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::FullIncludeTree, - CASOptions(), DB, Cache, nullptr, ScanningOptimizations::Default, + CASOptions(), DB, Cache, ScanningOptimizations::Default, /*EagerLoadModules=*/false, /*TraceVFS=*/false, llvm::sys::toTimeT(std::chrono::system_clock::now()), /*CacheNegativeStats=*/false); diff --git a/clang/unittests/Tooling/DependencyScanning/DependencyScanningFilesystemTest.cpp b/clang/unittests/Tooling/DependencyScanning/DependencyScanningFilesystemTest.cpp index 52bf06d6d5a18..ab0eaa7131634 100644 --- a/clang/unittests/Tooling/DependencyScanning/DependencyScanningFilesystemTest.cpp +++ b/clang/unittests/Tooling/DependencyScanning/DependencyScanningFilesystemTest.cpp @@ -9,7 +9,6 @@ #include "clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h" #include "clang/Tooling/DependencyScanning/DependencyScanningService.h" #include "clang/CAS/CASOptions.h" -#include "llvm/CAS/CachingOnDiskFileSystem.h" #include "llvm/ADT/SmallString.h" #include "llvm/CAS/CachingOnDiskFileSystem.h" #include "llvm/Support/VirtualFileSystem.h" @@ -25,7 +24,7 @@ TEST(DependencyScanningWorkerFilesystem, CacheStatusFailures) { DependencyScanningService Service( ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::Make, - clang::CASOptions(), nullptr, nullptr, nullptr, + clang::CASOptions(), nullptr, nullptr, ScanningOptimizations::Default, /*EagerLoadModules=*/false, /*TraceVFS=*/false, llvm::sys::toTimeT(std::chrono::system_clock::now()), /*CacheNegativeStats=*/true); @@ -56,7 +55,7 @@ TEST(DependencyScanningFilesystem, CacheGetRealPath) { DependencyScanningService Service( ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::Make, - clang::CASOptions(), nullptr, nullptr, nullptr, + clang::CASOptions(), nullptr, nullptr, ScanningOptimizations::Default, /*EagerLoadModules=*/false, /*TraceVFS=*/false, llvm::sys::toTimeT(std::chrono::system_clock::now()), /*CacheNegativeStats=*/true); @@ -96,7 +95,7 @@ TEST(DependencyScanningFilesystem, RealPathAndStatusInvariants) { DependencyScanningService Service( ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::Make, - clang::CASOptions(), nullptr, nullptr, nullptr); + clang::CASOptions(), nullptr, nullptr); DependencyScanningWorkerFilesystem DepFS(Service, InMemoryFS); // Success. @@ -151,7 +150,7 @@ TEST(DependencyScanningFilesystem, CacheStatOnExists) { InMemoryFS->addFile("/bar", 0, llvm::MemoryBuffer::getMemBuffer("")); DependencyScanningService Service( ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::Make, - clang::CASOptions(), nullptr, nullptr, nullptr, + clang::CASOptions(), nullptr, nullptr, ScanningOptimizations::Default, /*EagerLoadModules=*/false, /*TraceVFS=*/false, llvm::sys::toTimeT(std::chrono::system_clock::now()), /*CacheNegativeStats=*/true); @@ -179,7 +178,7 @@ TEST(DependencyScanningFilesystem, CacheStatFailures) { DependencyScanningService Service( ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::Make, - clang::CASOptions(), nullptr, nullptr, nullptr, + clang::CASOptions(), nullptr, nullptr, ScanningOptimizations::Default, /*EagerLoadModules=*/false, /*TraceVFS=*/false, llvm::sys::toTimeT(std::chrono::system_clock::now()), /*CacheNegativeStats=*/true); @@ -211,7 +210,7 @@ TEST(DependencyScanningFilesystem, DiagnoseStaleStatFailures) { DependencyScanningService Service( ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::Make, - clang::CASOptions(), nullptr, nullptr, nullptr, + clang::CASOptions(), nullptr, nullptr, ScanningOptimizations::Default, /*EagerLoadModules=*/false, /*TraceVFS=*/false, llvm::sys::toTimeT(std::chrono::system_clock::now()), /*CacheNegativeStats=*/true); @@ -242,7 +241,7 @@ TEST(DependencyScanningFilesystem, DiagnoseCachedFileSizeChange) { DependencyScanningService Service( ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::Make, - clang::CASOptions(), nullptr, nullptr, nullptr, + clang::CASOptions(), nullptr, nullptr, ScanningOptimizations::Default, /*EagerLoadModules=*/false, /*TraceVFS=*/false, llvm::sys::toTimeT(std::chrono::system_clock::now()), /*CacheNegativeStats=*/true); @@ -281,7 +280,7 @@ TEST(DependencyScanningFilesystem, DoNotDiagnoseDirSizeChange) { DependencyScanningService Service( ScanningMode::DependencyDirectivesScan, ScanningOutputFormat::Make, - clang::CASOptions(), nullptr, nullptr, nullptr); + clang::CASOptions(), nullptr, nullptr); DependencyScanningWorkerFilesystem DepFS(Service, FS); // Trigger the file system cache. diff --git a/clang/unittests/Tooling/DependencyScanningCASFilesystemTest.cpp b/clang/unittests/Tooling/DependencyScanningCASFilesystemTest.cpp deleted file mode 100644 index ec585d2a31564..0000000000000 --- a/clang/unittests/Tooling/DependencyScanningCASFilesystemTest.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===- unittest/Tooling/DependencyScanningCASFilesystemTest.cpp -----------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "clang/Tooling/DependencyScanning/DependencyScanningCASFilesystem.h" -#include "clang/Tooling/DependencyScanning/DependencyScanningService.h" -#include "llvm/CAS/ActionCache.h" -#include "llvm/CAS/CachingOnDiskFileSystem.h" -#include "llvm/CAS/ObjectStore.h" -#include "llvm/Testing/Support/SupportHelpers.h" -#include "gtest/gtest.h" - -using namespace clang; -using namespace clang::cas; -using namespace clang::cas; -using namespace clang::tooling::dependencies; -using llvm::unittest::TempDir; -using llvm::unittest::TempFile; -using llvm::unittest::TempLink; - -TEST(DependencyScanningCASFilesystem, FilenameSpelling) { - TempDir TestDir("DependencyScanningCASFilesystemTest", /*Unique=*/true); - TempFile TestFile(TestDir.path("File.h"), "", "#define FOO\n"); -#ifndef _WIN32 - TempLink TestLink("File.h", TestDir.path("SymFile.h")); -#else - // As the create_link uses a hard link on Windows, the full path is - // required for the link target. - TempLink TestLink(TestDir.path("File.h"), TestDir.path("SymFile.h")); -#endif - - std::shared_ptr CAS = llvm::cas::createInMemoryCAS(); - std::shared_ptr Cache = llvm::cas::createInMemoryActionCache(); - auto CacheFS = llvm::cantFail(llvm::cas::createCachingOnDiskFileSystem(*CAS)); - DependencyScanningService Service(ScanningMode::DependencyDirectivesScan, - ScanningOutputFormat::Make, - clang::CASOptions(), CAS, Cache, nullptr); - DependencyScanningCASFilesystem FS(Service, CacheFS); - - EXPECT_EQ(FS.status(TestFile.path()).getError(), std::error_code()); - auto Directives = FS.getDirectiveTokens(TestFile.path()); - ASSERT_TRUE(Directives); - EXPECT_EQ(Directives->size(), 2u); - auto DirectivesDots = FS.getDirectiveTokens(TestDir.path("././File.h")); - ASSERT_TRUE(DirectivesDots); - EXPECT_EQ(DirectivesDots->size(), 2u); - auto DirectivesSymlink = FS.getDirectiveTokens(TestLink.path()); - ASSERT_TRUE(DirectivesSymlink); - EXPECT_EQ(DirectivesSymlink->size(), 2u); -} - -TEST(DependencyScanningCASFilesystem, DirectiveScanFailure) { - TempDir TestDir("DependencyScanningCASFilesystemTest", /*Unique=*/true); - TempFile TestFile(TestDir.path("python"), "", "import sys\n"); - - std::shared_ptr CAS = llvm::cas::createInMemoryCAS(); - std::shared_ptr Cache = llvm::cas::createInMemoryActionCache(); - auto CacheFS = llvm::cantFail(llvm::cas::createCachingOnDiskFileSystem(*CAS)); - DependencyScanningService Service(ScanningMode::DependencyDirectivesScan, - ScanningOutputFormat::Make, - clang::CASOptions(), CAS, Cache, nullptr); - DependencyScanningCASFilesystem FS(Service, CacheFS); - - EXPECT_EQ(FS.status(TestFile.path()).getError(), std::error_code()); - auto Directives = FS.getDirectiveTokens(TestFile.path()); - ASSERT_FALSE(Directives); - - // Check the cached failure in the action cache. - { - DependencyScanningCASFilesystem NewFS(Service, CacheFS); - EXPECT_EQ(NewFS.status(TestFile.path()).getError(), std::error_code()); - auto Directives = NewFS.getDirectiveTokens(TestFile.path()); - ASSERT_FALSE(Directives); - } -}