@@ -28,11 +28,13 @@ import Dispatch
28
28
import WinSDK
29
29
#endif
30
30
31
- import enum TSCBasic. ProcessEnv
31
+ import struct TSCBasic. AbsolutePath
32
32
import func TSCBasic. exec
33
+ import enum TSCBasic. ProcessEnv
33
34
import class TSCBasic. DiagnosticsEngine
34
35
import class TSCBasic. Process
35
36
import class TSCBasic. ProcessSet
37
+ import func TSCBasic. resolveSymlinks
36
38
import protocol TSCBasic. DiagnosticData
37
39
import var TSCBasic. localFileSystem
38
40
84
86
}
85
87
86
88
let ( mode, arguments) = try Driver . invocationRunMode ( forArgs: CommandLine . arguments)
87
-
88
89
if case . subcommand( let subcommand) = mode {
89
90
// We are running as a subcommand, try to find the subcommand adjacent to the executable we are running as.
90
91
// If we didn't find the tool there, let the OS search for it.
91
- let subcommandPath = Process . findExecutable ( CommandLine . arguments [ 0 ] ) ? . parentDirectory. appending ( component: subcommand)
92
- ?? Process . findExecutable ( subcommand)
92
+ let subcommandPath : AbsolutePath ?
93
+ if let executablePath = Process . findExecutable ( CommandLine . arguments [ 0 ] ) {
94
+ // Attempt to resolve the executable symlink in order to be able to
95
+ // resolve compiler-adjacent library locations.
96
+ subcommandPath = try TSCBasic . resolveSymlinks ( executablePath) . parentDirectory. appending ( component: subcommand)
97
+ } else {
98
+ subcommandPath = Process . findExecutable ( subcommand)
99
+ }
93
100
94
101
guard let subcommandPath = subcommandPath,
95
102
localFileSystem. exists ( subcommandPath) else {
0 commit comments