Skip to content

Commit 41e4712

Browse files
committed
[Dependency Scanning] Deprecate/Remove batch scanning capability
Batch dependency scanning was added as a mechanism to support multiple compilation contexts within a single module dependency graph. The Swift compiler and the Explicitly-built modules model has long since abandoned this approach and this code has long been stale. It is time to remove it and its associated C API.
1 parent eb1ea4e commit 41e4712

18 files changed

+4
-692
lines changed

include/swift-c/DependencyScan/DependencyScan.h

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -292,48 +292,6 @@ swiftscan_clang_detail_get_cas_fs_root_id(swiftscan_module_details_t details);
292292
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
293293
swiftscan_clang_detail_get_module_cache_key(swiftscan_module_details_t details);
294294

295-
//=== Batch Scan Input Functions ------------------------------------------===//
296-
297-
/// Create an \c swiftscan_batch_scan_input_t instance.
298-
/// The returned \c swiftscan_batch_scan_input_t is owned by the caller and must be disposed
299-
/// of using \c swiftscan_batch_scan_input_dispose .
300-
SWIFTSCAN_PUBLIC swiftscan_batch_scan_input_t *
301-
swiftscan_batch_scan_input_create();
302-
303-
SWIFTSCAN_PUBLIC void
304-
swiftscan_batch_scan_input_set_modules(swiftscan_batch_scan_input_t *input,
305-
int count,
306-
swiftscan_batch_scan_entry_t *modules);
307-
308-
//=== Batch Scan Entry Functions ------------------------------------------===//
309-
310-
/// Create an \c swiftscan_batch_scan_entry_t instance.
311-
/// The returned \c swiftscan_batch_scan_entry_t is owned by the caller and must be disposed
312-
/// of using \c swiftscan_batch_scan_entry_dispose .
313-
SWIFTSCAN_PUBLIC swiftscan_batch_scan_entry_t
314-
swiftscan_batch_scan_entry_create();
315-
316-
SWIFTSCAN_PUBLIC void
317-
swiftscan_batch_scan_entry_set_module_name(swiftscan_batch_scan_entry_t entry,
318-
const char *name);
319-
320-
SWIFTSCAN_PUBLIC void
321-
swiftscan_batch_scan_entry_set_arguments(swiftscan_batch_scan_entry_t entry,
322-
const char *arguments);
323-
324-
SWIFTSCAN_PUBLIC void
325-
swiftscan_batch_scan_entry_set_is_swift(swiftscan_batch_scan_entry_t entry,
326-
bool is_swift);
327-
328-
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
329-
swiftscan_batch_scan_entry_get_module_name(swiftscan_batch_scan_entry_t entry);
330-
331-
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
332-
swiftscan_batch_scan_entry_get_arguments(swiftscan_batch_scan_entry_t entry);
333-
334-
SWIFTSCAN_PUBLIC bool
335-
swiftscan_batch_scan_entry_get_is_swift(swiftscan_batch_scan_entry_t entry);
336-
337295
//=== Prescan Result Functions --------------------------------------------===//
338296

339297
SWIFTSCAN_PUBLIC swiftscan_string_set_t *
@@ -382,15 +340,6 @@ swiftscan_dependency_graph_dispose(swiftscan_dependency_graph_t result);
382340
SWIFTSCAN_PUBLIC void
383341
swiftscan_import_set_dispose(swiftscan_import_set_t result);
384342

385-
SWIFTSCAN_PUBLIC void
386-
swiftscan_batch_scan_entry_dispose(swiftscan_batch_scan_entry_t entry);
387-
388-
SWIFTSCAN_PUBLIC void
389-
swiftscan_batch_scan_input_dispose(swiftscan_batch_scan_input_t *input);
390-
391-
SWIFTSCAN_PUBLIC void
392-
swiftscan_batch_scan_result_dispose(swiftscan_batch_scan_result_t *result);
393-
394343
SWIFTSCAN_PUBLIC void
395344
swiftscan_scan_invocation_dispose(swiftscan_scan_invocation_t invocation);
396345

@@ -427,15 +376,6 @@ SWIFTSCAN_PUBLIC void swiftscan_scanner_dispose(swiftscan_scanner_t);
427376
SWIFTSCAN_PUBLIC swiftscan_dependency_graph_t swiftscan_dependency_graph_create(
428377
swiftscan_scanner_t scanner, swiftscan_scan_invocation_t invocation);
429378

