Skip to content

Add fallback to auxiliary legacy driver executable on '--disallow-use-new-driver' #1485

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 1 commit into from
Jan 4, 2024
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
14 changes: 14 additions & 0 deletions Sources/swift-driver/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
import SwiftDriverExecution
import SwiftDriver
import SwiftOptions
#if os(Windows)
import CRT
#elseif os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
Expand Down Expand Up @@ -65,6 +66,19 @@ do {
}
interruptSignalSource.resume()

// Fallback to legacy driver if forced to
if CommandLine.arguments.contains(Option.disallowForwardingDriver.spelling) ||
ProcessEnv.vars["SWIFT_USE_OLD_DRIVER"] != nil {
if let legacyExecutablePath = Process.findExecutable(CommandLine.arguments[0] + "-legacy-driver"),
localFileSystem.exists(legacyExecutablePath) {
let legacyDriverCommand = [legacyExecutablePath.pathString] +
CommandLine.arguments[1...]
try exec(path: legacyExecutablePath.pathString, args: legacyDriverCommand)
} else {
throw Driver.Error.unknownOrMissingSubcommand(CommandLine.arguments[0] + "-legacy-driver")
}
}

if ProcessEnv.vars["SWIFT_ENABLE_EXPLICIT_MODULE"] != nil {
CommandLine.arguments.append("-explicit-module-build")
}
Expand Down
1 change: 1 addition & 0 deletions Tests/SwiftDriverTests/IntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ final class IntegrationTests: IntegrationTestCase {
let extraEnv = [
"SWIFT": swift.pathString,
"SWIFTC": swiftc.pathString,
"SWIFT_FORCE_TEST_NEW_DRIVER": "1",
"SWIFT_DRIVER_SWIFT_EXEC": swiftFile.pathString,
"SWIFT_DRIVER_SWIFT_FRONTEND_EXEC": frontendFile.pathString,
"LC_ALL": "en_US.UTF-8"
Expand Down