Skip to content

Commit 4b5e5d7

Browse files
committed
[Dependency Scanning] Deprecate/Remove inter-module dependency graph serialization SwiftScan API uses
This mechanism relied on serializing contents of a dependency scanner cache that included all queried scanning contexts. Instead, the scanner will move to a per-query serialization format. These API were never actually deployed and, to our knowledge, have not worked for a long time. Compiler-side change: swiftlang/swift#77794
1 parent 2d61fdd commit 4b5e5d7

File tree

4 files changed

+0
-126
lines changed

4 files changed

+0
-126
lines changed

Sources/CSwiftScan/include/swiftscan_header.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,6 @@ typedef struct {
259259
int64_t
260260
(*swiftscan_source_location_get_column_number)(swiftscan_source_location_t);
261261

262-
//=== Scanner Cache Functions ---------------------------------------------===//
263-
void (*swiftscan_scanner_cache_serialize)(swiftscan_scanner_t scanner, const char * path);
264-
bool (*swiftscan_scanner_cache_load)(swiftscan_scanner_t scanner, const char * path);
265-
void (*swiftscan_scanner_cache_reset)(swiftscan_scanner_t scanner);
266-
267262
//=== Scanner CAS Operations ----------------------------------------------===//
268263
swiftscan_cas_options_t (*swiftscan_cas_options_create)(void);
269264
int64_t (*swiftscan_cas_get_ondisk_size)(swiftscan_cas_t,

Sources/SwiftDriver/ExplicitModuleBuilds/InterModuleDependencies/InterModuleDependencyOracle.swift

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -90,34 +90,6 @@ public class InterModuleDependencyOracle {
9090
}
9191
}
9292

93-
@_spi(Testing) public func serializeScannerCache(to path: AbsolutePath) {
94-
guard let swiftScan = swiftScanLibInstance else {
95-
fatalError("Attempting to serialize scanner cache with no scanner instance.")
96-
}
97-
if swiftScan.canLoadStoreScannerCache {
98-
swiftScan.serializeScannerCache(to: path)
99-
}
100-
}
101-
102-
@_spi(Testing) public func loadScannerCache(from path: AbsolutePath) -> Bool {
103-
guard let swiftScan = swiftScanLibInstance else {
104-
fatalError("Attempting to load scanner cache with no scanner instance.")
105-
}
106-
if swiftScan.canLoadStoreScannerCache {
107-
return swiftScan.loadScannerCache(from: path)
108-
}
109-
return false
110-
}
111-
112-
@_spi(Testing) public func resetScannerCache() {
113-
guard let swiftScan = swiftScanLibInstance else {
114-
fatalError("Attempting to reset scanner cache with no scanner instance.")
115-
}
116-
if swiftScan.canLoadStoreScannerCache {
117-
swiftScan.resetScannerCache()
118-
}
119-
}
120-
12193
@_spi(Testing) public func supportsBinaryFrameworkDependencies() throws -> Bool {
12294
guard let swiftScan = swiftScanLibInstance else {
12395
fatalError("Attempting to query supported scanner API with no scanner instance.")

Sources/SwiftDriver/SwiftScan/SwiftScan.swift

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,6 @@ private extension String {
228228
api.swiftscan_swift_binary_detail_get_header_dependency_module_dependencies != nil
229229
}
230230

231-
@_spi(Testing) public var canLoadStoreScannerCache : Bool {
232-
api.swiftscan_scanner_cache_load != nil &&
233-
api.swiftscan_scanner_cache_serialize != nil &&
234-
api.swiftscan_scanner_cache_reset != nil
235-
}
236-
237231
@_spi(Testing) public var clangDetailsHaveCapturedPCMArgs : Bool {
238232
api.swiftscan_clang_detail_get_captured_pcm_args != nil
239233
}
@@ -319,20 +313,6 @@ private extension String {
319313
api.swiftscan_link_library_info_get_should_force_load != nil
320314
}
321315

322-
func serializeScannerCache(to path: AbsolutePath) {
323-
api.swiftscan_scanner_cache_serialize(scanner,
324-
path.description.cString(using: String.Encoding.utf8))
325-
}
326-
327-
func loadScannerCache(from path: AbsolutePath) -> Bool {
328-
return api.swiftscan_scanner_cache_load(scanner,
329-
path.description.cString(using: String.Encoding.utf8))
330-
}
331-
332-
func resetScannerCache() {
333-
api.swiftscan_scanner_cache_reset(scanner)
334-
}
335-
336316
internal func mapToDriverDiagnosticPayload(_ diagnosticSetRef: UnsafeMutablePointer<swiftscan_diagnostic_set_t>) throws -> [ScannerDiagnosticPayload] {
337317
var result: [ScannerDiagnosticPayload] = []
338318
let diagnosticRefArray = Array(UnsafeBufferPointer(start: diagnosticSetRef.pointee.diagnostics,
@@ -497,14 +477,6 @@ private extension swiftscan_functions_t {
497477
self.swiftscan_compiler_target_info_query_v2 =
498478
loadOptional("swiftscan_compiler_target_info_query_v2")
499479

500-
// Dependency scanner serialization/deserialization features
501-
self.swiftscan_scanner_cache_serialize =
502-
loadOptional("swiftscan_scanner_cache_serialize")
503-
self.swiftscan_scanner_cache_load =
504-
loadOptional("swiftscan_scanner_cache_load")
505-
self.swiftscan_scanner_cache_reset =
506-
loadOptional("swiftscan_scanner_cache_reset")
507-
508480
// Clang dependency captured PCM args
509481
self.swiftscan_clang_detail_get_captured_pcm_args =
510482
loadOptional("swiftscan_clang_detail_get_captured_pcm_args")

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,71 +2172,6 @@ final class ExplicitModuleBuildTests: XCTestCase {
21722172
}
21732173
}
21742174

2175-
/// Test the libSwiftScan dependency scanning.
2176-
func testDependencyScanReuseCache() throws {
2177-
let (stdlibPath, shimsPath, toolchain, _) = try getDriverArtifactsForScanning()
2178-
try withTemporaryDirectory { path in
2179-
let cacheSavePath = path.appending(component: "saved.moddepcache")
2180-
let main = path.appending(component: "testDependencyScanning.swift")
2181-
try localFileSystem.writeFileContents(main, bytes:
2182-
"""
2183-
import C;\
2184-
import E;\
2185-
import G;
2186-
"""
2187-
)
2188-
2189-
let cHeadersPath: AbsolutePath =
2190-
try testInputsPath.appending(component: "ExplicitModuleBuilds")
2191-
.appending(component: "CHeaders")
2192-
let swiftModuleInterfacesPath: AbsolutePath =
2193-
try testInputsPath.appending(component: "ExplicitModuleBuilds")
2194-
.appending(component: "Swift")
2195-
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
2196-
var driver = try Driver(args: ["swiftc",
2197-
"-I", cHeadersPath.nativePathString(escaped: true),
2198-
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
2199-
"-I", stdlibPath.nativePathString(escaped: true),
2200-
"-I", shimsPath.nativePathString(escaped: true),
2201-
"-explicit-module-build",
2202-
"-working-directory", path.nativePathString(escaped: true),
2203-
"-disable-clang-target",
2204-
main.nativePathString(escaped: true)] + sdkArgumentsForTesting,
2205-
env: ProcessEnv.vars)
2206-
let resolver = try ArgsResolver(fileSystem: localFileSystem)
2207-
var scannerCommand = try driver.dependencyScannerInvocationCommand().1.map { try resolver.resolve($0) }
2208-
// We generate full swiftc -frontend -scan-dependencies invocations in order to also be
2209-
// able to launch them as standalone jobs. Frontend's argument parser won't recognize
2210-
// -frontend when passed directly via libSwiftScan.
2211-
if scannerCommand.first == "-frontend" {
2212-
scannerCommand.removeFirst()
2213-
}
2214-
2215-
let scanLibPath = try XCTUnwrap(toolchain.lookupSwiftScanLib())
2216-
// Run the first scan and serialize the cache contents.
2217-
let firstDependencyOracle = InterModuleDependencyOracle()
2218-
try firstDependencyOracle.verifyOrCreateScannerInstance(swiftScanLibPath: scanLibPath)
2219-
var firstScanDiagnostics: [ScannerDiagnosticPayload] = []
2220-
let firstScanGraph =
2221-
try firstDependencyOracle.getDependencies(workingDirectory: path,
2222-
commandLine: scannerCommand,
2223-
diagnostics: &firstScanDiagnostics)
2224-
firstDependencyOracle.serializeScannerCache(to: cacheSavePath)
2225-
2226-
// Run the second scan, re-using the serialized cache contents.
2227-
let secondDependencyOracle = InterModuleDependencyOracle()
2228-
try secondDependencyOracle.verifyOrCreateScannerInstance(swiftScanLibPath: scanLibPath)
2229-
XCTAssertFalse(secondDependencyOracle.loadScannerCache(from: cacheSavePath))
2230-
var secondScanDiagnostics: [ScannerDiagnosticPayload] = []
2231-
let secondScanGraph =
2232-
try secondDependencyOracle.getDependencies(workingDirectory: path,
2233-
commandLine: scannerCommand,
2234-
diagnostics: &secondScanDiagnostics)
2235-
2236-
XCTAssertTrue(firstScanGraph.modules.count == secondScanGraph.modules.count)
2237-
}
2238-
}
2239-
22402175
func testDependencyScanCommandLineEscape() throws {
22412176
#if os(Windows)
22422177
let quoteCharacter: Character = "\""

0 commit comments

Comments
 (0)