Skip to content

Commit ac20ce1

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 14226b3 commit ac20ce1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-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
}

0 commit comments

Comments
 (0)