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