Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix forwarding of -ld-path to Clang #1447

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1695,7 +1695,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