Skip to content

Commit 5eb85ac

Browse files
authored
Merge pull request #82031 from artemcm/RemovePlaceholdersInDepScanner
[Dependency Scanning] Remove obsolete placeholder module concept
2 parents edc7109 + a78ee29 commit 5eb85ac

25 files changed

+37
-642
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

@@ -310,7 +309,8 @@ swiftscan_swift_binary_detail_get_module_cache_key(
310309
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
311310
swiftscan_swift_binary_detail_get_user_module_version(
312311
swiftscan_module_details_t details);
313-
//=== Swift Placeholder Module Details query APIs -------------------------===//
312+
313+
//=== Swift Placeholder Module Details query APIs - DEPRECATED -----------===//
314314

315315
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
316316
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
@@ -360,14 +360,6 @@ ERROR(explicit_swift_module_map_corrupted,none,
360360
"explicit Swift module map from %0 is malformed",
361361
(StringRef))
362362

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

include/swift/AST/ModuleDependencies.h

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

9875
/// This is used to idenfity a specific macro plugin dependency.
@@ -542,39 +519,6 @@ class ClangModuleDependencyStorage : public ModuleDependencyInfoStorageBase {
542519
}
543520
};
544521

545-
/// Describes an placeholder Swift module dependency module stub.
546-
///
547-
/// This class is mostly an implementation detail for \c ModuleDependencyInfo.
548-
549-
class SwiftPlaceholderModuleDependencyStorage
550-
: public ModuleDependencyInfoStorageBase {
551-
public:
552-
SwiftPlaceholderModuleDependencyStorage(StringRef compiledModulePath,
553-
StringRef moduleDocPath,
554-
StringRef sourceInfoPath)
555-
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftPlaceholder, {}, {},
556-
{}),
557-
compiledModulePath(compiledModulePath), moduleDocPath(moduleDocPath),
558-
sourceInfoPath(sourceInfoPath) {}
559-
560-
ModuleDependencyInfoStorageBase *clone() const override {
561-
return new SwiftPlaceholderModuleDependencyStorage(*this);
562-
}
563-
564-
/// The path to the .swiftmodule file.
565-
const std::string compiledModulePath;
566-
567-
/// The path to the .swiftModuleDoc file.
568-
const std::string moduleDocPath;
569-
570-
/// The path to the .swiftSourceInfo file.
571-
const std::string sourceInfoPath;
572-
573-
static bool classof(const ModuleDependencyInfoStorageBase *base) {
574-
return base->dependencyKind == ModuleDependencyKind::SwiftPlaceholder;
575-
}
576-
};
577-
578522
// MARK: Module Dependency Info
579523
/// Describes the dependencies of a given module.
580524
///
@@ -675,16 +619,6 @@ class ModuleDependencyInfo {
675619
CASFileSystemRootID, clangIncludeTreeRoot, moduleCacheKey, IsSystem));
676620
}
677621

