Skip to content

Commit 02684bf

Browse files
authored
Revert "Swift SDKs: implement swiftResourcesPath (#6717)"
This reverts commit 76e3594.
1 parent a0b3bc4 commit 02684bf

File tree

6 files changed

+8
-84
lines changed

6 files changed

+8
-84
lines changed

Sources/Build/BuildDescription/ProductBuildDescription.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
187187
derivedProductType = self.product.type
188188
}
189189

190-
var isLinkingStaticStdlib = false
191190
switch derivedProductType {
192191
case .macro:
193192
throw InternalError("macro not supported") // should never be reached
@@ -214,13 +213,11 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
214213
args += self.deadStripArguments
215214
case .executable, .snippet:
216215
// Link the Swift stdlib statically, if requested.
217-
// TODO: unify this logic with SwiftTargetBuildDescription.stdlibArguments
218216
if self.buildParameters.shouldLinkStaticSwiftStdlib {
219217
if self.buildParameters.targetTriple.isDarwin() {
220218
self.observabilityScope.emit(.swiftBackDeployError)
221219
} else if self.buildParameters.targetTriple.isSupportingStaticStdlib {
222220
args += ["-static-stdlib"]
223-
isLinkingStaticStdlib = true
224221
}
225222
}
226223
args += ["-emit-executable"]
@@ -246,16 +243,6 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
246243
throw InternalError("unexpectedly asked to generate linker arguments for a plugin product")
247244
}
248245

