Skip to content

Commit 490a48d

Browse files
committed
Set PATH to ensure the linker driver is able to find a linker in a different toolchain
1 parent 41553c1 commit 490a48d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Sources/SWBCore/SpecImplementations/Tools/LinkerTools.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,13 @@ public final class LdLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @unchec
11221122
}
11231123
}
11241124

1125+
override public func environmentFromSpec(_ cbc: CommandBuildContext, _ delegate: any DiagnosticProducingDelegate, lookup: ((MacroDeclaration) -> MacroExpression?)? = nil) -> [(String, String)] {
1126+
var env: [(String, String)] = super.environmentFromSpec(cbc, delegate, lookup: lookup)
1127+
// The linker driver and linker may not be adjacent, so set PATH so the former can find the latter.
1128+
env.append(("PATH", cbc.producer.executableSearchPaths.environmentRepresentation))
1129+
return env
1130+
}
1131+
11251132
/// Compute the list of command line arguments and inputs to pass to the linker, given a list of library specifiers.
11261133
///
11271134
/// Note that `inputs` will only contain values for libraries which are being directly linked by absolute path rather than by using search paths.

0 commit comments

Comments
 (0)