Skip to content

Commit 39151f6

Browse files
authored
Fix forwarding of -ld-path to Clang (#1447)
The Clang linker driver spells this as `--ld-path` so we can't forward the argument wholesale anymore, since as of #1441 we spell it `-ld-path` in the Swift Driver.
1 parent bcf15e3 commit 39151f6

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
@@ -1694,7 +1694,7 @@ final class SwiftDriverTests: XCTestCase {
16941694
let cmd = linkJob.commandLine
16951695
XCTAssertTrue(cmd.contains(.flag("-dynamiclib")))
16961696
XCTAssertTrue(cmd.contains(.flag("-fuse-ld=foo")))
1697-
XCTAssertTrue(cmd.contains(.joinedOptionAndPath("-ld-path=", try VirtualPath(path: "/bar/baz"))))
1697+
XCTAssertTrue(cmd.contains(.joinedOptionAndPath("--ld-path=", try VirtualPath(path: "/bar/baz"))))
16981698
XCTAssertTrue(cmd.contains(.flag("--target=x86_64-apple-macosx10.15")))
16991699
XCTAssertEqual(linkJob.outputs[0].file, try VirtualPath(path: "libTest.dylib"))
17001700

0 commit comments

Comments
 (0)