Skip to content

Commit 0ff8d8e

Browse files
committed
[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.
1 parent 68524a8 commit 0ff8d8e

25 files changed

+37
-639
lines changed

include/swift-c/DependencyScan/DependencyScan.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ typedef enum {
3636
// SwiftInterface and SwiftSource.
3737
SWIFTSCAN_DEPENDENCY_INFO_SWIFT_TEXTUAL = 0,
3838
SWIFTSCAN_DEPENDENCY_INFO_SWIFT_BINARY = 1,
39-
SWIFTSCAN_DEPENDENCY_INFO_SWIFT_PLACEHOLDER = 2,
4039
SWIFTSCAN_DEPENDENCY_INFO_CLANG = 3
4140
} swiftscan_dependency_info_kind_t;
4241

@@ -273,7 +272,8 @@ swiftscan_swift_binary_detail_get_module_cache_key(
273272
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
274273
swiftscan_swift_binary_detail_get_user_module_version(
275274
swiftscan_module_details_t details);
276-
//=== Swift Placeholder Module Details query APIs -------------------------===//
275+
276+
//=== Swift Placeholder Module Details query APIs - DEPRECATED -----------===//
277277

278278
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
279279
swiftscan_swift_placeholder_detail_get_compiled_module_path(

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,6 @@ ERROR(explicit_swift_module_map_corrupted,none,
362362
"explicit Swift module map from %0 is malformed",
363363
(StringRef))
364364

365-
ERROR(placeholder_dependency_module_map_missing,none,
366-
"cannot open Swift placeholder dependency module map from %0",
367-
(StringRef))
368-
369-
ERROR(placeholder_dependency_module_map_corrupted,none,
370-
"Swift placeholder dependency module map from %0 is malformed",
371-
(StringRef))
372-
373365
ERROR(const_extract_protocol_list_input_file_missing,none,
374366
"cannot open constant extraction protocol list input file from %0",
375367
(StringRef))

include/swift/AST/ModuleDependencies.h

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -68,30 +68,7 @@ enum class ModuleDependencyKind : int8_t {
6868
Clang,
6969
// Used to model the translation unit's source module
7070
SwiftSource,
71-
// Placeholder dependencies are a kind of dependencies used only by the
72-
// dependency scanner. They are swift modules that the scanner will not be
73-
// able to locate in its search paths and which are the responsibility of the
74-
// scanner's client to ensure are provided.
75-
//
76-
// Placeholder dependencies will be specified in the scanner's output
77-
// dependency graph where it is the responsibility of the scanner's client to
78-
// ensure required post-processing takes place to "resolve" them. In order to
79-
// do so, the client (swift driver, or any other client build system) is
80-
// expected to have access to a full dependency graph of all placeholder
81-
// dependencies and be able to replace placeholder nodes in the dependency
82-
// graph with their full dependency trees, `uniquing` common dependency module
83-
// nodes in the process.
84-
//
85-
// One example where placeholder dependencies are employed is when using
86-
// SwiftPM in Explicit Module Build mode. SwiftPM constructs a build plan for
87-
// all targets ahead-of-time. When planning a build for a target that depends
88-
// on other targets, the dependency scanning action is not able to locate
89-
// dependency target modules, because they have not yet been built. Instead,
90-
// the build system treats them as placeholder dependencies and resolves them
91-
// with `actual` dependencies in a post-processing step once dependency graphs
92-
// of all targets, individually, have been computed.
93-
SwiftPlaceholder,
94-
LastKind = SwiftPlaceholder + 1
71+
LastKind = SwiftSource + 1
9572
};
9673

9774
/// This is used to idenfity a specific macro plugin dependency.
@@ -530,39 +507,6 @@ class ClangModuleDependencyStorage : public ModuleDependencyInfoStorageBase {
530507
}
531508
};
532509

533-
/// Describes an placeholder Swift module dependency module stub.
534-
///
535-
/// This class is mostly an implementation detail for \c ModuleDependencyInfo.
536-
537-
class SwiftPlaceholderModuleDependencyStorage
538-
: public ModuleDependencyInfoStorageBase {
539-
public:
540-
SwiftPlaceholderModuleDependencyStorage(StringRef compiledModulePath,
541-
StringRef moduleDocPath,
542-
StringRef sourceInfoPath)
543-
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftPlaceholder, {}, {},
544-
{}),
545-
compiledModulePath(compiledModulePath), moduleDocPath(moduleDocPath),
546-
sourceInfoPath(sourceInfoPath) {}
547-
548-
ModuleDependencyInfoStorageBase *clone() const override {
549-
return new SwiftPlaceholderModuleDependencyStorage(*this);
550-
}
551-
552-
/// The path to the .swiftmodule file.
553-
const std::string compiledModulePath;
554-
555-
/// The path to the .swiftModuleDoc file.
556-
const std::string moduleDocPath;
557-
558-
/// The path to the .swiftSourceInfo file.
559-
const std::string sourceInfoPath;
560-
561-
static bool classof(const ModuleDependencyInfoStorageBase *base) {
562-
return base->dependencyKind == ModuleDependencyKind::SwiftPlaceholder;
563-
}
564-
};
565-
566510
// MARK: Module Dependency Info
567511
/// Describes the dependencies of a given module.
568512
///
@@ -661,16 +605,6 @@ class ModuleDependencyInfo {
661605
CASFileSystemRootID, clangIncludeTreeRoot, moduleCacheKey, IsSystem));
662606
}
663607