678-
/// Describe a placeholder dependency swift module.
679-
static ModuleDependencyInfo
680-
forPlaceholderSwiftModuleStub(StringRef compiledModulePath,
681-
StringRef moduleDocPath,
682-
StringRef sourceInfoPath) {
683-
return ModuleDependencyInfo(
684-
std::make_unique<SwiftPlaceholderModuleDependencyStorage>(
685-
compiledModulePath, moduleDocPath, sourceInfoPath));
686-
}
687-
688622
/// Retrieve the module-level imports.
689623
ArrayRef<ScannerImportStatementInfo> getModuleImports() const {
690624
return storage->moduleImports;
@@ -903,7 +837,7 @@ class ModuleDependencyInfo {
903837
bool isTestableImport(StringRef moduleName) const;
904838

905839
/// Whether the dependencies are for a Swift module: either Textual, Source,
906-
/// Binary, or Placeholder.
840+
/// or Binary
907841
bool isSwiftModule() const;
908842

909843
/// Whether the dependencies are for a textual interface Swift module or a
@@ -919,9 +853,6 @@ class ModuleDependencyInfo {
919853
/// Whether the dependencies are for a binary Swift module.
920854
bool isSwiftBinaryModule() const;
921855

922-
/// Whether this represents a placeholder module stub
923-
bool isSwiftPlaceholderModule() const;
924-
925856
/// Whether the dependencies are for a Clang module.
926857
bool isClangModule() const;
927858

@@ -940,10 +871,6 @@ class ModuleDependencyInfo {
940871
/// Retrieve the dependencies for a Clang module.
941872
const ClangModuleDependencyStorage *getAsClangModule() const;
942873

943-
/// Retrieve the dependencies for a placeholder dependency module stub.
944-
const SwiftPlaceholderModuleDependencyStorage *
945-
getAsPlaceholderDependencyModule() const;
946-
947874
/// Add a dependency on the given module, if it was not already in the set.
948875
void
949876
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

@@ -192,19 +191,6 @@ typedef struct {
192191
swiftscan_string_ref_t user_module_version;
193192
} swiftscan_swift_binary_details_t;
194193

195-
/// Swift placeholder modules carry additional details that specify their
196-
/// module doc path and source info paths.
197-
typedef struct {
198-
/// The path to the pre-compiled binary module
199-
swiftscan_string_ref_t compiled_module_path;
200-
201-
/// The path to the .swiftModuleDoc file.
202-
swiftscan_string_ref_t module_doc_path;
203-
204-
/// The path to the .swiftSourceInfo file.
205-
swiftscan_string_ref_t module_source_info_path;
206-
} swiftscan_swift_placeholder_details_t;
207-
208194
/// Clang modules are built from a module map file.
209195
typedef struct {
210196
/// The path to the module map used to build this module.
@@ -231,7 +217,6 @@ struct swiftscan_module_details_s {
231217
union {
232218
swiftscan_swift_textual_details_t swift_textual_details;
233219
swiftscan_swift_binary_details_t swift_binary_details;
234-
swiftscan_swift_placeholder_details_t swift_placeholder_details;
235220
swiftscan_clang_details_t clang_details;
236221
};
237222
};

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 = 3;
4545

@@ -112,7 +112,6 @@ enum {
112112
OPTIONAL_IMPORT_STATEMENT_ARRAY_NODE,
113113
SWIFT_INTERFACE_MODULE_DETAILS_NODE,
114114
SWIFT_SOURCE_MODULE_DETAILS_NODE,
115-
SWIFT_PLACEHOLDER_MODULE_DETAILS_NODE,
116115
SWIFT_BINARY_MODULE_DETAILS_NODE,
117116
CLANG_MODULE_DETAILS_NODE,
118117
IDENTIFIER_NODE,
@@ -208,7 +207,6 @@ using OptionalImportStatementArrayLayout =
208207
// - SwiftInterfaceModuleDetails
209208
// - SwiftSourceModuleDetails
210209
// - SwiftBinaryModuleDetails
211-
// - SwiftPlaceholderModuleDetails
212210
// - ClangModuleDetails
213211
using ModuleInfoLayout =
214212
BCRecordLayout<MODULE_NODE, // ID
@@ -273,13 +271,6 @@ using SwiftBinaryModuleDetailsLayout =
273271
IdentifierIDField // UserModuleVersion
274272
>;
275273

276-
using SwiftPlaceholderModuleDetailsLayout =
277-
BCRecordLayout<SWIFT_PLACEHOLDER_MODULE_DETAILS_NODE, // ID
278-
FileIDField, // compiledModulePath
279-
FileIDField, // moduleDocPath
280-
FileIDField // moduleSourceInfoPath
281-
>;
282-
283274
using ClangModuleDetailsLayout =
284275
BCRecordLayout<CLANG_MODULE_DETAILS_NODE, // ID
285276
FileIDField, // pcmOutputPath

include/swift/Option/FrontendOptions.td

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

261-
def placeholder_dependency_module_map
262-
: Separate<["-"], "placeholder-dependency-module-map-file">, MetaVarName<"<path>">,
263-
HelpText<"Specify a JSON file containing information of external Swift module dependencies">;
264-
265261
def import_prescan : Flag<["-"], "import-prescan">,
266262
HelpText<"When performing a dependency scan, only identify all imports of the main Swift module sources">;
267263

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);
@@ -388,11 +378,6 @@ std::string ModuleDependencyInfo::getModuleOutputPath() const {
388378
cast<SwiftBinaryModuleDependencyStorage>(storage.get());
389379
return swiftBinaryStorage->compiledModulePath;
390380
}
391-
case swift::ModuleDependencyKind::SwiftPlaceholder: {
392-
auto swiftPlaceholderStorage =
393-
cast<SwiftPlaceholderModuleDependencyStorage>(storage.get());
394-
return swiftPlaceholderStorage->compiledModulePath;
395-
}
396381
default:
397382
llvm_unreachable("Unexpected dependency kind");
398383
}
@@ -876,8 +861,6 @@ ModuleDependenciesCache::findSwiftDependency(StringRef moduleName) const {
876861
return found;
877862
if (auto found = findDependency(moduleName, ModuleDependencyKind::SwiftSource))
878863
return found;
879-
if (auto found = findDependency(moduleName, ModuleDependencyKind::SwiftPlaceholder))
880-
return found;
881864
return std::nullopt;
882865
}
883866

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)