From 996f5aa734aa9f9eb93d030065acb62e9b6b9ef2 Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Wed, 8 Jan 2025 09:45:04 -0800 Subject: [PATCH] Remove error for invalid swift caching configuration Currently, swift-driver emits an error when trying to importing a swift binary module that has a bridging header when swift caching is enabled. This turns out to be a very common configuration that we need to support. It turns out most of the time, allowing the compilation to continue will result in a successful compilation. Even though in rare occasions where multiple bridging headers from the dependencies are involved with overlapping content, the compilation is going to fail with confusing error message, we will address that in swift compiler instead. Thus the current error message is removed to allow more supported projects. (cherry picked from commit d091f6de5bc792916b70197a7e834453126395b6) --- .../ExplicitDependencyBuildPlanner.swift | 5 ----- Sources/SwiftDriver/SwiftScan/SwiftScan.swift | 3 --- Tests/SwiftDriverTests/CachingBuildTests.swift | 6 +++--- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Sources/SwiftDriver/ExplicitModuleBuilds/ExplicitDependencyBuildPlanner.swift b/Sources/SwiftDriver/ExplicitModuleBuilds/ExplicitDependencyBuildPlanner.swift index 2e41da5f9..a40297e6f 100644 --- a/Sources/SwiftDriver/ExplicitModuleBuilds/ExplicitDependencyBuildPlanner.swift +++ b/Sources/SwiftDriver/ExplicitModuleBuilds/ExplicitDependencyBuildPlanner.swift @@ -264,11 +264,6 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT for dependencyModule in swiftDependencyArtifacts { inputs.append(TypedVirtualPath(file: dependencyModule.modulePath.path, type: .swiftModule)) - - let prebuiltHeaderDependencyPaths = dependencyModule.prebuiltHeaderDependencyPaths ?? [] - if cas != nil && !prebuiltHeaderDependencyPaths.isEmpty { - throw DependencyScanningError.unsupportedConfigurationForCaching("module \(dependencyModule.moduleName) has bridging header dependency") - } } for moduleArtifactInfo in clangDependencyArtifacts { let clangModulePath = diff --git a/Sources/SwiftDriver/SwiftScan/SwiftScan.swift b/Sources/SwiftDriver/SwiftScan/SwiftScan.swift index b5f80e918..89c1cae31 100644 --- a/Sources/SwiftDriver/SwiftScan/SwiftScan.swift +++ b/Sources/SwiftDriver/SwiftScan/SwiftScan.swift @@ -35,7 +35,6 @@ public enum DependencyScanningError: LocalizedError, DiagnosticData, Equatable { case scanningLibraryInvocationMismatch(String, String) case scanningLibraryNotFound(AbsolutePath) case argumentQueryFailed - case unsupportedConfigurationForCaching(String) public var description: String { switch self { @@ -61,8 +60,6 @@ public enum DependencyScanningError: LocalizedError, DiagnosticData, Equatable { return "Dependency Scanning library not found at path: \(path)" case .argumentQueryFailed: return "Supported compiler argument query failed" - case .unsupportedConfigurationForCaching(let reason): - return "Unsupported configuration for -cache-compile-job, consider turn off swift caching: \(reason)" } } diff --git a/Tests/SwiftDriverTests/CachingBuildTests.swift b/Tests/SwiftDriverTests/CachingBuildTests.swift index 936b563d1..b1c9acc2b 100644 --- a/Tests/SwiftDriverTests/CachingBuildTests.swift +++ b/Tests/SwiftDriverTests/CachingBuildTests.swift @@ -709,9 +709,9 @@ final class CachingBuildTests: XCTestCase { main.nativePathString(escaped: true)] + sdkArgumentsForTesting, env: ProcessEnv.vars, interModuleDependencyOracle: dependencyOracle) - // This is currently not supported. - XCTAssertThrowsError(try driver.planBuild()) { - XCTAssertEqual($0 as? DependencyScanningError, .unsupportedConfigurationForCaching("module Foo has bridging header dependency")) + let jobs = try driver.planBuild() + for job in jobs { + XCTAssertFalse(job.outputCacheKeys.isEmpty) } } }