Skip to content

Commit

Permalink
[5.10] Fix forwarding of -ld-path (#1454)
Browse files Browse the repository at this point in the history
Cherry-pick of #1447.

The Clang linker driver spells this as `--ld-path` so we can't forward the argument wholesale anymore, since we spell it `-ld-path`.

(cherry picked from commit 9a357ee)
---------

Co-authored-by: Kabir Oberai <[email protected]>
  • Loading branch information
MaxDesiatov and kabiroberai authored Oct 18, 2023
1 parent af363df commit f16a26a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Sources/SwiftDriver/Jobs/DarwinToolchain+LinkerSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ extension DarwinToolchain {
commandLine.appendFlag("-fuse-ld=\(arg.asSingle)")
}

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

let fSystemArgs = parsedOptions.arguments(for: .F, .Fsystem)
for opt in fSystemArgs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ extension GenericUnixToolchain {
}
}

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

// Configure the toolchain.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ extension WebAssemblyToolchain {
commandLine.appendFlag("-fuse-ld=\(linkerArg)")
}

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

// Configure the toolchain.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ extension WindowsToolchain {
commandLine.appendFlag("-fuse-ld=lld")
}

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

switch lto {
case .some(.llvmThin):
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,7 @@ final class SwiftDriverTests: XCTestCase {
let cmd = linkJob.commandLine
XCTAssertTrue(cmd.contains(.flag("-dynamiclib")))
XCTAssertTrue(cmd.contains(.flag("-fuse-ld=foo")))
XCTAssertTrue(cmd.contains(.joinedOptionAndPath("-ld-path=", try VirtualPath(path: "/bar/baz"))))
XCTAssertTrue(cmd.contains(.joinedOptionAndPath("--ld-path=", try VirtualPath(path: "/bar/baz"))))
XCTAssertTrue(cmd.contains(.flag("--target=x86_64-apple-macosx10.15")))
XCTAssertEqual(linkJob.outputs[0].file, try VirtualPath(path: "libTest.dylib"))

Expand Down

0 comments on commit f16a26a

Please sign in to comment.