Skip to content

Commit 2f39944

Browse files
committed
Add fallback to auxiliary legacy driver executable on '--disallow-use-new-driver'
With the swift-driver executable becoming the default target of 'swift' and 'swiftc' sumlinks, we need to allow for the prior mechanism afforded by this flag
1 parent 28ffedb commit 2f39944

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Sources/swift-driver/main.swift

+14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212
import SwiftDriverExecution
1313
import SwiftDriver
14+
import SwiftOptions
1415
#if os(Windows)
1516
import CRT
1617
#elseif os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
@@ -65,6 +66,19 @@ do {
6566
}
6667
interruptSignalSource.resume()
6768

69+
// Fallback to legacy driver if forced to
70+
if CommandLine.arguments.contains(Option.disallowForwardingDriver.spelling) ||
71+
ProcessEnv.vars["SWIFT_USE_OLD_DRIVER"] != nil {
72+
if let legacyExecutablePath = Process.findExecutable(CommandLine.arguments[0] + "-legacy-driver"),
73+
localFileSystem.exists(legacyExecutablePath) {
74+
let legacyDriverCommand = [legacyExecutablePath.pathString] +
75+
CommandLine.arguments[1...]
76+
try exec(path: legacyExecutablePath.pathString, args: legacyDriverCommand)
77+
} else {
78+
throw Driver.Error.unknownOrMissingSubcommand(CommandLine.arguments[0] + "-legacy-driver")
79+
}
80+
}
81+
6882
if ProcessEnv.vars["SWIFT_ENABLE_EXPLICIT_MODULE"] != nil {
6983
CommandLine.arguments.append("-explicit-module-build")
7084
}

Tests/SwiftDriverTests/IntegrationTests.swift

+1
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ final class IntegrationTests: IntegrationTestCase {
224224
let extraEnv = [
225225
"SWIFT": swift.pathString,
226226
"SWIFTC": swiftc.pathString,
227+
"SWIFT_FORCE_TEST_NEW_DRIVER": "1",
227228
"SWIFT_DRIVER_SWIFT_EXEC": swiftFile.pathString,
228229
"SWIFT_DRIVER_SWIFT_FRONTEND_EXEC": frontendFile.pathString,
229230
"LC_ALL": "en_US.UTF-8"

0 commit comments

Comments
 (0)