Skip to content

Commit

Permalink
Disable in-process target-info and supported-features queries using l…
Browse files Browse the repository at this point in the history
…ibSwiftScan

When building the compiler toolchain, there is currently a race condition which makes it so that the 'libSwiftScan.dylib' is not ready by the time the driver is used to begin compilation of the Swift standard library. For now, disable in-process queries altogether.

On 'main', this is resolved with swiftlang/swift#77606, which seems to be a challenge to backport to 6.0.
  • Loading branch information
artemcm committed Dec 9, 2024
1 parent 2f500f2 commit 72e785e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
18 changes: 10 additions & 8 deletions Sources/SwiftDriver/Jobs/EmitSupportedFeaturesJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ extension Driver {
fileSystem: FileSystem,
executor: DriverExecutor)
throws -> Set<String> {
do {
if let supportedArgs =
try querySupportedCompilerArgsInProcess(of: toolchain, fileSystem: fileSystem) {
return supportedArgs
}
} catch {
diagnosticsEngine.emit(.remark_inprocess_supported_features_query_failed(error.localizedDescription))
}
// Disable in-process supported features query due to a race condition in the compiler's current
// build system where libSwiftScan may not be ready when building the Swift standard library.
// do {
// if let supportedArgs =
// try querySupportedCompilerArgsInProcess(of: toolchain, fileSystem: fileSystem) {
// return supportedArgs
// }
// } catch {
// diagnosticsEngine.emit(.remark_inprocess_supported_features_query_failed(error.localizedDescription))
// }

// Fallback: Invoke `swift-frontend -emit-supported-features` and decode the output
let frontendOverride = try FrontendOverride(&parsedOptions, diagnosticsEngine)
Expand Down
22 changes: 12 additions & 10 deletions Sources/SwiftDriver/Jobs/PrintTargetInfoJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,18 @@ extension Driver {
using: executor.resolver)
Self.sanitizeCommandForLibScanInvocation(&command)

do {
if let targetInfo =
try Self.queryTargetInfoInProcess(of: toolchain, fileSystem: fileSystem,
workingDirectory: workingDirectory,
invocationCommand: command) {
return targetInfo
}
} catch {
diagnosticsEngine.emit(.remark_inprocess_target_info_query_failed(error.localizedDescription))
}
// Disable in-process target query due to a race condition in the compiler's current
// build system where libSwiftScan may not be ready when building the Swift standard library.
// do {
// if let targetInfo =
// try Self.queryTargetInfoInProcess(of: toolchain, fileSystem: fileSystem,
// workingDirectory: workingDirectory,
// invocationCommand: command) {
// return targetInfo
// }
// } catch {
// diagnosticsEngine.emit(.remark_inprocess_target_info_query_failed(error.localizedDescription))
// }

// Fallback: Invoke `swift-frontend -print-target-info` and decode the output
return try executor.execute(
Expand Down

0 comments on commit 72e785e

Please sign in to comment.