Skip to content

Commit 13b9264

Browse files
committed
Swift SDKs: fix toolset.linker.path not passed to -ld-path
This reverts commit 57d0a55 and PR #6939. Now that swiftlang/swift-driver#1447 and its 5.10 counterpart swiftlang/swift-driver#1454 were merged, we can reapply the fix for Swift SDKs linker metadata not being handled.
1 parent 55e79b1 commit 13b9264

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Sources/PackageModel/UserToolchain.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,11 @@ public final class UserToolchain: Toolchain {
349349
swiftSDK: SwiftSDK,
350350
environment: EnvironmentVariables
351351
) throws -> [String] {
352-
let swiftCompilerFlags = swiftSDK.toolset.knownTools[.swiftCompiler]?.extraCLIOptions ?? []
352+
var swiftCompilerFlags = swiftSDK.toolset.knownTools[.swiftCompiler]?.extraCLIOptions ?? []
353+
354+
if let linker = swiftSDK.toolset.knownTools[.linker]?.path {
355+
swiftCompilerFlags += ["-ld-path=\(linker)"]
356+
}
353357

354358
guard let sdkDir = swiftSDK.pathsConfiguration.sdkRootPath else {
355359
if triple.isWindows() {

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3716,7 +3716,7 @@ final class BuildPlanTests: XCTestCase {
37163716
.cxxCompiler: .init(extraCLIOptions: [jsonFlag(tool: .cxxCompiler)]),
37173717
.swiftCompiler: .init(extraCLIOptions: [jsonFlag(tool: .swiftCompiler)]),
37183718
.librarian: .init(path: "/fake/toolchain/usr/bin/librarian"),
3719-
.linker: .init(extraCLIOptions: [jsonFlag(tool: .linker)]),
3719+
.linker: .init(path: "/fake/toolchain/usr/bin/linker", extraCLIOptions: [jsonFlag(tool: .linker)]),
37203720
],
37213721
rootPaths: try UserToolchain.default.swiftSDK.toolset.rootPaths)
37223722
let targetTriple = try Triple("armv7em-unknown-none-macho")
@@ -3797,7 +3797,9 @@ final class BuildPlanTests: XCTestCase {
37973797
// Compile Swift Target
37983798
let exeCompileArguments = try result.target(for: "exe").swiftTarget().compileArguments()
37993799
let exeCompileArgumentsPattern: [StringPattern] = [
3800-
jsonFlag(tool: .swiftCompiler), "-g", cliFlag(tool: .swiftCompiler),
3800+
jsonFlag(tool: .swiftCompiler),
3801+
"-ld-path=/fake/toolchain/usr/bin/linker",
3802+
"-g", cliFlag(tool: .swiftCompiler),
38013803
.anySequence,
38023804
"-Xcc", jsonFlag(tool: .cCompiler), "-Xcc", "-g", "-Xcc", cliFlag(tool: .cCompiler),
38033805
// TODO: Pass -Xcxx flags to swiftc (#6491)
@@ -3820,7 +3822,9 @@ final class BuildPlanTests: XCTestCase {
38203822
// Link Product
38213823
let exeLinkArguments = try result.buildProduct(for: "exe").linkArguments()
38223824
let exeLinkArgumentsPattern: [StringPattern] = [
3823-
jsonFlag(tool: .swiftCompiler), "-g", cliFlag(tool: .swiftCompiler),
3825+
jsonFlag(tool: .swiftCompiler),
3826+
"-ld-path=/fake/toolchain/usr/bin/linker",
3827+
"-g", cliFlag(tool: .swiftCompiler),
38243828
.anySequence,
38253829
"-Xlinker", jsonFlag(tool: .linker), "-Xlinker", cliFlag(tool: .linker),
38263830
]

0 commit comments

Comments
 (0)