249-
if let resourcesPath = self.buildParameters.toolchain.swiftResourcesPath(isStatic: isLinkingStaticStdlib) {
250-
args += ["-resource-dir", "\(resourcesPath)"]
251-
}
252-
253-
// clang resources are always in lib/swift/
254-
if let dynamicResourcesPath = self.buildParameters.toolchain.swiftResourcesPath {
255-
let clangResourcesPath = dynamicResourcesPath.appending("clang")
256-
args += ["-Xclang-linker", "-resource-dir", "-Xclang-linker", "\(clangResourcesPath)"]
257-
}
258-
259246
// Set rpath such that dynamic libraries are looked up
260247
// adjacent to the product.
261248
if self.buildParameters.targetTriple.isLinux() {

Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -830,18 +830,12 @@ public final class SwiftTargetBuildDescription {
830830
}
831831

832832
private var stdlibArguments: [String] {
833-
var arguments: [String] = []
834-
835-
let isLinkingStaticStdlib = self.buildParameters.shouldLinkStaticSwiftStdlib
836-
&& self.buildParameters.targetTriple.isSupportingStaticStdlib
837-
if isLinkingStaticStdlib {
838-
arguments += ["-static-stdlib"]
839-
}
840-
841-
if let resourcesPath = self.buildParameters.toolchain.swiftResourcesPath(isStatic: isLinkingStaticStdlib) {
842-
arguments += ["-resource-dir", "\(resourcesPath)"]
833+
if self.buildParameters.shouldLinkStaticSwiftStdlib,
834+
self.buildParameters.targetTriple.isSupportingStaticStdlib
835+
{
836+
return ["-static-stdlib"]
837+
} else {
838+
return []
843839
}
844-
845-
return arguments
846840
}
847841
}

Sources/PackageModel/Toolchain.swift

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ public protocol Toolchain {
1919
/// Path of the `swiftc` compiler.
2020
var swiftCompilerPath: AbsolutePath { get }
2121

22-
/// Path to `lib/swift`
23-
var swiftResourcesPath: AbsolutePath? { get }
24-
25-
/// Path to `lib/swift_static`
26-
var swiftStaticResourcesPath: AbsolutePath? { get }
27-
2822
/// Whether the used compiler is from a open source development toolchain.
2923
var isSwiftDevelopmentToolchain: Bool { get }
3024

@@ -87,15 +81,7 @@ extension Toolchain {
8781
return try AbsolutePath(validating: "../../lib", relativeTo: resolveSymlinks(swiftCompilerPath))
8882
}
8983
}
90-
91-
/// Returns the appropriate Swift resources directory path.
92-
///
93-
/// - Parameter static: Controls whether to use the static or dynamic
94-
/// resources directory.
95-
public func swiftResourcesPath(isStatic: Bool) -> AbsolutePath? {
96-
isStatic ? swiftStaticResourcesPath : swiftResourcesPath
97-
}
98-
84+
9985
public var extraCCFlags: [String] {
10086
extraFlags.cCompilerFlags
10187
}

Sources/PackageModel/UserToolchain.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@ public final class UserToolchain: Toolchain {
4040
/// An array of paths to search for libraries at link time.
4141
public let librarySearchPaths: [AbsolutePath]
4242

43-
/// Path containing Swift resources for dynamic linking.
44-
public var swiftResourcesPath: AbsolutePath? {
45-
destination.pathsConfiguration.swiftResourcesPath
46-
}
47-
48-
/// Path containing Swift resources for static linking.
49-
public var swiftStaticResourcesPath: AbsolutePath? {
50-
destination.pathsConfiguration.swiftStaticResourcesPath
51-
}
52-
5343
/// Additional flags to be passed to the build tools.
5444
public var extraFlags: BuildFlags
5545

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3575,9 +3575,6 @@ final class BuildPlanTests: XCTestCase {
35753575
Manifest.createRootManifest(
35763576
displayName: "Pkg",
35773577
path: "/Pkg",
3578-
products: [
3579-
ProductDescription(name: "exe", type: .executable, targets: ["exe"]),
3580-
],
35813578
targets: [
35823579
TargetDescription(name: "exe", dependencies: ["lib"]),
35833580
TargetDescription(name: "lib", dependencies: []),
@@ -3595,11 +3592,7 @@ final class BuildPlanTests: XCTestCase {
35953592
],
35963593
rootPaths: try UserToolchain.default.swiftSDK.toolset.rootPaths
35973594
),
3598-
pathsConfiguration: .init(
3599-
sdkRootPath: "/fake/sdk",
3600-
swiftResourcesPath: "/fake/lib/swift",
3601-
swiftStaticResourcesPath: "/fake/lib/swift_static"
3602-
)
3595+
pathsConfiguration: .init(sdkRootPath: "/fake/sdk")
36033596
)
36043597
let mockToolchain = try UserToolchain(swiftSDK: userSwiftSDK)
36053598
let extraBuildParameters = mockBuildParameters(toolchain: mockToolchain,
@@ -3628,7 +3621,6 @@ final class BuildPlanTests: XCTestCase {
36283621
let exe = try result.target(for: "exe").swiftTarget().compileArguments()
36293622
XCTAssertMatch(exe, [
36303623
"-module-cache-path", "\(buildPath.appending(components: "ModuleCache"))",
3631-
"-resource-dir", "/fake/lib/swift",
36323624
.anySequence,
36333625
"-swift-flag-from-json",
36343626
.anySequence,
@@ -3638,29 +3630,6 @@ final class BuildPlanTests: XCTestCase {
36383630
.anySequence,
36393631
"-Xcc", "-clang-command-line-flag"
36403632
])
3641-
3642-
let exeProduct = try result.buildProduct(for: "exe").linkArguments()
3643-
XCTAssertMatch(exeProduct, [.anySequence, "-resource-dir", "/fake/lib/swift", "-Xclang-linker", "-resource-dir", "-Xclang-linker", "/fake/lib/swift/clang", .anySequence])
3644-
3645-
let staticBuildParameters = {
3646-
var copy = extraBuildParameters
3647-
copy.shouldLinkStaticSwiftStdlib = true
3648-
// pick a triple with support for static linking
3649-
copy.targetTriple = .x86_64Linux
3650-
return copy
3651-
}()
3652-
let staticResult = try BuildPlanResult(plan: BuildPlan(
3653-
buildParameters: staticBuildParameters,
3654-
graph: graph,
3655-
fileSystem: fs,
3656-
observabilityScope: observability.topScope
3657-
))
3658-
3659-
let staticExe = try staticResult.target(for: "exe").swiftTarget().compileArguments()
3660-
XCTAssertMatch(staticExe, [.anySequence, "-resource-dir", "/fake/lib/swift_static", .anySequence])
3661-
3662-
let staticExeProduct = try staticResult.buildProduct(for: "exe").linkArguments()
3663-
XCTAssertMatch(staticExeProduct, [.anySequence, "-resource-dir", "/fake/lib/swift_static", "-Xclang-linker", "-resource-dir", "-Xclang-linker", "/fake/lib/swift/clang", .anySequence])
36643633
}
36653634

36663635
func testUserToolchainWithToolsetCompileFlags() throws {

Tests/BuildTests/MockBuildTestHelper.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ struct MockToolchain: PackageModel.Toolchain {
2828
let swiftCompilerPath = AbsolutePath("/fake/path/to/swiftc")
2929
let includeSearchPaths = [AbsolutePath]()
3030
let librarySearchPaths = [AbsolutePath]()
31-
let swiftResourcesPath: AbsolutePath? = nil
32-
let swiftStaticResourcesPath: AbsolutePath? = nil
3331
let isSwiftDevelopmentToolchain = false
3432
let swiftPluginServerPath: AbsolutePath? = nil
3533
let extraFlags = PackageModel.BuildFlags()

0 commit comments

Comments
 (0)