Skip to content

[Dependency Scanning] Deprecate/Remove batch scanning capability #77719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 58 additions & 67 deletions include/swift-c/DependencyScan/DependencyScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/// The version constants for the SwiftDependencyScan C API.
/// SWIFTSCAN_VERSION_MINOR should increase when there are API additions.
/// SWIFTSCAN_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
#define SWIFTSCAN_VERSION_MAJOR 1
#define SWIFTSCAN_VERSION_MAJOR 2
#define SWIFTSCAN_VERSION_MINOR 0

SWIFTSCAN_BEGIN_DECLS
Expand Down Expand Up @@ -94,20 +94,20 @@ typedef struct {
size_t count;
} swiftscan_diagnostic_set_t;

//=== Batch Scan Input Specification --------------------------------------===//
//=== Batch Scan Input Specification -------DEPRECATED--------------------===//

/// Opaque container to a container of batch scan entry information.
typedef struct swiftscan_batch_scan_entry_s *swiftscan_batch_scan_entry_t;
/// Opaque container to a container of batch scan entry information.
typedef struct swiftscan_batch_scan_entry_s *swiftscan_batch_scan_entry_t;

typedef struct {
swiftscan_batch_scan_entry_t *modules;
size_t count;
} swiftscan_batch_scan_input_t;
typedef struct {
swiftscan_batch_scan_entry_t *modules;
size_t count;
} swiftscan_batch_scan_input_t;

typedef struct {
swiftscan_dependency_graph_t *results;
size_t count;
} swiftscan_batch_scan_result_t;
typedef struct {
swiftscan_dependency_graph_t *results;
size_t count;
} swiftscan_batch_scan_result_t;

//=== Scanner Invocation Specification ------------------------------------===//

Expand Down Expand Up @@ -194,9 +194,10 @@ SWIFTSCAN_PUBLIC swiftscan_string_set_t *
swiftscan_swift_textual_detail_get_bridging_pch_command_line(
swiftscan_module_details_t details);

// DEPRECATED
SWIFTSCAN_PUBLIC swiftscan_string_set_t *
swiftscan_swift_textual_detail_get_extra_pcm_args(
swiftscan_module_details_t details);
swiftscan_swift_textual_detail_get_extra_pcm_args(
swiftscan_module_details_t details);

SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_swift_textual_detail_get_context_hash(
Expand Down Expand Up @@ -283,6 +284,7 @@ swiftscan_clang_detail_get_context_hash(swiftscan_module_details_t details);
SWIFTSCAN_PUBLIC swiftscan_string_set_t *
swiftscan_clang_detail_get_command_line(swiftscan_module_details_t details);

// DEPRECATED
SWIFTSCAN_PUBLIC swiftscan_string_set_t *
swiftscan_clang_detail_get_captured_pcm_args(swiftscan_module_details_t details);

Expand All @@ -292,47 +294,39 @@ swiftscan_clang_detail_get_cas_fs_root_id(swiftscan_module_details_t details);
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_clang_detail_get_module_cache_key(swiftscan_module_details_t details);

//=== Batch Scan Input Functions ------------------------------------------===//

/// Create an \c swiftscan_batch_scan_input_t instance.
/// The returned \c swiftscan_batch_scan_input_t is owned by the caller and must be disposed
/// of using \c swiftscan_batch_scan_input_dispose .
SWIFTSCAN_PUBLIC swiftscan_batch_scan_input_t *
swiftscan_batch_scan_input_create();

SWIFTSCAN_PUBLIC void
swiftscan_batch_scan_input_set_modules(swiftscan_batch_scan_input_t *input,
int count,
swiftscan_batch_scan_entry_t *modules);

//=== Batch Scan Entry Functions ------------------------------------------===//

/// Create an \c swiftscan_batch_scan_entry_t instance.
/// The returned \c swiftscan_batch_scan_entry_t is owned by the caller and must be disposed
/// of using \c swiftscan_batch_scan_entry_dispose .
SWIFTSCAN_PUBLIC swiftscan_batch_scan_entry_t
swiftscan_batch_scan_entry_create();

SWIFTSCAN_PUBLIC void
swiftscan_batch_scan_entry_set_module_name(swiftscan_batch_scan_entry_t entry,
const char *name);

SWIFTSCAN_PUBLIC void
swiftscan_batch_scan_entry_set_arguments(swiftscan_batch_scan_entry_t entry,
const char *arguments);

SWIFTSCAN_PUBLIC void
swiftscan_batch_scan_entry_set_is_swift(swiftscan_batch_scan_entry_t entry,
bool is_swift);

SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_batch_scan_entry_get_module_name(swiftscan_batch_scan_entry_t entry);

SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_batch_scan_entry_get_arguments(swiftscan_batch_scan_entry_t entry);

SWIFTSCAN_PUBLIC bool
swiftscan_batch_scan_entry_get_is_swift(swiftscan_batch_scan_entry_t entry);
//=== Batch Scan Input Functions ------DEPRECATED---------------------------===//
/// Deprecated
SWIFTSCAN_PUBLIC swiftscan_batch_scan_input_t *
swiftscan_batch_scan_input_create();
/// Deprecated
SWIFTSCAN_PUBLIC void
swiftscan_batch_scan_input_set_modules(swiftscan_batch_scan_input_t *input,
int count,
swiftscan_batch_scan_entry_t *modules);
/// Deprecated
SWIFTSCAN_PUBLIC swiftscan_batch_scan_entry_t
swiftscan_batch_scan_entry_create();
/// Deprecated
SWIFTSCAN_PUBLIC void
swiftscan_batch_scan_entry_set_module_name(swiftscan_batch_scan_entry_t entry,
const char *name);
/// Deprecated
SWIFTSCAN_PUBLIC void
swiftscan_batch_scan_entry_set_arguments(swiftscan_batch_scan_entry_t entry,
const char *arguments);
/// Deprecated
SWIFTSCAN_PUBLIC void
swiftscan_batch_scan_entry_set_is_swift(swiftscan_batch_scan_entry_t entry,
bool is_swift);
/// Deprecated
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_batch_scan_entry_get_module_name(swiftscan_batch_scan_entry_t entry);
/// Deprecated
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_batch_scan_entry_get_arguments(swiftscan_batch_scan_entry_t entry);
/// Deprecated
SWIFTSCAN_PUBLIC bool
swiftscan_batch_scan_entry_get_is_swift(swiftscan_batch_scan_entry_t entry);

//=== Prescan Result Functions --------------------------------------------===//

Expand Down Expand Up @@ -382,15 +376,16 @@ swiftscan_dependency_graph_dispose(swiftscan_dependency_graph_t result);
SWIFTSCAN_PUBLIC void
swiftscan_import_set_dispose(swiftscan_import_set_t result);

/// Deprecated
SWIFTSCAN_PUBLIC void
swiftscan_batch_scan_entry_dispose(swiftscan_batch_scan_entry_t entry);

/// Deprecated
SWIFTSCAN_PUBLIC void
swiftscan_batch_scan_input_dispose(swiftscan_batch_scan_input_t *input);

/// Deprecated
SWIFTSCAN_PUBLIC void
swiftscan_batch_scan_result_dispose(swiftscan_batch_scan_result_t *result);

/// Deprecated
SWIFTSCAN_PUBLIC void
swiftscan_scan_invocation_dispose(swiftscan_scan_invocation_t invocation);

Expand Down Expand Up @@ -427,22 +422,18 @@ SWIFTSCAN_PUBLIC void swiftscan_scanner_dispose(swiftscan_scanner_t);
SWIFTSCAN_PUBLIC swiftscan_dependency_graph_t swiftscan_dependency_graph_create(
swiftscan_scanner_t scanner, swiftscan_scan_invocation_t invocation);

/// Invoke the scan for an input batch of modules specified in the
/// \c swiftscan_batch_scan_input_t argument. The returned
/// \c swiftscan_batch_scan_result_t is owned by the caller and must be disposed
/// of using \c swiftscan_batch_scan_result_dispose .
SWIFTSCAN_PUBLIC swiftscan_batch_scan_result_t *
swiftscan_batch_scan_result_create(swiftscan_scanner_t scanner,
swiftscan_batch_scan_input_t *batch_input,
swiftscan_scan_invocation_t invocation);

/// Invoke the import prescan using arguments specified in the \c
/// swiftscan_scan_invocation_t argument. The returned \c swiftscan_import_set_t
/// is owned by the caller and must be disposed of using \c
/// swiftscan_import_set_dispose .
SWIFTSCAN_PUBLIC swiftscan_import_set_t swiftscan_import_set_create(
swiftscan_scanner_t scanner, swiftscan_scan_invocation_t invocation);

/// Deprecated
SWIFTSCAN_PUBLIC swiftscan_batch_scan_result_t *
swiftscan_batch_scan_result_create(swiftscan_scanner_t scanner,
swiftscan_batch_scan_input_t *batch_input,
swiftscan_scan_invocation_t invocation);

//=== Scanner Diagnostics -------------------------------------------------===//
/// For the specified \c scanner instance, query all insofar emitted diagnostics
Expand Down
8 changes: 0 additions & 8 deletions include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -354,18 +354,10 @@ ERROR(placeholder_dependency_module_map_corrupted,none,
"Swift placeholder dependency module map from %0 is malformed",
(StringRef))

ERROR(batch_scan_input_file_missing,none,
"cannot open batch dependencies scan input file from %0",
(StringRef))

ERROR(const_extract_protocol_list_input_file_missing,none,
"cannot open constant extraction protocol list input file from %0",
(StringRef))

ERROR(batch_scan_input_file_corrupted,none,
"batch dependencies scan input file from %0 is malformed",
(StringRef))

ERROR(const_extract_protocol_list_input_file_corrupted,none,
"constant extraction protocol list input file from %0 is malformed",
(StringRef))
Expand Down
39 changes: 11 additions & 28 deletions include/swift/AST/ModuleDependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,13 @@ class ModuleDependencyInfoStorageBase {

struct CommonSwiftTextualModuleDependencyDetails {
CommonSwiftTextualModuleDependencyDetails(
ArrayRef<StringRef> extraPCMArgs, ArrayRef<StringRef> buildCommandLine,
ArrayRef<StringRef> buildCommandLine,
StringRef CASFileSystemRootID)
: extraPCMArgs(extraPCMArgs.begin(), extraPCMArgs.end()),
bridgingHeaderFile(std::nullopt),
: bridgingHeaderFile(std::nullopt),
bridgingSourceFiles(), bridgingModuleDependencies(),
buildCommandLine(buildCommandLine.begin(), buildCommandLine.end()),
CASFileSystemRootID(CASFileSystemRootID) {}

/// To build a PCM to be used by this Swift module, we need to append these
/// arguments to the generic PCM build arguments reported from the dependency
/// graph.
const std::vector<std::string> extraPCMArgs;

/// Bridging header file, if there is one.
std::optional<std::string> bridgingHeaderFile;

Expand Down Expand Up @@ -299,7 +293,7 @@ class SwiftInterfaceModuleDependenciesStorage
ArrayRef<ScannerImportStatementInfo> moduleImports,
ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
ArrayRef<StringRef> buildCommandLine, ArrayRef<LinkLibrary> linkLibraries,
ArrayRef<StringRef> extraPCMArgs, StringRef contextHash, bool isFramework,
StringRef contextHash, bool isFramework,
bool isStatic, StringRef RootID, StringRef moduleCacheKey,
StringRef userModuleVersion)
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftInterface,
Expand All @@ -310,7 +304,7 @@ class SwiftInterfaceModuleDependenciesStorage
compiledModuleCandidates(compiledModuleCandidates.begin(),
compiledModuleCandidates.end()),
contextHash(contextHash), isFramework(isFramework), isStatic(isStatic),
textualModuleDetails(extraPCMArgs, buildCommandLine, RootID),
textualModuleDetails(buildCommandLine, RootID),
userModuleVersion(userModuleVersion) {}

ModuleDependencyInfoStorageBase *clone() const override {
Expand Down Expand Up @@ -348,11 +342,10 @@ class SwiftSourceModuleDependenciesStorage
StringRef RootID, ArrayRef<StringRef> buildCommandLine,
ArrayRef<ScannerImportStatementInfo> moduleImports,
ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
ArrayRef<StringRef> bridgingHeaderBuildCommandLine,
ArrayRef<StringRef> extraPCMArgs)
ArrayRef<StringRef> bridgingHeaderBuildCommandLine)
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftSource,
moduleImports, optionalModuleImports, {}),
textualModuleDetails(extraPCMArgs, buildCommandLine, RootID),
textualModuleDetails(buildCommandLine, RootID),
testableImports(llvm::StringSet<>()),
bridgingHeaderBuildCommandLine(bridgingHeaderBuildCommandLine.begin(),
bridgingHeaderBuildCommandLine.end()) {}
Expand Down Expand Up @@ -476,10 +469,6 @@ class ClangModuleDependencyStorage : public ModuleDependencyInfoStorageBase {
/// The file dependencies
const std::vector<std::string> fileDependencies;

/// The swift-specific PCM arguments captured by this dependencies object
/// as found by the scanning action that discovered it
const std::vector<std::string> capturedPCMArgs;

/// CASID for the Root of CASFS. Empty if CAS is not used.
std::string CASFileSystemRootID;

Expand All @@ -493,7 +482,6 @@ class ClangModuleDependencyStorage : public ModuleDependencyInfoStorageBase {
StringRef moduleMapFile, StringRef contextHash,
ArrayRef<std::string> buildCommandLine,
ArrayRef<std::string> fileDependencies,
ArrayRef<std::string> capturedPCMArgs,
ArrayRef<LinkLibrary> linkLibraries,
StringRef CASFileSystemRootID,
StringRef clangIncludeTreeRoot,
Expand All @@ -504,7 +492,6 @@ class ClangModuleDependencyStorage : public ModuleDependencyInfoStorageBase {
pcmOutputPath(pcmOutputPath), mappedPCMPath(mappedPCMPath),
moduleMapFile(moduleMapFile), contextHash(contextHash),
buildCommandLine(buildCommandLine), fileDependencies(fileDependencies),
capturedPCMArgs(capturedPCMArgs),
CASFileSystemRootID(CASFileSystemRootID),
CASClangIncludeTreeRootID(clangIncludeTreeRoot), IsSystem(IsSystem) {}

Expand Down Expand Up @@ -588,15 +575,15 @@ class ModuleDependencyInfo {
ArrayRef<StringRef> compiledCandidates, ArrayRef<StringRef> buildCommands,
ArrayRef<ScannerImportStatementInfo> moduleImports,
ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
ArrayRef<LinkLibrary> linkLibraries, ArrayRef<StringRef> extraPCMArgs,
ArrayRef<LinkLibrary> linkLibraries,
StringRef contextHash, bool isFramework, bool isStatic,
StringRef CASFileSystemRootID, StringRef moduleCacheKey,
StringRef userModuleVersion) {
return ModuleDependencyInfo(
std::make_unique<SwiftInterfaceModuleDependenciesStorage>(
moduleOutputPath, swiftInterfaceFile, compiledCandidates,
moduleImports, optionalModuleImports,
buildCommands, linkLibraries, extraPCMArgs, contextHash,
buildCommands, linkLibraries, contextHash,
isFramework, isStatic, CASFileSystemRootID, moduleCacheKey,
userModuleVersion));
}
Expand Down Expand Up @@ -624,13 +611,11 @@ class ModuleDependencyInfo {
ArrayRef<StringRef> buildCommands,
ArrayRef<ScannerImportStatementInfo> moduleImports,
ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
ArrayRef<StringRef> bridgingHeaderBuildCommands,
ArrayRef<StringRef> extraPCMArgs) {
ArrayRef<StringRef> bridgingHeaderBuildCommands) {
return ModuleDependencyInfo(
std::make_unique<SwiftSourceModuleDependenciesStorage>(
CASFileSystemRootID, buildCommands, moduleImports,
optionalModuleImports, bridgingHeaderBuildCommands,
extraPCMArgs));
optionalModuleImports, bridgingHeaderBuildCommands));
}

static ModuleDependencyInfo
Expand All @@ -640,7 +625,6 @@ class ModuleDependencyInfo {
StringRef(), ArrayRef<StringRef>(),
ArrayRef<ScannerImportStatementInfo>(),
ArrayRef<ScannerImportStatementInfo>(),
ArrayRef<StringRef>(),
ArrayRef<StringRef>()));
}

