From a78ee29692ec88f8c34cb0485760243070c1df3f Mon Sep 17 00:00:00 2001 From: Artem Chikin Date: Tue, 3 Jun 2025 16:34:43 -0700 Subject: [PATCH] [Dependency Scanning] Remove obsolete placeholder module concept This was used a long time ago for a design of a scanner which could rely on the client to specify that some modules *will be* present at a given location but are not yet during the scan. We have long ago determined that the scanner must have all modules available to it at the time of scan for soundness. This code has been stale for a couple of years and it is time to simplify things a bit by deleting it. --- .../swift-c/DependencyScan/DependencyScan.h | 4 +- include/swift/AST/DiagnosticsFrontend.def | 8 -- include/swift/AST/ModuleDependencies.h | 77 +-------------- .../swift/DependencyScan/DependencyScanImpl.h | 15 --- .../DependencyScan/DependencyScanningTool.h | 4 +- .../SerializedModuleDependencyCacheFormat.h | 11 +-- include/swift/Option/FrontendOptions.td | 4 - include/swift/Serialization/ScanningLoaders.h | 45 --------- lib/AST/ModuleDependencies.cpp | 19 +--- lib/AST/ModuleLoader.cpp | 3 - lib/DependencyScan/DependencyScanJSON.cpp | 37 +------ lib/DependencyScan/DependencyScanningTool.cpp | 1 - .../ModuleDependencyCacheSerialization.cpp | 55 ----------- .../ModuleDependencyScanner.cpp | 13 +-- lib/DependencyScan/ScanDependencies.cpp | 37 ------- lib/Driver/Driver.cpp | 7 -- lib/Frontend/CompilerInvocation.cpp | 2 - lib/Frontend/Frontend.cpp | 8 -- lib/Serialization/ScanningLoaders.cpp | 88 +++-------------- lib/Tooling/libSwiftScan/libSwiftScan.cpp | 18 +--- .../Inputs/ModuleDependencyGraph.swift | 50 ++-------- .../can_import_placeholder.swift | 42 -------- .../module_deps_external.swift | 96 ------------------- .../placholder_overlay_deps.swift | 31 ------ unittests/DependencyScan/ModuleDeps.cpp | 4 +- 25 files changed, 37 insertions(+), 642 deletions(-) delete mode 100644 test/ScanDependencies/can_import_placeholder.swift delete mode 100644 test/ScanDependencies/module_deps_external.swift delete mode 100644 test/ScanDependencies/placholder_overlay_deps.swift diff --git a/include/swift-c/DependencyScan/DependencyScan.h b/include/swift-c/DependencyScan/DependencyScan.h index 93a9ec2bdc31b..f5f5717455518 100644 --- a/include/swift-c/DependencyScan/DependencyScan.h +++ b/include/swift-c/DependencyScan/DependencyScan.h @@ -36,7 +36,6 @@ typedef enum { // SwiftInterface and SwiftSource. SWIFTSCAN_DEPENDENCY_INFO_SWIFT_TEXTUAL = 0, SWIFTSCAN_DEPENDENCY_INFO_SWIFT_BINARY = 1, - SWIFTSCAN_DEPENDENCY_INFO_SWIFT_PLACEHOLDER = 2, SWIFTSCAN_DEPENDENCY_INFO_CLANG = 3 } swiftscan_dependency_info_kind_t; @@ -273,7 +272,8 @@ swiftscan_swift_binary_detail_get_module_cache_key( SWIFTSCAN_PUBLIC swiftscan_string_ref_t swiftscan_swift_binary_detail_get_user_module_version( swiftscan_module_details_t details); -//=== Swift Placeholder Module Details query APIs -------------------------===// + +//=== Swift Placeholder Module Details query APIs - DEPRECATED -----------===// SWIFTSCAN_PUBLIC swiftscan_string_ref_t swiftscan_swift_placeholder_detail_get_compiled_module_path( diff --git a/include/swift/AST/DiagnosticsFrontend.def b/include/swift/AST/DiagnosticsFrontend.def index 1497037d5c674..94567ab790edf 100644 --- a/include/swift/AST/DiagnosticsFrontend.def +++ b/include/swift/AST/DiagnosticsFrontend.def @@ -362,14 +362,6 @@ ERROR(explicit_swift_module_map_corrupted,none, "explicit Swift module map from %0 is malformed", (StringRef)) -ERROR(placeholder_dependency_module_map_missing,none, - "cannot open Swift placeholder dependency module map from %0", - (StringRef)) - -ERROR(placeholder_dependency_module_map_corrupted,none, - "Swift placeholder dependency module map from %0 is malformed", - (StringRef)) - ERROR(const_extract_protocol_list_input_file_missing,none, "cannot open constant extraction protocol list input file from %0", (StringRef)) diff --git a/include/swift/AST/ModuleDependencies.h b/include/swift/AST/ModuleDependencies.h index e6d0581dab5a4..8019cba6d1bac 100644 --- a/include/swift/AST/ModuleDependencies.h +++ b/include/swift/AST/ModuleDependencies.h @@ -69,30 +69,7 @@ enum class ModuleDependencyKind : int8_t { Clang, // Used to model the translation unit's source module SwiftSource, - // Placeholder dependencies are a kind of dependencies used only by the - // dependency scanner. They are swift modules that the scanner will not be - // able to locate in its search paths and which are the responsibility of the - // scanner's client to ensure are provided. - // - // Placeholder dependencies will be specified in the scanner's output - // dependency graph where it is the responsibility of the scanner's client to - // ensure required post-processing takes place to "resolve" them. In order to - // do so, the client (swift driver, or any other client build system) is - // expected to have access to a full dependency graph of all placeholder - // dependencies and be able to replace placeholder nodes in the dependency - // graph with their full dependency trees, `uniquing` common dependency module - // nodes in the process. - // - // One example where placeholder dependencies are employed is when using - // SwiftPM in Explicit Module Build mode. SwiftPM constructs a build plan for - // all targets ahead-of-time. When planning a build for a target that depends - // on other targets, the dependency scanning action is not able to locate - // dependency target modules, because they have not yet been built. Instead, - // the build system treats them as placeholder dependencies and resolves them - // with `actual` dependencies in a post-processing step once dependency graphs - // of all targets, individually, have been computed. - SwiftPlaceholder, - LastKind = SwiftPlaceholder + 1 + LastKind = SwiftSource + 1 }; /// This is used to idenfity a specific macro plugin dependency. @@ -537,39 +514,6 @@ class ClangModuleDependencyStorage : public ModuleDependencyInfoStorageBase { } }; -/// Describes an placeholder Swift module dependency module stub. -/// -/// This class is mostly an implementation detail for \c ModuleDependencyInfo. - -class SwiftPlaceholderModuleDependencyStorage - : public ModuleDependencyInfoStorageBase { -public: - SwiftPlaceholderModuleDependencyStorage(StringRef compiledModulePath, - StringRef moduleDocPath, - StringRef sourceInfoPath) - : ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftPlaceholder, {}, {}, - {}), - compiledModulePath(compiledModulePath), moduleDocPath(moduleDocPath), - sourceInfoPath(sourceInfoPath) {} - - ModuleDependencyInfoStorageBase *clone() const override { - return new SwiftPlaceholderModuleDependencyStorage(*this); - } - - /// The path to the .swiftmodule file. - const std::string compiledModulePath; - - /// The path to the .swiftModuleDoc file. - const std::string moduleDocPath; - - /// The path to the .swiftSourceInfo file. - const std::string sourceInfoPath; - - static bool classof(const ModuleDependencyInfoStorageBase *base) { - return base->dependencyKind == ModuleDependencyKind::SwiftPlaceholder; - } -}; - // MARK: Module Dependency Info /// Describes the dependencies of a given module. /// @@ -670,16 +614,6 @@ class ModuleDependencyInfo { CASFileSystemRootID, clangIncludeTreeRoot, moduleCacheKey, IsSystem)); } - /// Describe a placeholder dependency swift module. - static ModuleDependencyInfo - forPlaceholderSwiftModuleStub(StringRef compiledModulePath, - StringRef moduleDocPath, - StringRef sourceInfoPath) { - return ModuleDependencyInfo( - std::make_unique( - compiledModulePath, moduleDocPath, sourceInfoPath)); - } - /// Retrieve the module-level imports. ArrayRef getModuleImports() const { return storage->moduleImports; @@ -898,7 +832,7 @@ class ModuleDependencyInfo { bool isTestableImport(StringRef moduleName) const; /// Whether the dependencies are for a Swift module: either Textual, Source, - /// Binary, or Placeholder. + /// or Binary bool isSwiftModule() const; /// Whether the dependencies are for a textual interface Swift module or a @@ -914,9 +848,6 @@ class ModuleDependencyInfo { /// Whether the dependencies are for a binary Swift module. bool isSwiftBinaryModule() const; - /// Whether this represents a placeholder module stub - bool isSwiftPlaceholderModule() const; - /// Whether the dependencies are for a Clang module. bool isClangModule() const; @@ -935,10 +866,6 @@ class ModuleDependencyInfo { /// Retrieve the dependencies for a Clang module. const ClangModuleDependencyStorage *getAsClangModule() const; - /// Retrieve the dependencies for a placeholder dependency module stub. - const SwiftPlaceholderModuleDependencyStorage * - getAsPlaceholderDependencyModule() const; - /// Add a dependency on the given module, if it was not already in the set. void addOptionalModuleImport(StringRef module, bool isExported, diff --git a/include/swift/DependencyScan/DependencyScanImpl.h b/include/swift/DependencyScan/DependencyScanImpl.h index 66f95615269b6..fd38669a1ba99 100644 --- a/include/swift/DependencyScan/DependencyScanImpl.h +++ b/include/swift/DependencyScan/DependencyScanImpl.h @@ -43,7 +43,6 @@ struct swiftscan_dependency_info_s { /// "swiftInterface" /// "swiftSource" /// "swiftBinary" - /// "swiftPlaceholder" /// "clang"" swiftscan_string_ref_t module_name; @@ -183,19 +182,6 @@ typedef struct { swiftscan_string_ref_t user_module_version; } swiftscan_swift_binary_details_t; -/// Swift placeholder modules carry additional details that specify their -/// module doc path and source info paths. -typedef struct { - /// The path to the pre-compiled binary module - swiftscan_string_ref_t compiled_module_path; - - /// The path to the .swiftModuleDoc file. - swiftscan_string_ref_t module_doc_path; - - /// The path to the .swiftSourceInfo file. - swiftscan_string_ref_t module_source_info_path; -} swiftscan_swift_placeholder_details_t; - /// Clang modules are built from a module map file. typedef struct { /// The path to the module map used to build this module. @@ -222,7 +208,6 @@ struct swiftscan_module_details_s { union { swiftscan_swift_textual_details_t swift_textual_details; swiftscan_swift_binary_details_t swift_binary_details; - swiftscan_swift_placeholder_details_t swift_placeholder_details; swiftscan_clang_details_t clang_details; }; }; diff --git a/include/swift/DependencyScan/DependencyScanningTool.h b/include/swift/DependencyScan/DependencyScanningTool.h index 8aa380c83fc0e..fb84be398bcff 100644 --- a/include/swift/DependencyScan/DependencyScanningTool.h +++ b/include/swift/DependencyScan/DependencyScanningTool.h @@ -68,14 +68,12 @@ class DependencyScanningTool { /// Construct a dependency scanning tool. DependencyScanningTool(); - /// Collect the full module dependency graph for the input, ignoring any - /// placeholder modules. + /// Collect the full module dependency graph for the input. /// /// \returns a \c StringError with the diagnostic output if errors /// occurred, \c swiftscan_dependency_result_t otherwise. llvm::ErrorOr getDependencies(ArrayRef Command, - const llvm::StringSet<> &PlaceholderModules, StringRef WorkingDirectory); /// Collect the set of imports for the input module diff --git a/include/swift/DependencyScan/SerializedModuleDependencyCacheFormat.h b/include/swift/DependencyScan/SerializedModuleDependencyCacheFormat.h index 8a5c4d074cd90..c004eccb2e9ae 100644 --- a/include/swift/DependencyScan/SerializedModuleDependencyCacheFormat.h +++ b/include/swift/DependencyScan/SerializedModuleDependencyCacheFormat.h @@ -39,7 +39,7 @@ using llvm::BCVBR; /// Every .moddepcache file begins with these 4 bytes, for easy identification. const unsigned char MODULE_DEPENDENCY_CACHE_FORMAT_SIGNATURE[] = {'I', 'M', 'D','C'}; -const unsigned MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MAJOR = 9; +const unsigned MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MAJOR = 10; /// Increment this on every change. const unsigned MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MINOR = 3; @@ -109,7 +109,6 @@ enum { OPTIONAL_IMPORT_STATEMENT_ARRAY_NODE, SWIFT_INTERFACE_MODULE_DETAILS_NODE, SWIFT_SOURCE_MODULE_DETAILS_NODE, - SWIFT_PLACEHOLDER_MODULE_DETAILS_NODE, SWIFT_BINARY_MODULE_DETAILS_NODE, CLANG_MODULE_DETAILS_NODE, IDENTIFIER_NODE, @@ -204,7 +203,6 @@ using OptionalImportStatementArrayLayout = // - SwiftInterfaceModuleDetails // - SwiftSourceModuleDetails // - SwiftBinaryModuleDetails -// - SwiftPlaceholderModuleDetails // - ClangModuleDetails using ModuleInfoLayout = BCRecordLayout; -using SwiftPlaceholderModuleDetailsLayout = - BCRecordLayout; - using ClangModuleDetailsLayout = BCRecordLayout, MetaVarName<"">, HelpText<"Specify a list of protocols for extraction of conformances' const values'">; -def placeholder_dependency_module_map - : Separate<["-"], "placeholder-dependency-module-map-file">, MetaVarName<"">, - HelpText<"Specify a JSON file containing information of external Swift module dependencies">; - def import_prescan : Flag<["-"], "import-prescan">, HelpText<"When performing a dependency scan, only identify all imports of the main Swift module sources">; diff --git a/include/swift/Serialization/ScanningLoaders.h b/include/swift/Serialization/ScanningLoaders.h index 1aecb1bb3e903..6cdbf437962c8 100644 --- a/include/swift/Serialization/ScanningLoaders.h +++ b/include/swift/Serialization/ScanningLoaders.h @@ -83,51 +83,6 @@ class SwiftModuleScanner : public SerializedModuleLoaderBase { return MDS->getKind() == MDS_plain; } }; - -/// A ModuleLoader that loads placeholder dependency module stubs specified in -/// -placeholder-dependency-module-map-file -/// This loader is used only in dependency scanning to inform the scanner that a -/// set of modules constitute placeholder dependencies that are not visible to -/// the scanner but will nevertheless be provided by the scanner's clients. This -/// "loader" will not attempt to load any module files. -class PlaceholderSwiftModuleScanner : public SwiftModuleScanner { - /// Scan the given placeholder module map - void parsePlaceholderModuleMap(StringRef fileName); - - llvm::StringMap PlaceholderDependencyModuleMap; - llvm::BumpPtrAllocator Allocator; - -public: - PlaceholderSwiftModuleScanner(ASTContext &ctx, ModuleLoadingMode LoadMode, - Identifier moduleName, - StringRef PlaceholderDependencyModuleMap, - InterfaceSubContextDelegate &astDelegate, - StringRef moduleOutputPath, - StringRef sdkModuleOutputPath) - : SwiftModuleScanner(ctx, LoadMode, moduleName, astDelegate, - moduleOutputPath, sdkModuleOutputPath, {}, - MDS_placeholder) { - // FIXME: Find a better place for this map to live, to avoid - // doing the parsing on every module. - if (!PlaceholderDependencyModuleMap.empty()) { - parsePlaceholderModuleMap(PlaceholderDependencyModuleMap); - } - } - - virtual bool - findModule(ImportPath::Element moduleID, - SmallVectorImpl *moduleInterfacePath, - SmallVectorImpl *moduleInterfaceSourcePath, - std::unique_ptr *moduleBuffer, - std::unique_ptr *moduleDocBuffer, - std::unique_ptr *moduleSourceInfoBuffer, - bool skipBuildingInterface, bool isTestableDependencyLookup, - bool &isFramework, bool &isSystemModule) override; - - static bool classof(const SwiftModuleScanner *MDS) { - return MDS->getKind() == MDS_placeholder; - } -}; } // namespace swift #endif // SWIFT_SCANNINGLOADERS_H diff --git a/lib/AST/ModuleDependencies.cpp b/lib/AST/ModuleDependencies.cpp index dbd5e44c65ffb..a7622b11454c1 100644 --- a/lib/AST/ModuleDependencies.cpp +++ b/lib/AST/ModuleDependencies.cpp @@ -36,7 +36,7 @@ ModuleDependencyInfoStorageBase::~ModuleDependencyInfoStorageBase() {} bool ModuleDependencyInfo::isSwiftModule() const { return isSwiftInterfaceModule() || isSwiftSourceModule() || - isSwiftBinaryModule() || isSwiftPlaceholderModule(); + isSwiftBinaryModule(); } bool ModuleDependencyInfo::isTextualSwiftModule() const { @@ -66,10 +66,6 @@ bool ModuleDependencyInfo::isSwiftBinaryModule() const { return isa(storage.get()); } -bool ModuleDependencyInfo::isSwiftPlaceholderModule() const { - return isa(storage.get()); -} - bool ModuleDependencyInfo::isClangModule() const { return isa(storage.get()); } @@ -97,12 +93,6 @@ ModuleDependencyInfo::getAsClangModule() const { return dyn_cast(storage.get()); } -/// Retrieve the dependencies for a placeholder dependency module stub. -const SwiftPlaceholderModuleDependencyStorage * -ModuleDependencyInfo::getAsPlaceholderDependencyModule() const { - return dyn_cast(storage.get()); -} - void ModuleDependencyInfo::addTestableImport(ImportPath::Module module) { assert(getAsSwiftSourceModule() && "Expected source module for addTestableImport."); dyn_cast(storage.get())->addTestableImport(module); @@ -361,11 +351,6 @@ std::string ModuleDependencyInfo::getModuleOutputPath() const { cast(storage.get()); return swiftBinaryStorage->compiledModulePath; } - case swift::ModuleDependencyKind::SwiftPlaceholder: { - auto swiftPlaceholderStorage = - cast(storage.get()); - return swiftPlaceholderStorage->compiledModulePath; - } default: llvm_unreachable("Unexpected dependency kind"); } @@ -849,8 +834,6 @@ ModuleDependenciesCache::findSwiftDependency(StringRef moduleName) const { return found; if (auto found = findDependency(moduleName, ModuleDependencyKind::SwiftSource)) return found; - if (auto found = findDependency(moduleName, ModuleDependencyKind::SwiftPlaceholder)) - return found; return std::nullopt; } diff --git a/lib/AST/ModuleLoader.cpp b/lib/AST/ModuleLoader.cpp index 6bd49ae3a8b41..06e2b2c2adaf4 100644 --- a/lib/AST/ModuleLoader.cpp +++ b/lib/AST/ModuleLoader.cpp @@ -240,9 +240,6 @@ ModuleDependencyInfo::collectCrossImportOverlayNames( case swift::ModuleDependencyKind::SwiftSource: { return result; } - case swift::ModuleDependencyKind::SwiftPlaceholder: { - return result; - } case swift::ModuleDependencyKind::LastKind: llvm_unreachable("Unhandled dependency kind."); } diff --git a/lib/DependencyScan/DependencyScanJSON.cpp b/lib/DependencyScan/DependencyScanJSON.cpp index b41efc6883cca..924e1b0ba905a 100644 --- a/lib/DependencyScan/DependencyScanJSON.cpp +++ b/lib/DependencyScan/DependencyScanJSON.cpp @@ -129,7 +129,6 @@ void writeEncodedModuleIdJSONValue(llvm::raw_ostream &out, out << "{\n"; static const std::string textualPrefix("swiftTextual"); static const std::string binaryPrefix("swiftBinary"); - static const std::string placeholderPrefix("swiftPlaceholder"); static const std::string clangPrefix("clang"); std::string valueStr = get_C_string(value); std::string moduleKind; @@ -141,10 +140,6 @@ void writeEncodedModuleIdJSONValue(llvm::raw_ostream &out, // FIXME: rename to be consistent in the clients (swift-driver) moduleKind = "swiftPrebuiltExternal"; moduleName = valueStr.substr(binaryPrefix.size() + 1); - } else if (!valueStr.compare(0, placeholderPrefix.size(), - placeholderPrefix)) { - moduleKind = "swiftPlaceholder"; - moduleName = valueStr.substr(placeholderPrefix.size() + 1); } else { moduleKind = "clang"; moduleName = valueStr.substr(clangPrefix.size() + 1); @@ -276,13 +271,6 @@ getAsTextualDependencyModule(swiftscan_module_details_t details) { return nullptr; } -static const swiftscan_swift_placeholder_details_t * -getAsPlaceholderDependencyModule(swiftscan_module_details_t details) { - if (details->kind == SWIFTSCAN_DEPENDENCY_INFO_SWIFT_PLACEHOLDER) - return &details->swift_placeholder_details; - return nullptr; -} - static const swiftscan_swift_binary_details_t * getAsBinaryDependencyModule(swiftscan_module_details_t details) { if (details->kind == SWIFTSCAN_DEPENDENCY_INFO_SWIFT_BINARY) @@ -329,8 +317,6 @@ void writeJSON(llvm::raw_ostream &out, out << ",\n"; out.indent(2 * 2); out << "{\n"; - auto swiftPlaceholderDeps = - getAsPlaceholderDependencyModule(moduleInfo.details); auto swiftTextualDeps = getAsTextualDependencyModule(moduleInfo.details); auto swiftBinaryDeps = getAsBinaryDependencyModule(moduleInfo.details); auto clangDeps = getAsClangDependencyModule(moduleInfo.details); @@ -343,9 +329,7 @@ void writeJSON(llvm::raw_ostream &out, std::string(get_C_string(moduleInfo.module_name)); std::string moduleName = moduleKindAndName.substr(moduleKindAndName.find(":") + 1); - if (swiftPlaceholderDeps) - modulePath = get_C_string(swiftPlaceholderDeps->compiled_module_path); - else if (swiftBinaryDeps) + if (swiftBinaryDeps) modulePath = get_C_string(swiftBinaryDeps->compiled_module_path); else if (clangDeps || swiftTextualDeps) modulePath = get_C_string(moduleInfo.module_path); @@ -499,25 +483,6 @@ void writeJSON(llvm::raw_ostream &out, "swiftOverlayDependencies", 5, /*trailingComma=*/false); } - } else if (swiftPlaceholderDeps) { - out << "\"swiftPlaceholder\": {\n"; - - // Module doc file - if (swiftPlaceholderDeps->module_doc_path.data && - get_C_string(swiftPlaceholderDeps->module_doc_path)[0] != '\0') - writeJSONSingleField(out, "moduleDocPath", - swiftPlaceholderDeps->module_doc_path, - /*indentLevel=*/5, - /*trailingComma=*/true); - - // Module Source Info file - if (swiftPlaceholderDeps->module_source_info_path.data && - get_C_string(swiftPlaceholderDeps->module_source_info_path)[0] != - '\0') - writeJSONSingleField(out, "moduleSourceInfoPath", - swiftPlaceholderDeps->module_source_info_path, - /*indentLevel=*/5, - /*trailingComma=*/false); } else if (swiftBinaryDeps) { bool hasOverlayDependencies = swiftBinaryDeps->swift_overlay_module_dependencies && diff --git a/lib/DependencyScan/DependencyScanningTool.cpp b/lib/DependencyScan/DependencyScanningTool.cpp index e2651976c16da..b9d044d512f6a 100644 --- a/lib/DependencyScan/DependencyScanningTool.cpp +++ b/lib/DependencyScan/DependencyScanningTool.cpp @@ -264,7 +264,6 @@ DependencyScanningTool::DependencyScanningTool() llvm::ErrorOr DependencyScanningTool::getDependencies( ArrayRef Command, - const llvm::StringSet<> &PlaceholderModules, StringRef WorkingDirectory) { // There may be errors as early as in instance initialization, so we must ensure // we can catch those. diff --git a/lib/DependencyScan/ModuleDependencyCacheSerialization.cpp b/lib/DependencyScan/ModuleDependencyCacheSerialization.cpp index 1ca3d8e444ad2..edd9ab3c02853 100644 --- a/lib/DependencyScan/ModuleDependencyCacheSerialization.cpp +++ b/lib/DependencyScan/ModuleDependencyCacheSerialization.cpp @@ -749,34 +749,6 @@ bool ModuleDependenciesCacheDeserializer::readGraph( break; } - case SWIFT_PLACEHOLDER_MODULE_DETAILS_NODE: { - if (!hasCurrentModule) - llvm::report_fatal_error( - "Unexpected SWIFT_PLACEHOLDER_MODULE_DETAILS_NODE record"); - unsigned compiledModulePathID, moduleDocPathID, moduleSourceInfoPathID; - SwiftPlaceholderModuleDetailsLayout::readRecord( - Scratch, compiledModulePathID, moduleDocPathID, - moduleSourceInfoPathID); - - auto compiledModulePath = getIdentifier(compiledModulePathID); - if (!compiledModulePath) - llvm::report_fatal_error("Bad compiled module path"); - auto moduleDocPath = getIdentifier(moduleDocPathID); - if (!moduleDocPath) - llvm::report_fatal_error("Bad module doc path"); - auto moduleSourceInfoPath = getIdentifier(moduleSourceInfoPathID); - if (!moduleSourceInfoPath) - llvm::report_fatal_error("Bad module source info path"); - - // Form the dependencies storage object - auto moduleDep = ModuleDependencyInfo::forPlaceholderSwiftModuleStub( - *compiledModulePath, *moduleDocPath, *moduleSourceInfoPath); - - cache.recordDependency(currentModuleName, std::move(moduleDep)); - hasCurrentModule = false; - break; - } - case CLANG_MODULE_DETAILS_NODE: { if (!hasCurrentModule) llvm::report_fatal_error("Unexpected CLANG_MODULE_DETAILS_NODE record"); @@ -1011,7 +983,6 @@ ModuleDependenciesCacheDeserializer::getModuleDependencyIDArray(unsigned n) { if (encodedIdentifierStringArray) { static const std::string textualPrefix("swiftTextual"); static const std::string binaryPrefix("swiftBinary"); - static const std::string placeholderPrefix("swiftPlaceholder"); static const std::string clangPrefix("clang"); std::vector result; for (const auto &encodedIdentifierString : *encodedIdentifierStringArray) { @@ -1026,11 +997,6 @@ ModuleDependenciesCacheDeserializer::getModuleDependencyIDArray(unsigned n) { auto moduleName = encodedIdentifierString.substr(binaryPrefix.size() + 1); id = {moduleName, ModuleDependencyKind::SwiftBinary}; - } else if (!encodedIdentifierString.compare(0, placeholderPrefix.size(), - placeholderPrefix)) { - auto moduleName = - encodedIdentifierString.substr(placeholderPrefix.size() + 1); - id = {moduleName, ModuleDependencyKind::SwiftPlaceholder}; } else { auto moduleName = encodedIdentifierString.substr(clangPrefix.size() + 1); @@ -1266,7 +1232,6 @@ void ModuleDependenciesCacheSerializer::writeBlockInfoBlock() { BLOCK_RECORD(graph_block, SWIFT_INTERFACE_MODULE_DETAILS_NODE); BLOCK_RECORD(graph_block, SWIFT_SOURCE_MODULE_DETAILS_NODE); BLOCK_RECORD(graph_block, SWIFT_BINARY_MODULE_DETAILS_NODE); - BLOCK_RECORD(graph_block, SWIFT_PLACEHOLDER_MODULE_DETAILS_NODE); BLOCK_RECORD(graph_block, CLANG_MODULE_DETAILS_NODE); } @@ -1664,17 +1629,6 @@ void ModuleDependenciesCacheSerializer::writeModuleInfo( getIdentifier(swiftBinDeps->userModuleVersion)); break; } - case swift::ModuleDependencyKind::SwiftPlaceholder: { - auto swiftPHDeps = dependencyInfo.getAsPlaceholderDependencyModule(); - assert(swiftPHDeps); - SwiftPlaceholderModuleDetailsLayout::emitRecord( - Out, ScratchRecord, - AbbrCodes[SwiftPlaceholderModuleDetailsLayout::Code], - getIdentifier(swiftPHDeps->compiledModulePath), - getIdentifier(swiftPHDeps->moduleDocPath), - getIdentifier(swiftPHDeps->sourceInfoPath)); - break; - } case swift::ModuleDependencyKind::Clang: { auto clangDeps = dependencyInfo.getAsClangModule(); assert(clangDeps); @@ -1932,14 +1886,6 @@ void ModuleDependenciesCacheSerializer::collectStringsAndArrays( [this](auto &sp) { addIdentifier(sp.Path); }); break; } - case swift::ModuleDependencyKind::SwiftPlaceholder: { - auto swiftPHDeps = dependencyInfo->getAsPlaceholderDependencyModule(); - assert(swiftPHDeps); - addIdentifier(swiftPHDeps->compiledModulePath); - addIdentifier(swiftPHDeps->moduleDocPath); - addIdentifier(swiftPHDeps->sourceInfoPath); - break; - } case swift::ModuleDependencyKind::SwiftSource: { auto swiftSourceDeps = dependencyInfo->getAsSwiftSourceModule(); assert(swiftSourceDeps); @@ -2017,7 +1963,6 @@ void ModuleDependenciesCacheSerializer::writeInterModuleDependenciesCache( registerRecordAbbr(); registerRecordAbbr(); registerRecordAbbr(); - registerRecordAbbr(); registerRecordAbbr(); // Make a pass to collect all unique strings and arrays diff --git a/lib/DependencyScan/ModuleDependencyScanner.cpp b/lib/DependencyScan/ModuleDependencyScanner.cpp index fadd930d05c2d..19d15bd78dbe2 100644 --- a/lib/DependencyScan/ModuleDependencyScanner.cpp +++ b/lib/DependencyScan/ModuleDependencyScanner.cpp @@ -104,8 +104,7 @@ findPathToDependency(ModuleDependencyID dependency, static bool isSwiftDependencyKind(ModuleDependencyKind Kind) { return Kind == ModuleDependencyKind::SwiftInterface || Kind == ModuleDependencyKind::SwiftSource || - Kind == ModuleDependencyKind::SwiftBinary || - Kind == ModuleDependencyKind::SwiftPlaceholder; + Kind == ModuleDependencyKind::SwiftBinary; } // The Swift compiler does not have a concept of a working directory. @@ -1365,8 +1364,7 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule( Identifier moduleIdentifier) { auto moduleName = moduleIdentifier.str(); if (cache.hasDependency(moduleName, ModuleDependencyKind::SwiftInterface) || - cache.hasDependency(moduleName, ModuleDependencyKind::SwiftBinary) || - cache.hasDependency(moduleName, ModuleDependencyKind::SwiftPlaceholder)) + cache.hasDependency(moduleName, ModuleDependencyKind::SwiftBinary)) return; auto moduleDependencies = withDependencyScanningWorker( @@ -1705,10 +1703,6 @@ void ModuleDependencyScanner::diagnoseScannerFailure( moduleFilePath = entryNode->getAsSwiftBinaryModule()->compiledModulePath; break; - case swift::ModuleDependencyKind::SwiftPlaceholder: - moduleFilePath = - entryNode->getAsPlaceholderDependencyModule()->compiledModulePath; - break; case swift::ModuleDependencyKind::Clang: moduleFilePath = entryNode->getAsClangModule()->moduleMapFile; isClang = true; @@ -1743,9 +1737,6 @@ static std::string getModuleDefiningPath(const ModuleDependencyInfo &info) { case swift::ModuleDependencyKind::SwiftBinary: path = info.getAsSwiftBinaryModule()->compiledModulePath; break; - case swift::ModuleDependencyKind::SwiftPlaceholder: - path = info.getAsPlaceholderDependencyModule()->compiledModulePath; - break; case swift::ModuleDependencyKind::Clang: path = info.getAsClangModule()->moduleMapFile; break; diff --git a/lib/DependencyScan/ScanDependencies.cpp b/lib/DependencyScan/ScanDependencies.cpp index 054b237ba82cd..221e60e0f5798 100644 --- a/lib/DependencyScan/ScanDependencies.cpp +++ b/lib/DependencyScan/ScanDependencies.cpp @@ -92,10 +92,6 @@ class ExplicitModuleDependencyResolver { // Resolve the dependencies for the current moduleID. Return true on error. bool resolve(const std::set &dependencies, std::optional> bridgingHeaderDeps) { - // No need to resolve dependency for placeholder. - if (moduleID.Kind == ModuleDependencyKind::SwiftPlaceholder) - return false; - // If the dependency is already finalized, nothing needs to be done. if (resolvingDepInfo.isFinalized()) return false; @@ -116,13 +112,6 @@ class ExplicitModuleDependencyResolver { if (handleSwiftBinaryModuleDependency(depModuleID, *binaryDepDetails)) return true; } break; - case swift::ModuleDependencyKind::SwiftPlaceholder: { - auto placeholderDetails = depInfo.getAsPlaceholderDependencyModule(); - assert(placeholderDetails && "Expected Swift Placeholder dependency."); - if (handleSwiftPlaceholderModuleDependency(depModuleID, - *placeholderDetails)) - return true; - } break; case swift::ModuleDependencyKind::Clang: { auto clangDepDetails = depInfo.getAsClangModule(); assert(clangDepDetails && "Expected Clang Module dependency."); @@ -195,9 +184,6 @@ class ExplicitModuleDependencyResolver { bool finalize(ModuleDependencyInfo &depInfo, const SwiftInterfaceModuleOutputPathResolution::ResultTy &swiftInterfaceModuleOutputPath) { - if (resolvingDepInfo.isSwiftPlaceholderModule()) - return false; - if (resolvingDepInfo.isSwiftInterfaceModule()) depInfo.setOutputPathAndHash( swiftInterfaceModuleOutputPath.outputPath.str().str(), @@ -287,15 +273,6 @@ class ExplicitModuleDependencyResolver { return false; } - bool handleSwiftPlaceholderModuleDependency( - ModuleDependencyID depModuleID, - const SwiftPlaceholderModuleDependencyStorage &placeholderDetails) { - if (!resolvingDepInfo.isSwiftSourceModule()) - commandline.push_back("-swift-module-file=" + depModuleID.ModuleName + - "=" + placeholderDetails.compiledModulePath); - return false; - } - bool handleClangModuleDependency( ModuleDependencyID depModuleID, const ClangModuleDependencyStorage &clangDepDetails) { @@ -721,9 +698,6 @@ static void bridgeDependencyIDs(const ArrayRef dependencies, case ModuleDependencyKind::SwiftBinary: dependencyKindAndName = "swiftBinary"; break; - case ModuleDependencyKind::SwiftPlaceholder: - dependencyKindAndName = "swiftPlaceholder"; - break; case ModuleDependencyKind::Clang: dependencyKindAndName = "clang"; break; @@ -776,7 +750,6 @@ generateFullDependencyGraph(const CompilerInstance &instance, const auto &moduleID = allModules[i]; auto &moduleDependencyInfo = cache.findKnownDependency(moduleID); // Collect all the required pieces to build a ModuleInfo - auto swiftPlaceholderDeps = moduleDependencyInfo.getAsPlaceholderDependencyModule(); auto swiftTextualDeps = moduleDependencyInfo.getAsSwiftInterfaceModule(); auto swiftSourceDeps = moduleDependencyInfo.getAsSwiftSourceModule(); auto swiftBinaryDeps = moduleDependencyInfo.getAsSwiftBinaryModule(); @@ -788,8 +761,6 @@ generateFullDependencyGraph(const CompilerInstance &instance, std::string modulePath; if (swiftTextualDeps) modulePath = swiftTextualDeps->moduleOutputPath; - else if (swiftPlaceholderDeps) - modulePath = swiftPlaceholderDeps->compiledModulePath; else if (swiftBinaryDeps) modulePath = swiftBinaryDeps->compiledModulePath; else if (clangDeps) @@ -904,12 +875,6 @@ generateFullDependencyGraph(const CompilerInstance &instance, create_clone(swiftSourceDeps->chainedBridgingHeaderPath.c_str()), create_clone( swiftSourceDeps->chainedBridgingHeaderContent.c_str())}; - } else if (swiftPlaceholderDeps) { - details->kind = SWIFTSCAN_DEPENDENCY_INFO_SWIFT_PLACEHOLDER; - details->swift_placeholder_details = { - create_clone(swiftPlaceholderDeps->compiledModulePath.c_str()), - create_clone(swiftPlaceholderDeps->moduleDocPath.c_str()), - create_clone(swiftPlaceholderDeps->sourceInfoPath.c_str())}; } else if (swiftBinaryDeps) { details->kind = SWIFTSCAN_DEPENDENCY_INFO_SWIFT_BINARY; // Create an overlay dependencies set according to the output format @@ -1315,8 +1280,6 @@ swift::dependencies::createEncodedModuleKindAndName(ModuleDependencyID id) { return "swiftTextual:" + id.ModuleName; case ModuleDependencyKind::SwiftBinary: return "swiftBinary:" + id.ModuleName; - case ModuleDependencyKind::SwiftPlaceholder: - return "swiftPlaceholder:" + id.ModuleName; case ModuleDependencyKind::Clang: return "clang:" + id.ModuleName; default: diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 3432da07a449b..16cb5ff0b0539 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -193,8 +193,6 @@ static void validateProfilingArgs(DiagnosticEngine &diags, static void validateDependencyScanningArgs(DiagnosticEngine &diags, const ArgList &args) { - const Arg *ExternalDependencyMap = - args.getLastArg(options::OPT_placeholder_dependency_module_map); const Arg *ScanDependencies = args.getLastArg(options::OPT_scan_dependencies); const Arg *Prescan = args.getLastArg(options::OPT_import_prescan); @@ -207,11 +205,6 @@ static void validateDependencyScanningArgs(DiagnosticEngine &diags, const Arg *ValidatePriorCache = args.getLastArg(options::OPT_validate_prior_dependency_scan_cache); - if (ExternalDependencyMap && !ScanDependencies) { - diags.diagnose(SourceLoc(), diag::error_requirement_not_met, - "-placeholder-dependency-module-map-file", - "-scan-dependencies"); - } if (Prescan && !ScanDependencies) { diags.diagnose(SourceLoc(), diag::error_requirement_not_met, "-import-prescan", "-scan-dependencies"); diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index ad9e5587e2584..c6800a9440ba5 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -2441,8 +2441,6 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args, for (auto A: Args.filtered(OPT_candidate_module_file)) { Opts.CandidateCompiledModules.push_back(resolveSearchPath(A->getValue())); } - if (const Arg *A = Args.getLastArg(OPT_placeholder_dependency_module_map)) - Opts.PlaceholderDependencyModuleMap = A->getValue(); if (const Arg *A = Args.getLastArg(OPT_const_gather_protocols_file)) Opts.ConstGatherProtocolListFilePath = A->getValue(); diff --git a/lib/Frontend/Frontend.cpp b/lib/Frontend/Frontend.cpp index 3d578b8510b5c..86b5aa1af82e8 100644 --- a/lib/Frontend/Frontend.cpp +++ b/lib/Frontend/Frontend.cpp @@ -899,14 +899,6 @@ bool CompilerInstance::setUpModuleLoaders() { FEOpts.SerializeModuleInterfaceDependencyHashes, FEOpts.shouldTrackSystemDependencies(), RequireOSSAModules_t(Invocation.getSILOptions())); - auto mainModuleName = Context->getIdentifier(FEOpts.ModuleName); - std::unique_ptr PSMS = - std::make_unique( - *Context, MLM, mainModuleName, - Context->SearchPathOpts.PlaceholderDependencyModuleMap, ASTDelegate, - getInvocation().getFrontendOptions().ExplicitModulesOutputPath, - getInvocation().getFrontendOptions().ExplicitSDKModulesOutputPath); - Context->addModuleLoader(std::move(PSMS)); } return false; diff --git a/lib/Serialization/ScanningLoaders.cpp b/lib/Serialization/ScanningLoaders.cpp index 2b90236952336..0eb215d8f325b 100644 --- a/lib/Serialization/ScanningLoaders.cpp +++ b/lib/Serialization/ScanningLoaders.cpp @@ -83,56 +83,6 @@ std::error_code SwiftModuleScanner::findModuleFilesInDirectory( return dependencies.getError(); } -bool PlaceholderSwiftModuleScanner::findModule( - ImportPath::Element moduleID, SmallVectorImpl *moduleInterfacePath, - SmallVectorImpl *moduleInterfaceSourcePath, - std::unique_ptr *moduleBuffer, - std::unique_ptr *moduleDocBuffer, - std::unique_ptr *moduleSourceInfoBuffer, - bool skipBuildingInterface, bool isTestableDependencyLookup, - bool &isFramework, bool &isSystemModule) { - StringRef moduleName = Ctx.getRealModuleName(moduleID.Item).str(); - auto it = PlaceholderDependencyModuleMap.find(moduleName); - if (it == PlaceholderDependencyModuleMap.end()) { - return false; - } - auto &moduleInfo = it->getValue(); - auto dependencies = ModuleDependencyInfo::forPlaceholderSwiftModuleStub( - moduleInfo.modulePath, - moduleInfo.moduleDocPath.has_value() ? moduleInfo.moduleDocPath.value() - : "", - moduleInfo.moduleSourceInfoPath.has_value() - ? moduleInfo.moduleSourceInfoPath.value() - : ""); - this->dependencies = std::move(dependencies); - return true; -} - -void PlaceholderSwiftModuleScanner::parsePlaceholderModuleMap( - StringRef fileName) { - ExplicitModuleMapParser parser(Allocator); - llvm::StringMap ClangDependencyModuleMap; - llvm::StringMap ModuleAliases; - llvm::ErrorOr> fileBufOrErr = - llvm::MemoryBuffer::getFile(fileName); - if (!fileBufOrErr) { - Ctx.Diags.diagnose(SourceLoc(), diag::explicit_swift_module_map_missing, - fileName); - return; - } - auto result = parser.parseSwiftExplicitModuleMap( - (*fileBufOrErr)->getMemBufferRef(), PlaceholderDependencyModuleMap, - ClangDependencyModuleMap, ModuleAliases); - if (result == std::errc::invalid_argument) { - Ctx.Diags.diagnose(SourceLoc(), - diag::placeholder_dependency_module_map_corrupted, - fileName); - } else if (result == std::errc::no_such_file_or_directory) { - Ctx.Diags.diagnose( - SourceLoc(), diag::placeholder_dependency_module_map_missing, fileName); - } -} - static std::vector getCompiledCandidates(ASTContext &ctx, StringRef moduleName, StringRef interfacePath) { @@ -295,36 +245,20 @@ ModuleDependencyVector SerializedModuleLoaderBase::getModuleDependencies( auto modulePath = builder.get(); auto moduleId = modulePath.front().Item; - // Instantiate dependency scanning "loaders". - SmallVector, 2> scanners; - // Placeholder dependencies must be resolved first, to prevent the - // ModuleDependencyScanner from first discovering artifacts of a previous - // build. Such artifacts are captured as compiledModuleCandidates in the - // dependency graph of the placeholder dependency module itself. - // FIXME: submodules? - scanners.push_back(std::make_unique( - Ctx, LoadMode, moduleId, Ctx.SearchPathOpts.PlaceholderDependencyModuleMap, - delegate, moduleOutputPath, sdkModuleOutputPath)); - scanners.push_back(std::make_unique( + auto scanner = std::make_unique( Ctx, LoadMode, moduleId, delegate, moduleOutputPath, sdkModuleOutputPath, - swiftModuleClangCC1CommandLineArgs, - SwiftModuleScanner::MDS_plain)); + swiftModuleClangCC1CommandLineArgs, SwiftModuleScanner::MDS_plain); // Check whether there is a module with this name that we can import. - assert(isa(scanners[0].get()) && - "Expected PlaceholderSwiftModuleScanner as the first dependency " - "scanner loader."); - for (auto &scanner : scanners) { - if (scanner->canImportModule(modulePath, SourceLoc(), nullptr, - isTestableDependencyLookup)) { - - ModuleDependencyVector moduleDependnecies; - moduleDependnecies.push_back( - std::make_pair(ModuleDependencyID{moduleName.str().str(), - scanner->dependencies->getKind()}, - *(scanner->dependencies))); - return moduleDependnecies; - } + if (scanner->canImportModule(modulePath, SourceLoc(), nullptr, + isTestableDependencyLookup)) { + + ModuleDependencyVector moduleDependnecies; + moduleDependnecies.push_back( + std::make_pair(ModuleDependencyID{moduleName.str().str(), + scanner->dependencies->getKind()}, + *(scanner->dependencies))); + return moduleDependnecies; } return {}; diff --git a/lib/Tooling/libSwiftScan/libSwiftScan.cpp b/lib/Tooling/libSwiftScan/libSwiftScan.cpp index e51f8191b8c41..44f78345b7c42 100644 --- a/lib/Tooling/libSwiftScan/libSwiftScan.cpp +++ b/lib/Tooling/libSwiftScan/libSwiftScan.cpp @@ -93,14 +93,6 @@ void swiftscan_dependency_info_details_dispose( swiftscan_string_dispose( details_impl->swift_binary_details.user_module_version); break; - case SWIFTSCAN_DEPENDENCY_INFO_SWIFT_PLACEHOLDER: - swiftscan_string_dispose( - details_impl->swift_placeholder_details.compiled_module_path); - swiftscan_string_dispose( - details_impl->swift_placeholder_details.module_doc_path); - swiftscan_string_dispose( - details_impl->swift_placeholder_details.module_source_info_path); - break; case SWIFTSCAN_DEPENDENCY_INFO_CLANG: swiftscan_string_dispose(details_impl->clang_details.module_map_path); swiftscan_string_dispose(details_impl->clang_details.context_hash); @@ -168,7 +160,7 @@ swiftscan_dependency_graph_create(swiftscan_scanner_t scanner, // Execute the scan and bridge the result auto ScanResult = ScanningTool->getDependencies( - Compilation, {}, + Compilation, swift::c_string_utils::get_C_string(invocation->working_directory)); if (ScanResult.getError()) return nullptr; @@ -412,23 +404,23 @@ swiftscan_swift_binary_detail_get_user_module_version( return details->swift_binary_details.user_module_version; } -//=== Swift Placeholder Module Details query APIs -------------------------===// +//=== Swift Placeholder Module Details query APIs - DEPRECATED -----------===// swiftscan_string_ref_t swiftscan_swift_placeholder_detail_get_compiled_module_path( swiftscan_module_details_t details) { - return details->swift_placeholder_details.module_source_info_path; + return swift::c_string_utils::create_null(); } swiftscan_string_ref_t swiftscan_swift_placeholder_detail_get_module_doc_path( swiftscan_module_details_t details) { - return details->swift_placeholder_details.module_source_info_path; + return swift::c_string_utils::create_null(); } swiftscan_string_ref_t swiftscan_swift_placeholder_detail_get_module_source_info_path( swiftscan_module_details_t details) { - return details->swift_placeholder_details.module_source_info_path; + return swift::c_string_utils::create_null(); } //=== Clang Module Details query APIs -------------------------------------===// diff --git a/test/ScanDependencies/Inputs/ModuleDependencyGraph.swift b/test/ScanDependencies/Inputs/ModuleDependencyGraph.swift index 6037a5d954092..0fedfdb7b4475 100644 --- a/test/ScanDependencies/Inputs/ModuleDependencyGraph.swift +++ b/test/ScanDependencies/Inputs/ModuleDependencyGraph.swift @@ -13,14 +13,12 @@ import Foundation enum ModuleDependencyId: Hashable { case swift(String) - case swiftPlaceholder(String) case swiftPrebuiltExternal(String) case clang(String) var moduleName: String { switch self { case .swift(let name): return name - case .swiftPlaceholder(let name): return name case .swiftPrebuiltExternal(let name): return name case .clang(let name): return name } @@ -30,7 +28,6 @@ enum ModuleDependencyId: Hashable { extension ModuleDependencyId: Codable { enum CodingKeys: CodingKey { case swift - case swiftPlaceholder case swiftPrebuiltExternal case clang } @@ -42,16 +39,11 @@ extension ModuleDependencyId: Codable { self = .swift(moduleName) } catch { do { - let moduleName = try container.decode(String.self, forKey: .swiftPlaceholder) - self = .swiftPlaceholder(moduleName) + let moduleName = try container.decode(String.self, forKey: .swiftPrebuiltExternal) + self = .swiftPrebuiltExternal(moduleName) } catch { - do { - let moduleName = try container.decode(String.self, forKey: .swiftPrebuiltExternal) - self = .swiftPrebuiltExternal(moduleName) - } catch { - let moduleName = try container.decode(String.self, forKey: .clang) - self = .clang(moduleName) - } + let moduleName = try container.decode(String.self, forKey: .clang) + self = .clang(moduleName) } } } @@ -61,8 +53,6 @@ extension ModuleDependencyId: Codable { switch self { case .swift(let moduleName): try container.encode(moduleName, forKey: .swift) - case .swiftPlaceholder(let moduleName): - try container.encode(moduleName, forKey: .swiftPlaceholder) case .swiftPrebuiltExternal(let moduleName): try container.encode(moduleName, forKey: .swiftPrebuiltExternal) case .clang(let moduleName): @@ -99,15 +89,6 @@ struct SwiftModuleDetails: Codable { var swiftOverlayDependencies: [ModuleDependencyId]? } -/// Details specific to Swift placeholder dependencies. -struct SwiftPlaceholderModuleDetails: Codable { - /// The path to the .swiftModuleDoc file. - var moduleDocPath: String? - - /// The path to the .swiftSourceInfo file. - var moduleSourceInfoPath: String? -} - /// Details specific to Swift externally-pre-built modules. struct SwiftPrebuiltExternalModuleDetails: Codable { /// The path to the already-compiled module that must be used instead of @@ -152,10 +133,6 @@ struct ModuleInfo: Codable { /// a bridging header. case swift(SwiftModuleDetails) - /// Swift placeholder modules carry additional details that specify their - /// module doc path and source info paths. - case swiftPlaceholder(SwiftPlaceholderModuleDetails) - /// Swift externally-prebuilt modules must communicate the path to pre-built binary artifacts case swiftPrebuiltExternal(SwiftPrebuiltExternalModuleDetails) @@ -167,7 +144,6 @@ struct ModuleInfo: Codable { extension ModuleInfo.Details: Codable { enum CodingKeys: CodingKey { case swift - case swiftPlaceholder case swiftPrebuiltExternal case clang } @@ -179,18 +155,12 @@ extension ModuleInfo.Details: Codable { self = .swift(details) } catch { do { - let details = try container.decode(SwiftPlaceholderModuleDetails.self, - forKey: .swiftPlaceholder) - self = .swiftPlaceholder(details) + let details = try container.decode(SwiftPrebuiltExternalModuleDetails.self, + forKey: .swiftPrebuiltExternal) + self = .swiftPrebuiltExternal(details) } catch { - do { - let details = try container.decode(SwiftPrebuiltExternalModuleDetails.self, - forKey: .swiftPrebuiltExternal) - self = .swiftPrebuiltExternal(details) - } catch { - let details = try container.decode(ClangModuleDetails.self, forKey: .clang) - self = .clang(details) - } + let details = try container.decode(ClangModuleDetails.self, forKey: .clang) + self = .clang(details) } } } @@ -200,8 +170,6 @@ extension ModuleInfo.Details: Codable { switch self { case .swift(let details): try container.encode(details, forKey: .swift) - case .swiftPlaceholder(let details): - try container.encode(details, forKey: .swiftPlaceholder) case .swiftPrebuiltExternal(let details): try container.encode(details, forKey: .swiftPrebuiltExternal) case .clang(let details): diff --git a/test/ScanDependencies/can_import_placeholder.swift b/test/ScanDependencies/can_import_placeholder.swift deleted file mode 100644 index 9a42e2b9a04a2..0000000000000 --- a/test/ScanDependencies/can_import_placeholder.swift +++ /dev/null @@ -1,42 +0,0 @@ -// RUN: %empty-directory(%t) -// RUN: mkdir -p %t/clang-module-cache -// RUN: mkdir -p %t/inputs - -// RUN: echo "[{" > %/t/inputs/map.json -// RUN: echo "\"moduleName\": \"SomeExternalModule\"," >> %/t/inputs/map.json -// RUN: echo "\"modulePath\": \"%/t/inputs/SomeExternalModule.swiftmodule\"," >> %/t/inputs/map.json -// RUN: echo "\"docPath\": \"%/t/inputs/SomeExternalModule.swiftdoc\"," >> %/t/inputs/map.json -// RUN: echo "\"sourceInfoPath\": \"%/t/inputs/SomeExternalModule.swiftsourceinfo\"," >> %/t/inputs/map.json -// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json -// RUN: echo "}]" >> %/t/inputs/map.json - -// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -// RUN: %validate-json %t/deps.json | %FileCheck %s - -// Ensure that round-trip serialization does not affect result -// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -test-dependency-scan-cache-serialization -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -// RUN: %validate-json %t/deps.json | %FileCheck %s - -// REQUIRES: executable_test -// REQUIRES: objc_interop -#if canImport(SomeExternalModule) -import SomeExternalModule -#endif - -// CHECK: "mainModuleName": "deps" - -/// --------Main module -// CHECK-LABEL: "modulePath": "deps.swiftmodule", -// CHECK-NEXT: sourceFiles -// CHECK-NEXT: can_import_placeholder.swift - -// CHECK: directDependencies -// CHECK-NEXT: { -// CHECK-DAG: "swift": "F" -// CHECK-DAG: "swiftPlaceholder": "SomeExternalModule" -// CHECK-DAG: "swift": "Swift" -// CHECK-DAG: "swift": "SwiftOnoneSupport" -// CHECK-DAG: "swift": "_Concurrency" -// CHECK-DAG: "swift": "_StringProcessing" -// CHECK-DAG: "clang": "_SwiftConcurrencyShims" -// CHECK: ], diff --git a/test/ScanDependencies/module_deps_external.swift b/test/ScanDependencies/module_deps_external.swift deleted file mode 100644 index 80d0f4bbba3d4..0000000000000 --- a/test/ScanDependencies/module_deps_external.swift +++ /dev/null @@ -1,96 +0,0 @@ -// RUN: %empty-directory(%t) -// RUN: mkdir -p %t/clang-module-cache -// RUN: mkdir -p %t/inputs - -// RUN: echo "[{" > %/t/inputs/map.json -// RUN: echo "\"moduleName\": \"SomeExternalModule\"," >> %/t/inputs/map.json -// RUN: echo "\"modulePath\": \"%/t/inputs/SomeExternalModule.swiftmodule\"," >> %/t/inputs/map.json -// RUN: echo "\"docPath\": \"%/t/inputs/SomeExternalModule.swiftdoc\"," >> %/t/inputs/map.json -// RUN: echo "\"sourceInfoPath\": \"%/t/inputs/SomeExternalModule.swiftsourceinfo\"," >> %/t/inputs/map.json -// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json -// RUN: echo "}]" >> %/t/inputs/map.json - -// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 - -// Check the contents of the JSON output -// RUN: %validate-json %t/deps.json | %FileCheck %s - -// Check the make-style dependencies file -// RUN: %FileCheck %s -check-prefix CHECK-MAKE-DEPS < %t/deps.d - -// Check that the JSON parses correctly into the canonical Swift data -// structures. - -// RUN: mkdir -p %t/PrintGraph -// RUN: cp %S/Inputs/PrintGraph.swift %t/main.swift -// RUN: %target-build-swift %S/Inputs/ModuleDependencyGraph.swift %t/main.swift -o %t/main -// RUN: %target-codesign %t/main -// RUN: %target-run %t/main %t/deps.json - -// Ensure that round-trip serialization does not affect result -// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -test-dependency-scan-cache-serialization -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -// RUN: %validate-json %t/deps.json | %FileCheck %s - -// REQUIRES: executable_test -// REQUIRES: objc_interop -import SomeExternalModule - -// CHECK: "mainModuleName": "deps" - -/// --------Main module -// CHECK-LABEL: "modulePath": "deps.swiftmodule", -// CHECK-NEXT: sourceFiles -// CHECK-NEXT: module_deps_external.swift - -// CHECK: directDependencies -// CHECK-NEXT: { -// CHECK-DAG: "clang": "F" -// CHECK-DAG: "swiftPlaceholder": "SomeExternalModule" -// CHECK-DAG: "swift": "Swift" -// CHECK-DAG: "swift": "SwiftOnoneSupport" -// CHECK-DAG: "swift": "_Concurrency" -// CHECK-DAG: "swift": "_StringProcessing" -// CHECK-DAG: "clang": "_SwiftConcurrencyShims" -// CHECK: ], - -// CHECK: "bridgingHeader": -// CHECK-NEXT: "path": -// CHECK-SAME: Bridging.h - -// CHECK-NEXT: "sourceFiles": -// CHECK-NEXT: Bridging.h -// CHECK-NEXT: BridgingOther.h - -// CHECK: "moduleDependencies": [ -// CHECK-NEXT: "F" -// CHECK-NEXT: ], - -// CHECK: "swiftOverlayDependencies": [ -// CHECK-NEXT: { -// CHECK-NEXT: "swift": "F" -// CHECK-NEXT: } -// CHECK-NEXT: ] - -/// --------Swift external module SomeExternalModule -// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}SomeExternalModule.swiftmodule", -// CHECK-NEXT: "details": { -// CHECK-NEXT: "swiftPlaceholder": { -// CHECK-NEXT: "moduleDocPath": "BUILD_DIR/{{.*}}/ScanDependencies/Output/module_deps_external.swift.tmp/inputs/SomeExternalModule.swiftdoc", -// CHECK-NEXT: "moduleSourceInfoPath": "BUILD_DIR/{{.*}}/ScanDependencies/Output/module_deps_external.swift.tmp/inputs/SomeExternalModule.swiftsourceinfo" - -/// --------Swift module Swift -// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}Swift-{{.*}}.swiftmodule", - -// CHECK: directDependencies -// CHECK-NEXT: { -// CHECK-NEXT: "clang": "SwiftShims" - -/// --------Clang module SwiftShims -// CHECK-LABEL: "modulePath": "{{.*}}/SwiftShims-{{.*}}.pcm", - -// Check make-style dependencies -// CHECK-MAKE-DEPS: module_deps_external.swift -// CHECK-MAKE-DEPS-SAME: Bridging.h -// CHECK-MAKE-DEPS-SAME: BridgingOther.h -// CHECK-MAKE-DEPS-SAME: module.modulemap - diff --git a/test/ScanDependencies/placholder_overlay_deps.swift b/test/ScanDependencies/placholder_overlay_deps.swift deleted file mode 100644 index 16fa8106d0ccc..0000000000000 --- a/test/ScanDependencies/placholder_overlay_deps.swift +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: %empty-directory(%t) -// RUN: mkdir -p %t/clang-module-cache -// RUN: mkdir -p %t/inputs - -// RUN: echo "[{" > %/t/inputs/map.json -// RUN: echo "\"moduleName\": \"Darwin\"," >> %/t/inputs/map.json -// RUN: echo "\"modulePath\": \"%/t/inputs/Darwin.swiftmodule\"," >> %/t/inputs/map.json -// RUN: echo "\"docPath\": \"%/t/inputs/Darwin.swiftdoc\"," >> %/t/inputs/map.json -// RUN: echo "\"sourceInfoPath\": \"%/t/inputs/Darwin.swiftsourceinfo\"," >> %/t/inputs/map.json -// RUN: echo "\"isFramework\": false," >> %/t/inputs/map.json -// RUN: echo "\"isSystem\": true" >> %/t/inputs/map.json -// RUN: echo "}]" >> %/t/inputs/map.json - -// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json - -// Check the contents of the JSON output -// RUN: %validate-json %t/deps.json > %t/validated_deps.json -// RUN: %FileCheck %s < %t/validated_deps.json - -// REQUIRES: executable_test -// REQUIRES: objc_interop -// REQUIRES: OS=macosx -import Metal - -// Ensure the dependency on Darwin is captured even though it is a placeholder - -// CHECK: "modulePath": "{{.*}}{{/|\\}}Metal-{{.*}}.swiftmodule", -// CHECK: "directDependencies": [ -// CHECK: { -// CHECK: "swiftPlaceholder": "Darwin" -// CHECK: }, diff --git a/unittests/DependencyScan/ModuleDeps.cpp b/unittests/DependencyScan/ModuleDeps.cpp index 27c8edf24e98a..7cc3d62735f90 100644 --- a/unittests/DependencyScan/ModuleDeps.cpp +++ b/unittests/DependencyScan/ModuleDeps.cpp @@ -175,7 +175,7 @@ export *\n\ for (auto &command : CommandStrArr) { Command.push_back(command.c_str()); } - auto DependenciesOrErr = ScannerTool.getDependencies(Command, {}, {}); + auto DependenciesOrErr = ScannerTool.getDependencies(Command, {}); ASSERT_FALSE(DependenciesOrErr.getError()); auto Dependencies = DependenciesOrErr.get(); // TODO: Output/verify dependency graph correctness @@ -309,7 +309,7 @@ public func funcB() { }\n")); auto ScanDiagnosticConsumer = std::make_shared(); - auto DependenciesOrErr = ScannerTool.getDependencies(Command, {}, {}); + auto DependenciesOrErr = ScannerTool.getDependencies(Command, {}); // Ensure a hollow output with diagnostic info is produced ASSERT_FALSE(DependenciesOrErr.getError());