Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -328,20 +328,15 @@ extension GenericUnixToolchain {
commandLine.appendPath(outputFile)
return try resolvedTool(clangTool, pathOverride: clangPath)
case .staticLibrary:
// We're using 'ar' as a linker
// We're using 'llvm-ar' as a linker
commandLine.appendFlag("crs")
commandLine.appendPath(outputFile)

commandLine.append(contentsOf: inputs.lazy.filter {
lto == nil ? $0.type == .object
: $0.type == .object || $0.type == .llvmBitcode
}.map { .path($0.file) })
if targetTriple.environment == .android {
// Always use the LTO archiver llvm-ar for Android
return try resolvedTool(.staticLinker(.llvmFull))
} else {
return try resolvedTool(.staticLinker(lto))
}
return try resolvedTool(.staticLinker(.llvmFull))
}

}
Expand Down
5 changes: 1 addition & 4 deletions Sources/SwiftDriver/Toolchains/GenericUnixToolchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ public final class GenericUnixToolchain: Toolchain {
switch tool {
case .swiftCompiler:
return try lookup(executable: "swift-frontend")
case .staticLinker(nil):
return try lookup(executable: "ar")
case .staticLinker(.llvmFull),
.staticLinker(.llvmThin):
case .staticLinker:
return try lookup(executable: "llvm-ar")
case .dynamicLinker:
// FIXME: This needs to look in the tools_directory first.
Expand Down
3 changes: 2 additions & 1 deletion Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2356,7 +2356,8 @@ final class SwiftDriverTests: XCTestCase {

let linkJob = plannedJobs[3]
let cmd = linkJob.commandLine
// we'd expect "ar crs libTest.a foo.o bar.o"
// we'd expect "llvm-ar crs libTest.a foo.o bar.o"
XCTAssertTrue(linkJob.tool.name.contains("llvm-ar"))
XCTAssertTrue(cmd.contains(.flag("crs")))
XCTAssertTrue(commandContainsTemporaryPath(cmd, "foo.o"))
XCTAssertTrue(commandContainsTemporaryPath(cmd, "bar.o"))
Expand Down