Skip to content

Commit 1faf231

Browse files
committed
[unix] Fix linker argument in Unix toolchains
The spelling of the linker is `-fuse-ld=`, not `--fuse-ld=`, as it can be seen in [1] and as used in the C++ driver in [2]. The code was correct before swiftlang#1545 using `-fuse-ld=`, but was changed to `--fuse-ld=`. The test was testing for the command line containing the same spelling, so it would had never failed, but running the actual command line would had failed. That code was eventually reverted and reverted back in swiftlang#1608. [1]: https://github.com/apple/llvm-project/blob/e33819dff1cbf7a90b0216a4993126cb11440d45/clang/include/clang/Driver/Options.td#L5267 [2]: https://github.com/apple/swift/blob/319f36b01baa082fd2d2640d6e320594752702d0/lib/Driver/UnixToolChains.cpp#L234
1 parent 1e7ed77 commit 1faf231

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ extension GenericUnixToolchain {
5050
case .executable:
5151
// Select the linker to use.
5252
if let arg = parsedOptions.getLastArgument(.useLd)?.asSingle {
53-
commandLine.appendFlag("--fuse-ld=\(arg)")
53+
commandLine.appendFlag("-fuse-ld=\(arg)")
5454
} else if lto != nil {
55-
commandLine.appendFlag("--fuse-ld=lld")
55+
commandLine.appendFlag("-fuse-ld=lld")
5656
}
5757

5858
if let arg = parsedOptions.getLastArgument(.ldPath)?.asSingle {

Tests/SwiftDriverTests/SwiftDriverTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2372,7 +2372,7 @@ final class SwiftDriverTests: XCTestCase {
23722372
let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs()
23732373
let lastJob = plannedJobs.last!
23742374
XCTAssertTrue(lastJob.tool.name.contains("clang"))
2375-
XCTAssertTrue(lastJob.commandLine.contains(.flag("--fuse-ld=lld")))
2375+
XCTAssertTrue(lastJob.commandLine.contains(.flag("-fuse-ld=lld")))
23762376
}
23772377
}
23782378

0 commit comments

Comments
 (0)