430-
/// Invoke the scan for an input batch of modules specified in the
431-
/// \c swiftscan_batch_scan_input_t argument. The returned
432-
/// \c swiftscan_batch_scan_result_t is owned by the caller and must be disposed
433-
/// of using \c swiftscan_batch_scan_result_dispose .
434-
SWIFTSCAN_PUBLIC swiftscan_batch_scan_result_t *
435-
swiftscan_batch_scan_result_create(swiftscan_scanner_t scanner,
436-
swiftscan_batch_scan_input_t *batch_input,
437-
swiftscan_scan_invocation_t invocation);
438-
439379
/// Invoke the import prescan using arguments specified in the \c
440380
/// swiftscan_scan_invocation_t argument. The returned \c swiftscan_import_set_t
441381
/// is owned by the caller and must be disposed of using \c

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,18 +354,10 @@ ERROR(placeholder_dependency_module_map_corrupted,none,
354354
"Swift placeholder dependency module map from %0 is malformed",
355355
(StringRef))
356356

357-
ERROR(batch_scan_input_file_missing,none,
358-
"cannot open batch dependencies scan input file from %0",
359-
(StringRef))
360-
361357
ERROR(const_extract_protocol_list_input_file_missing,none,
362358
"cannot open constant extraction protocol list input file from %0",
363359
(StringRef))
364360

365-
ERROR(batch_scan_input_file_corrupted,none,
366-
"batch dependencies scan input file from %0 is malformed",
367-
(StringRef))
368-
369361
ERROR(const_extract_protocol_list_input_file_corrupted,none,
370362
"constant extraction protocol list input file from %0 is malformed",
371363
(StringRef))

include/swift/AST/SearchPathOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,6 @@ class SearchPathOptions {
530530
/// A map of placeholder Swift module dependency information.
531531
std::string PlaceholderDependencyModuleMap;
532532

533-
/// A file containing modules we should perform batch scanning.
534-
std::string BatchScanInputFilePath;
535-
536533
/// A file containing a list of protocols whose conformances require const value extraction.
537534
std::string ConstGatherProtocolListFilePath;
538535

include/swift/DependencyScan/DependencyScanImpl.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,6 @@ struct swiftscan_module_details_s {
224224
};
225225
};
226226

