@@ -30,11 +30,13 @@ import Dispatch
3030import WinSDK
3131#endif
3232
33- import enum TSCBasic. ProcessEnv
33+ import struct TSCBasic. AbsolutePath
3434import func TSCBasic. exec
35+ import enum TSCBasic. ProcessEnv
3536import class TSCBasic. DiagnosticsEngine
3637import class TSCBasic. Process
3738import class TSCBasic. ProcessSet
39+ import func TSCBasic. resolveSymlinks
3840import protocol TSCBasic. DiagnosticData
3941import var TSCBasic. localFileSystem
4042
8688 }
8789
8890 let ( mode, arguments) = try Driver . invocationRunMode ( forArgs: CommandLine . arguments)
89-
9091 if case . subcommand( let subcommand) = mode {
9192 // We are running as a subcommand, try to find the subcommand adjacent to the executable we are running as.
9293 // 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+ }
95102
96103 guard let subcommandPath = subcommandPath,
97104 localFileSystem. exists ( subcommandPath) else {
0 commit comments