Skip to content

Commit 57f737d

Browse files
[5.9] PackageModel: honour .librarian for toolsets (#6770)
Cherry-pick of #6688. When defining a custom toolset, a specified librarian shall be given precedence over the platform's librarian. Use this to repair the toolset test on Windows where `ar` is unavailable. This test used to succeed due to the leaking of the host tools. This fixes a bug reproducible when cross-compiling projects with dependencies to any platform, including Linux. Risk: low, only affects cross-compilation with SwiftPM, which is not widely used yet. (cherry picked from commit 4d63d66) Co-authored-by: Saleem Abdulrasool <[email protected]>
1 parent a432dc8 commit 57f737d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Sources/PackageModel/UserToolchain.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ public final class UserToolchain: Toolchain {
501501
self.includeSearchPaths = destination.pathsConfiguration.includeSearchPaths ?? []
502502
self.librarySearchPaths = destination.pathsConfiguration.includeSearchPaths ?? []
503503

504-
self.librarianPath = try UserToolchain.determineLibrarian(
504+
self.librarianPath = try destination.toolset.knownTools[.librarian]?.path ?? UserToolchain.determineLibrarian(
505505
triple: triple,
506506
binDirectories: destination.toolset.rootPaths,
507507
useXcrun: useXcrun,

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3544,6 +3544,7 @@ final class BuildPlanTests: XCTestCase {
35443544
.cCompiler: .init(extraCLIOptions: [jsonFlag(tool: .cCompiler)]),
35453545
.cxxCompiler: .init(extraCLIOptions: [jsonFlag(tool: .cxxCompiler)]),
35463546
.swiftCompiler: .init(extraCLIOptions: [jsonFlag(tool: .swiftCompiler)]),
3547+
.librarian: .init(path: "/fake/toolchain/usr/bin/librarian"),
35473548
.linker: .init(extraCLIOptions: [jsonFlag(tool: .linker)]),
35483549
],
35493550
rootPaths: try UserToolchain.default.destination.toolset.rootPaths)

0 commit comments

Comments
 (0)