@@ -28,11 +28,13 @@ import Dispatch
2828import WinSDK
2929#endif
3030
31- import enum TSCBasic. ProcessEnv
31+ import struct TSCBasic. AbsolutePath
3232import func TSCBasic. exec
33+ import enum TSCBasic. ProcessEnv
3334import class TSCBasic. DiagnosticsEngine
3435import class TSCBasic. Process
3536import class TSCBasic. ProcessSet
37+ import func TSCBasic. resolveSymlinks
3638import protocol TSCBasic. DiagnosticData
3739import var TSCBasic. localFileSystem
3840
8486 }
8587
8688 let ( mode, arguments) = try Driver . invocationRunMode ( forArgs: CommandLine . arguments)
87-
8889 if case . subcommand( let subcommand) = mode {
8990 // We are running as a subcommand, try to find the subcommand adjacent to the executable we are running as.
9091 // 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+ }
93100
94101 guard let subcommandPath = subcommandPath,
95102 localFileSystem. exists ( subcommandPath) else {
0 commit comments