227-
struct swiftscan_batch_scan_entry_s {
228-
swiftscan_string_ref_t module_name;
229-
swiftscan_string_ref_t arguments;
230-
bool is_swift;
231-
};
232-
233227
struct swiftscan_import_set_s {
234228
/// The complete list of imports discovered
235229
swiftscan_string_set_t *imports;

include/swift/DependencyScan/DependencyScanningTool.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,6 @@ class DependencyScanningTool {
9797
llvm::ErrorOr<swiftscan_import_set_t>
9898
getImports(ArrayRef<const char *> Command, StringRef WorkingDirectory);
9999

100-
/// Collect the full module dependency graph for the input collection of
101-
/// module names (batch inputs) and output them to the
102-
/// BatchScanInput-specified output locations.
103-
///
104-
/// \returns a \c std::error_code if errors occurred during scan.
105-
std::vector<llvm::ErrorOr<swiftscan_dependency_graph_t>>
106-
getDependencies(ArrayRef<const char *> Command,
107-
const std::vector<BatchScanInput> &BatchInput,
108-
const llvm::StringSet<> &PlaceholderModules,
109-
StringRef WorkingDirectory);
110-
111100
/// Query diagnostics consumed so far.
112101
std::vector<DependencyScanDiagnosticCollector::ScannerDiagnosticInfo> getDiagnostics();
113102
/// Discared the collection of diagnostics encountered so far.
@@ -125,10 +114,6 @@ class DependencyScanningTool {
125114
/// during the lifetime of this Tool.
126115
std::unique_ptr<SwiftDependencyScanningService> ScanningService;
127116

128-
/// Shared cache of compiler instances created during batch scanning, corresponding to
129-
/// command-line options specified in the batch scan input entry.
130-
std::unique_ptr<CompilerArgInstanceCacheMap> VersionedPCMInstanceCacheCache;
131-
132117
/// Shared state mutual-exclusivity lock
133118
llvm::sys::SmartMutex<true> DependencyScanningToolStateLock;
134119

include/swift/DependencyScan/ScanDependencies.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ using CompilerArgInstanceCacheMap =
3737
std::unique_ptr<SwiftDependencyScanningService>,
3838
std::unique_ptr<ModuleDependenciesCache>>>;
3939

40-
struct BatchScanInput {
41-
llvm::StringRef moduleName;
42-
llvm::StringRef arguments;
43-
llvm::StringRef outputPath;
44-
bool isSwift;
45-
};
46-
4740
// MARK: FrontendTool dependency scanner entry points
4841
/// Scans the dependencies of the main module of \c instance and writes out
4942
/// the resulting JSON according to the instance's output parameters.
@@ -52,10 +45,6 @@ bool scanDependencies(CompilerInstance &instance);
5245
/// Identify all imports in the translation unit's module.
5346
bool prescanDependencies(CompilerInstance &instance);
5447

55-
/// Batch scan the dependencies for modules specified in \c batchInputFile.
56-
bool batchScanDependencies(CompilerInstance &instance,
57-
llvm::StringRef batchInputFile);
58-
5948
// MARK: Dependency scanning execution
6049
/// Scans the dependencies of the main module of \c instance.
6150
llvm::ErrorOr<swiftscan_dependency_graph_t>
@@ -69,14 +58,6 @@ performModulePrescan(CompilerInstance &instance,
6958
DependencyScanDiagnosticCollector *diagnostics,
7059
ModuleDependenciesCache &cache);
7160

72-
/// Batch scan the dependencies for modules specified in \c batchInputFile.
73-
std::vector<llvm::ErrorOr<swiftscan_dependency_graph_t>>
74-
performBatchModuleScan(CompilerInstance &invocationInstance,
75-
DependencyScanDiagnosticCollector *diagnostics,
76-
ModuleDependenciesCache &invocationCache,
77-
CompilerArgInstanceCacheMap *versionedPCMInstanceCache,
78-
llvm::StringSaver &saver,
79-
const std::vector<BatchScanInput> &BatchInput);
8061
} // end namespace dependencies
8162
} // end namespace swift
8263

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,6 @@ def placeholder_dependency_module_map
259259
: Separate<["-"], "placeholder-dependency-module-map-file">, MetaVarName<"<path>">,
260260
HelpText<"Specify a JSON file containing information of external Swift module dependencies">;
261261

262-
def batch_scan_input_file
263-
: Separate<["-"], "batch-scan-input-file">, MetaVarName<"<path>">,
264-
HelpText<"Specify a JSON file containing modules to perform batch dependencies scanning">;
265-
266262
def import_prescan : Flag<["-"], "import-prescan">,
267263
HelpText<"When performing a dependency scan, only identify all imports of the main Swift module sources">;
268264

lib/DependencyScan/DependencyScanningTool.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,6 @@ static swiftscan_import_set_t generateHollowDiagnosticOutputImportSet(
261261

262262
DependencyScanningTool::DependencyScanningTool()
263263
: ScanningService(std::make_unique<SwiftDependencyScanningService>()),
264-
VersionedPCMInstanceCacheCache(
265-
std::make_unique<CompilerArgInstanceCacheMap>()),
266264
CDC(), Alloc(), Saver(Alloc) {}
267265

268266
llvm::ErrorOr<swiftscan_dependency_graph_t>
@@ -327,35 +325,6 @@ DependencyScanningTool::getImports(ArrayRef<const char *> Command,
327325
return std::move(*DependenciesOrErr);
328326
}
329327

330-
std::vector<llvm::ErrorOr<swiftscan_dependency_graph_t>>
331-
DependencyScanningTool::getDependencies(
332-
ArrayRef<const char *> Command,
333-
const std::vector<BatchScanInput> &BatchInput,
334-
const llvm::StringSet<> &PlaceholderModules, StringRef WorkingDirectory) {
335-
// The primary instance used to scan Swift modules
336-
auto ScanDiagnosticConsumer = std::make_shared<DependencyScanDiagnosticCollector>();
337-
auto QueryContextOrErr = initCompilerInstanceForScan(Command,
338-
WorkingDirectory,
339-
ScanDiagnosticConsumer);
340-
if (std::error_code EC = QueryContextOrErr.getError())
341-
return std::vector<llvm::ErrorOr<swiftscan_dependency_graph_t>>(
342-
BatchInput.size(), std::make_error_code(std::errc::invalid_argument));
343-
344-
auto QueryContext = std::move(*QueryContextOrErr);
345-
346-
// Local scan cache instance, wrapping the shared global cache.
347-
ModuleDependenciesCache cache(
348-
*ScanningService, QueryContext.ScanInstance->getMainModule()->getNameStr().str(),
349-
QueryContext.ScanInstance->getInvocation().getFrontendOptions().ExplicitModulesOutputPath,
350-
QueryContext.ScanInstance->getInvocation().getModuleScanningHash());
351-
auto BatchScanResults = performBatchModuleScan(
352-
*QueryContext.ScanInstance.get(), QueryContext.ScanDiagnostics.get(),
353-
cache, VersionedPCMInstanceCacheCache.get(),
354-
Saver, BatchInput);
355-
356-
return BatchScanResults;
357-
}
358-
359328
std::vector<
360329
DependencyScanDiagnosticCollector::ScannerDiagnosticInfo>
361330
DependencyScanningTool::getDiagnostics() {

lib/DependencyScan/ModuleDependencyScanner.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ findPathToDependency(ModuleDependencyID dependency,
7878
const ModuleDependenciesCache &cache) {
7979
auto mainModuleDep = cache.findDependency(cache.getMainModuleName(),
8080
ModuleDependencyKind::SwiftSource);
81-
// We may be in a batch scan instance which does not have this dependency
8281
if (!mainModuleDep.has_value())
8382
return {};
8483
auto mainModuleID = ModuleDependencyID{cache.getMainModuleName().str(),

0 commit comments

Comments
 (0)