Skip to content

Commit 420ef0a

Browse files
authored
Build: create static libraries explicitly with libtool. (#5948)
This matches the implementation of the static linker in swift-driver, which always adds the explicit `-static`. https://github.com/apple/swift-driver/blob/caa81e560362a4e14034cd4502114d03e45ea261/Sources/SwiftDriver/Jobs/DarwinToolchain%2BLinkerSupport.swift#L95-L102
1 parent dd7e9cc commit 420ef0a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Sources/Build/BuildPlan.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
13871387
return [librarian, "/LIB", "/OUT:\(binaryPath.pathString)", "@\(linkFileListPath.pathString)"]
13881388
}
13891389
if triple.isDarwin(), librarian.hasSuffix("libtool") {
1390-
return [librarian, "-o", binaryPath.pathString, "@\(linkFileListPath.pathString)"]
1390+
return [librarian, "-static", "-o", binaryPath.pathString, "@\(linkFileListPath.pathString)"]
13911391
}
13921392
return [librarian, "crs", binaryPath.pathString, "@\(linkFileListPath.pathString)"]
13931393
}

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3808,7 +3808,7 @@ final class BuildPlanTests: XCTestCase {
38083808
inputs: ["\(buildPath.appending(components: "rary.build", "rary.swift.o").escapedPathString())"]
38093809
outputs: ["\(buildPath.appending(components: "library.a").escapedPathString())"]
38103810
description: "Archiving \(buildPath.appending(components: "library.a").escapedPathString())"
3811-
args: ["\(result.plan.buildParameters.toolchain.librarianPath.escapedPathString())","-o","\(buildPath.appending(components: "library.a").escapedPathString())","@\(buildPath.appending(components: "rary.product", "Objects.LinkFileList").escapedPathString())"]
3811+
args: ["\(result.plan.buildParameters.toolchain.librarianPath.escapedPathString())","-static","-o","\(buildPath.appending(components: "library.a").escapedPathString())","@\(buildPath.appending(components: "rary.product", "Objects.LinkFileList").escapedPathString())"]
38123812
"""))
38133813
} else { // assume Unix `ar` is the librarian
38143814
XCTAssertMatch(contents, .contains("""

0 commit comments

Comments
 (0)