Skip to content

Commit 9a357ee

Browse files
committed
Fix forwarding of -ld-path
The Clang linker driver spells this as --ld-path so we can't forward the argument wholesale anymore, since we spell it -ld-path.
1 parent c458271 commit 9a357ee

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

Sources/SwiftDriver/Jobs/DarwinToolchain+LinkerSupport.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ extension DarwinToolchain {
181181
commandLine.appendFlag("-fuse-ld=\(arg.asSingle)")
182182
}
183183

184-
try commandLine.appendLast(.ldPath, from: &parsedOptions)
184+
if let arg = parsedOptions.getLastArgument(.ldPath)?.asSingle {
185+
commandLine.append(.joinedOptionAndPath("--ld-path=", try VirtualPath(path: arg)))
186+
}
185187

186188
let fSystemArgs = parsedOptions.arguments(for: .F, .Fsystem)
187189
for opt in fSystemArgs {

Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ extension GenericUnixToolchain {
101101
}
102102
}
103103

104-
try commandLine.appendLast(.ldPath, from: &parsedOptions)
104+
if let arg = parsedOptions.getLastArgument(.ldPath)?.asSingle {
105+
commandLine.append(.joinedOptionAndPath("--ld-path=", try VirtualPath(path: arg)))
106+
}
105107

106108
// Configure the toolchain.
107109
//

Sources/SwiftDriver/Jobs/WebAssemblyToolchain+LinkerSupport.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ extension WebAssemblyToolchain {
4343
commandLine.appendFlag("-fuse-ld=\(linkerArg)")
4444
}
4545

46-
try commandLine.appendLast(.ldPath, from: &parsedOptions)
46+
if let arg = parsedOptions.getLastArgument(.ldPath)?.asSingle {
47+
commandLine.append(.joinedOptionAndPath("--ld-path=", try VirtualPath(path: arg)))
48+
}
4749

4850
// Configure the toolchain.
4951
//

Sources/SwiftDriver/Jobs/WindowsToolchain+LinkerSupport.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ extension WindowsToolchain {
105105
commandLine.appendFlag("-fuse-ld=lld")
106106
}
107107

108-
try commandLine.appendLast(.ldPath, from: &parsedOptions)
108+
if let arg = parsedOptions.getLastArgument(.ldPath)?.asSingle {
109+
commandLine.append(.joinedOptionAndPath("--ld-path=", try VirtualPath(path: arg)))
110+
}
109111

110112
switch lto {
111113
case .some(.llvmThin):

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,7 @@ final class SwiftDriverTests: XCTestCase {
16951695
let cmd = linkJob.commandLine
16961696
XCTAssertTrue(cmd.contains(.flag("-dynamiclib")))
16971697
XCTAssertTrue(cmd.contains(.flag("-fuse-ld=foo")))
1698-
XCTAssertTrue(cmd.contains(.joinedOptionAndPath("-ld-path=", try VirtualPath(path: "/bar/baz"))))
1698+
XCTAssertTrue(cmd.contains(.joinedOptionAndPath("--ld-path=", try VirtualPath(path: "/bar/baz"))))
16991699
XCTAssertTrue(cmd.contains(.flag("--target=x86_64-apple-macosx10.15")))
17001700
XCTAssertEqual(linkJob.outputs[0].file, try VirtualPath(path: "libTest.dylib"))
17011701

0 commit comments

Comments
 (0)