Skip to content

[Caching] Disable caching when -disable-bridging-pch is used #1537

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
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
55 changes: 30 additions & 25 deletions Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -646,31 +646,6 @@ public struct Driver {
diagnosticEngine: diagnosticsEngine,
compilerMode: compilerMode)

let cachingEnabled = parsedOptions.hasArgument(.cacheCompileJob) || env.keys.contains("SWIFT_ENABLE_CACHING")
if cachingEnabled {
if !parsedOptions.hasArgument(.driverExplicitModuleBuild) {
diagnosticsEngine.emit(.warning("-cache-compile-job cannot be used without explicit module build, turn off caching"),
location: nil)
self.enableCaching = false
} else {
self.enableCaching = true
}
} else {
self.enableCaching = false
}
self.useClangIncludeTree = !parsedOptions.hasArgument(.noClangIncludeTree) && !env.keys.contains("SWIFT_CACHING_USE_CLANG_CAS_FS")
self.scannerPrefixMap = try Self.computeScanningPrefixMapper(&parsedOptions)
if let sdkMapping = parsedOptions.getLastArgument(.scannerPrefixMapSdk)?.asSingle {
self.scannerPrefixMapSDK = try AbsolutePath(validating: sdkMapping)
} else {
self.scannerPrefixMapSDK = nil
}
if let toolchainMapping = parsedOptions.getLastArgument(.scannerPrefixMapToolchain)?.asSingle {
self.scannerPrefixMapToolchain = try AbsolutePath(validating: toolchainMapping)
} else {
self.scannerPrefixMapToolchain = nil
}

// Compute the working directory.
workingDirectory = try parsedOptions.getLastArgument(.workingDirectory).map { workingDirectoryArg in
let cwd = fileSystem.currentWorkingDirectory
Expand Down Expand Up @@ -851,6 +826,36 @@ public struct Driver {
}
self.supportedFrontendFeatures = try Self.computeSupportedCompilerFeatures(of: self.toolchain, env: env)

// Caching options.
let cachingEnabled = parsedOptions.hasArgument(.cacheCompileJob) || env.keys.contains("SWIFT_ENABLE_CACHING")
if cachingEnabled {
if !parsedOptions.hasArgument(.driverExplicitModuleBuild) {
diagnosticsEngine.emit(.warning("-cache-compile-job cannot be used without explicit module build, turn off caching"),
location: nil)
self.enableCaching = false
} else if importedObjCHeader != nil && bridgingPrecompiledHeader == nil {
diagnosticsEngine.emit(.warning("-cache-compile-job cannot be used with -disable-bridging-pch, turn off caching"),
location: nil)
self.enableCaching = false
} else {
self.enableCaching = true
}
} else {
self.enableCaching = false
}
self.useClangIncludeTree = !parsedOptions.hasArgument(.noClangIncludeTree) && !env.keys.contains("SWIFT_CACHING_USE_CLANG_CAS_FS")
self.scannerPrefixMap = try Self.computeScanningPrefixMapper(&parsedOptions)
if let sdkMapping = parsedOptions.getLastArgument(.scannerPrefixMapSdk)?.asSingle {
self.scannerPrefixMapSDK = try AbsolutePath(validating: sdkMapping)
} else {
self.scannerPrefixMapSDK = nil
}
if let toolchainMapping = parsedOptions.getLastArgument(.scannerPrefixMapToolchain)?.asSingle {
self.scannerPrefixMapToolchain = try AbsolutePath(validating: toolchainMapping)
} else {
self.scannerPrefixMapToolchain = nil
}

self.enabledSanitizers = try Self.parseSanitizerArgValues(
&parsedOptions,
diagnosticEngine: diagnosticEngine,
Expand Down