664-
/// Describe a placeholder dependency swift module.
665-
static ModuleDependencyInfo
666-
forPlaceholderSwiftModuleStub(StringRef compiledModulePath,
667-
StringRef moduleDocPath,
668-
StringRef sourceInfoPath) {
669-
return ModuleDependencyInfo(
670-
std::make_unique<SwiftPlaceholderModuleDependencyStorage>(
671-
compiledModulePath, moduleDocPath, sourceInfoPath));
672-
}
673-
674608
/// Retrieve the module-level imports.
675609
ArrayRef<ScannerImportStatementInfo> getModuleImports() const {
676610
return storage->moduleImports;
@@ -889,7 +823,7 @@ class ModuleDependencyInfo {
889823
bool isTestableImport(StringRef moduleName) const;
890824

891825
/// Whether the dependencies are for a Swift module: either Textual, Source,
892-
/// Binary, or Placeholder.
826+
/// or Binary
893827
bool isSwiftModule() const;
894828

895829
/// Whether the dependencies are for a textual interface Swift module or a
@@ -905,9 +839,6 @@ class ModuleDependencyInfo {
905839
/// Whether the dependencies are for a binary Swift module.
906840
bool isSwiftBinaryModule() const;
907841

908-
/// Whether this represents a placeholder module stub
909-
bool isSwiftPlaceholderModule() const;
910-
911842
/// Whether the dependencies are for a Clang module.
912843
bool isClangModule() const;
913844

@@ -926,10 +857,6 @@ class ModuleDependencyInfo {
926857
/// Retrieve the dependencies for a Clang module.
927858
const ClangModuleDependencyStorage *getAsClangModule() const;
928859

929-
/// Retrieve the dependencies for a placeholder dependency module stub.
930-
const SwiftPlaceholderModuleDependencyStorage *
931-
getAsPlaceholderDependencyModule() const;
932-
933860
/// Add a dependency on the given module, if it was not already in the set.
934861
void
935862
addOptionalModuleImport(StringRef module, bool isExported,

include/swift/DependencyScan/DependencyScanImpl.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ struct swiftscan_dependency_info_s {
4343
/// "swiftInterface"
4444
/// "swiftSource"
4545
/// "swiftBinary"
46-
/// "swiftPlaceholder"
4746
/// "clang""
4847
swiftscan_string_ref_t module_name;
4948

@@ -183,19 +182,6 @@ typedef struct {
183182
swiftscan_string_ref_t user_module_version;
184183
} swiftscan_swift_binary_details_t;
185184

186-
/// Swift placeholder modules carry additional details that specify their
187-
/// module doc path and source info paths.
188-
typedef struct {
189-
/// The path to the pre-compiled binary module
190-
swiftscan_string_ref_t compiled_module_path;
191-
192-
/// The path to the .swiftModuleDoc file.
193-
swiftscan_string_ref_t module_doc_path;
194-
195-
/// The path to the .swiftSourceInfo file.
196-
swiftscan_string_ref_t module_source_info_path;
197-
} swiftscan_swift_placeholder_details_t;
198-
199185
/// Clang modules are built from a module map file.
200186
typedef struct {
201187
/// The path to the module map used to build this module.
@@ -222,7 +208,6 @@ struct swiftscan_module_details_s {
222208
union {
223209
swiftscan_swift_textual_details_t swift_textual_details;
224210
swiftscan_swift_binary_details_t swift_binary_details;
225-
swiftscan_swift_placeholder_details_t swift_placeholder_details;
226211
swiftscan_clang_details_t clang_details;
227212
};
228213
};

include/swift/DependencyScan/DependencyScanningTool.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,12 @@ class DependencyScanningTool {
6868
/// Construct a dependency scanning tool.
6969
DependencyScanningTool();
7070

71-
/// Collect the full module dependency graph for the input, ignoring any
72-
/// placeholder modules.
71+
/// Collect the full module dependency graph for the input.
7372
///
7473
/// \returns a \c StringError with the diagnostic output if errors
7574
/// occurred, \c swiftscan_dependency_result_t otherwise.
7675
llvm::ErrorOr<swiftscan_dependency_graph_t>
7776
getDependencies(ArrayRef<const char *> Command,
78-
const llvm::StringSet<> &PlaceholderModules,
7977
StringRef WorkingDirectory);
8078

8179
/// Collect the set of imports for the input module

include/swift/DependencyScan/SerializedModuleDependencyCacheFormat.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ using llvm::BCVBR;
3939

4040
/// Every .moddepcache file begins with these 4 bytes, for easy identification.
4141
const unsigned char MODULE_DEPENDENCY_CACHE_FORMAT_SIGNATURE[] = {'I', 'M', 'D','C'};
42-
const unsigned MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MAJOR = 9;
42+
const unsigned MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MAJOR = 10;
4343
/// Increment this on every change.
4444
const unsigned MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MINOR = 2;
4545

@@ -106,7 +106,6 @@ enum {
106106
OPTIONAL_IMPORT_STATEMENT_ARRAY_NODE,
107107
SWIFT_INTERFACE_MODULE_DETAILS_NODE,
108108
SWIFT_SOURCE_MODULE_DETAILS_NODE,
109-
SWIFT_PLACEHOLDER_MODULE_DETAILS_NODE,
110109
SWIFT_BINARY_MODULE_DETAILS_NODE,
111110
CLANG_MODULE_DETAILS_NODE,
112111
IDENTIFIER_NODE,
@@ -190,7 +189,6 @@ using OptionalImportStatementArrayLayout =
190189
// - SwiftInterfaceModuleDetails
191190
// - SwiftSourceModuleDetails
192191
// - SwiftBinaryModuleDetails
193-
// - SwiftPlaceholderModuleDetails
194192
// - ClangModuleDetails
195193
using ModuleInfoLayout =
196194
BCRecordLayout<MODULE_NODE, // ID
@@ -254,13 +252,6 @@ using SwiftBinaryModuleDetailsLayout =
254252
IdentifierIDField // UserModuleVersion
255253
>;
256254

257-
using SwiftPlaceholderModuleDetailsLayout =
258-
BCRecordLayout<SWIFT_PLACEHOLDER_MODULE_DETAILS_NODE, // ID
259-
FileIDField, // compiledModulePath
260-
FileIDField, // moduleDocPath
261-
FileIDField // moduleSourceInfoPath
262-
>;
263-
264255
using ClangModuleDetailsLayout =
265256
BCRecordLayout<CLANG_MODULE_DETAILS_NODE, // ID
266257
FileIDField, // pcmOutputPath

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,6 @@ def const_gather_protocols_file
255255
: Separate<["-"], "const-gather-protocols-file">, MetaVarName<"<path>">,
256256
HelpText<"Specify a list of protocols for extraction of conformances' const values'">;
257257

258-
def placeholder_dependency_module_map
259-
: Separate<["-"], "placeholder-dependency-module-map-file">, MetaVarName<"<path>">,
260-
HelpText<"Specify a JSON file containing information of external Swift module dependencies">;
261-
262258
def import_prescan : Flag<["-"], "import-prescan">,
263259
HelpText<"When performing a dependency scan, only identify all imports of the main Swift module sources">;
264260

include/swift/Serialization/ScanningLoaders.h

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -83,51 +83,6 @@ class SwiftModuleScanner : public SerializedModuleLoaderBase {
8383
return MDS->getKind() == MDS_plain;
8484
}
8585
};
86-
87-
/// A ModuleLoader that loads placeholder dependency module stubs specified in
88-
/// -placeholder-dependency-module-map-file
89-
/// This loader is used only in dependency scanning to inform the scanner that a
90-
/// set of modules constitute placeholder dependencies that are not visible to
91-
/// the scanner but will nevertheless be provided by the scanner's clients. This
92-
/// "loader" will not attempt to load any module files.
93-
class PlaceholderSwiftModuleScanner : public SwiftModuleScanner {
94-
/// Scan the given placeholder module map
95-
void parsePlaceholderModuleMap(StringRef fileName);
96-
97-
llvm::StringMap<ExplicitSwiftModuleInputInfo> PlaceholderDependencyModuleMap;
98-
llvm::BumpPtrAllocator Allocator;
99-
100-
public:
101-
PlaceholderSwiftModuleScanner(ASTContext &ctx, ModuleLoadingMode LoadMode,
102-
Identifier moduleName,
103-
StringRef PlaceholderDependencyModuleMap,
104-
InterfaceSubContextDelegate &astDelegate,
105-
StringRef moduleOutputPath,
106-
StringRef sdkModuleOutputPath)
107-
: SwiftModuleScanner(ctx, LoadMode, moduleName, astDelegate,
108-
moduleOutputPath, sdkModuleOutputPath, {},
109-
MDS_placeholder) {
110-
// FIXME: Find a better place for this map to live, to avoid
111-
// doing the parsing on every module.
112-
if (!PlaceholderDependencyModuleMap.empty()) {
113-
parsePlaceholderModuleMap(PlaceholderDependencyModuleMap);
114-
}
115-
}
116-
117-
virtual bool
118-
findModule(ImportPath::Element moduleID,
119-
SmallVectorImpl<char> *moduleInterfacePath,
120-
SmallVectorImpl<char> *moduleInterfaceSourcePath,
121-
std::unique_ptr<llvm::MemoryBuffer> *moduleBuffer,
122-
std::unique_ptr<llvm::MemoryBuffer> *moduleDocBuffer,
123-
std::unique_ptr<llvm::MemoryBuffer> *moduleSourceInfoBuffer,
124-
bool skipBuildingInterface, bool isTestableDependencyLookup,
125-
bool &isFramework, bool &isSystemModule) override;
126-
127-
static bool classof(const SwiftModuleScanner *MDS) {
128-
return MDS->getKind() == MDS_placeholder;
129-
}
130-
};
13186
} // namespace swift
13287

13388
#endif // SWIFT_SCANNINGLOADERS_H

lib/AST/ModuleDependencies.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ModuleDependencyInfoStorageBase::~ModuleDependencyInfoStorageBase() {}
3636

3737
bool ModuleDependencyInfo::isSwiftModule() const {
3838
return isSwiftInterfaceModule() || isSwiftSourceModule() ||
39-
isSwiftBinaryModule() || isSwiftPlaceholderModule();
39+
isSwiftBinaryModule();
4040
}
4141

4242
bool ModuleDependencyInfo::isTextualSwiftModule() const {
@@ -66,10 +66,6 @@ bool ModuleDependencyInfo::isSwiftBinaryModule() const {
6666
return isa<SwiftBinaryModuleDependencyStorage>(storage.get());
6767
}
6868

69-
bool ModuleDependencyInfo::isSwiftPlaceholderModule() const {
70-
return isa<SwiftPlaceholderModuleDependencyStorage>(storage.get());
71-
}
72-
7369
bool ModuleDependencyInfo::isClangModule() const {
7470
return isa<ClangModuleDependencyStorage>(storage.get());
7571
}
@@ -97,12 +93,6 @@ ModuleDependencyInfo::getAsClangModule() const {
9793
return dyn_cast<ClangModuleDependencyStorage>(storage.get());
9894
}
9995

100-
/// Retrieve the dependencies for a placeholder dependency module stub.
101-
const SwiftPlaceholderModuleDependencyStorage *
102-
ModuleDependencyInfo::getAsPlaceholderDependencyModule() const {
103-
return dyn_cast<SwiftPlaceholderModuleDependencyStorage>(storage.get());
104-
}
105-
10696
void ModuleDependencyInfo::addTestableImport(ImportPath::Module module) {
10797
assert(getAsSwiftSourceModule() && "Expected source module for addTestableImport.");
10898
dyn_cast<SwiftSourceModuleDependenciesStorage>(storage.get())->addTestableImport(module);
@@ -361,11 +351,6 @@ std::string ModuleDependencyInfo::getModuleOutputPath() const {
361351
cast<SwiftBinaryModuleDependencyStorage>(storage.get());
362352
return swiftBinaryStorage->compiledModulePath;
363353
}
364-
case swift::ModuleDependencyKind::SwiftPlaceholder: {
365-
auto swiftPlaceholderStorage =
366-
cast<SwiftPlaceholderModuleDependencyStorage>(storage.get());
367-
return swiftPlaceholderStorage->compiledModulePath;
368-
}
369354
default:
370355
llvm_unreachable("Unexpected dependency kind");
371356
}
@@ -849,8 +834,6 @@ ModuleDependenciesCache::findSwiftDependency(StringRef moduleName) const {
849834
return found;
850835
if (auto found = findDependency(moduleName, ModuleDependencyKind::SwiftSource))
851836
return found;
852-
if (auto found = findDependency(moduleName, ModuleDependencyKind::SwiftPlaceholder))
853-
return found;
854837
return std::nullopt;
855838
}
856839

lib/AST/ModuleLoader.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,6 @@ ModuleDependencyInfo::collectCrossImportOverlayNames(
240240
case swift::ModuleDependencyKind::SwiftSource: {
241241
return result;
242242
}
243-
case swift::ModuleDependencyKind::SwiftPlaceholder: {
244-
return result;
245-
}
246243
case swift::ModuleDependencyKind::LastKind:
247244
llvm_unreachable("Unhandled dependency kind.");
248245
}

0 commit comments

Comments
 (0)