Expand All @@ -650,12 +634,11 @@ class ModuleDependencyInfo {
StringRef pcmOutputPath, StringRef mappedPCMPath, StringRef moduleMapFile,
StringRef contextHash, ArrayRef<std::string> nonPathCommandLine,
ArrayRef<std::string> fileDependencies,
ArrayRef<std::string> capturedPCMArgs,
ArrayRef<LinkLibrary> linkLibraries, StringRef CASFileSystemRootID,
StringRef clangIncludeTreeRoot, StringRef moduleCacheKey, bool IsSystem) {
return ModuleDependencyInfo(std::make_unique<ClangModuleDependencyStorage>(
pcmOutputPath, mappedPCMPath, moduleMapFile, contextHash,
nonPathCommandLine, fileDependencies, capturedPCMArgs, linkLibraries,
nonPathCommandLine, fileDependencies, linkLibraries,
CASFileSystemRootID, clangIncludeTreeRoot, moduleCacheKey, IsSystem));
}

Expand Down
2 changes: 0 additions & 2 deletions include/swift/AST/ModuleLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ struct SubCompilerInstanceInfo {
CompilerInstance* Instance;
StringRef Hash;
ArrayRef<StringRef> BuildArguments;
ArrayRef<StringRef> ExtraPCMArgs;
};

/// Abstract interface for a checker of module interfaces and prebuilt modules.
Expand Down Expand Up @@ -213,7 +212,6 @@ struct InterfaceSubContextDelegate {
StringRef outputPath,
SourceLoc diagLoc,
llvm::function_ref<std::error_code(ASTContext&, ModuleDecl*,
ArrayRef<StringRef>,
ArrayRef<StringRef>, StringRef,
StringRef)> action) = 0;
virtual std::error_code runInSubCompilerInstance(StringRef moduleName,
Expand Down
3 changes: 0 additions & 3 deletions include/swift/AST/SearchPathOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,6 @@ class SearchPathOptions {
/// A map of placeholder Swift module dependency information.
std::string PlaceholderDependencyModuleMap;

/// A file containing modules we should perform batch scanning.
std::string BatchScanInputFilePath;

/// A file containing a list of protocols whose conformances require const value extraction.
std::string ConstGatherProtocolListFilePath;

Expand Down
Loading