Skip to content

Commit 1bebc64

Browse files
Merge pull request #1756 from kateinoigakukun/yt/fix-non-windows-legacy-driver
2 parents 04be76e + 46cc429 commit 1bebc64

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Sources/swift-driver/main.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,26 @@ do {
8383
// invocation for a multi-call binary.
8484
let executable: URL = URL(fileURLWithPath: ProcessInfo.processInfo.arguments[0])
8585
let invocation: URL = URL(fileURLWithPath: CommandLine.arguments[0])
86+
87+
#if compiler(>=6.2)
8688
let legacyExecutablePath: URL =
89+
executable.deletingLastPathComponent()
90+
.appendingPathComponent("\(invocation.deletingPathExtension().lastPathComponent)-legacy-driver")
91+
.appendingPathExtension(executable.pathExtension)
92+
#else
93+
// WORKAROUND: Check if the original path has a non-empty extension because
94+
// `url.deletingPathExtension().appendingPathExtension(url.pathExtension)`
95+
// will not be equal to `url` but be `\(url).` if `url` doesn't have an
96+
// extension on Swift 6.0. Remove this when we drop support for Swift 6.0
97+
// as a bootstrapping compiler.
98+
// See https://github.com/swiftlang/swift-foundation/issues/1080
99+
var legacyExecutablePath: URL =
87100
executable.deletingLastPathComponent()
88101
.appendingPathComponent("\(invocation.deletingPathExtension().lastPathComponent)-legacy-driver")
89-
.appendingPathExtension(executable.pathExtension)
102+
if !executable.pathExtension.isEmpty {
103+
legacyExecutablePath.appendPathExtension(executable.pathExtension)
104+
}
105+
#endif
90106
let path: String = legacyExecutablePath.withUnsafeFileSystemRepresentation { String(cString: $0!) }
91107

92108
if localFileSystem.exists(AbsolutePath(path)) {

0 commit comments

Comments
 (0)