Skip to content

Commit 7a927cd

Browse files
authored
Do not try to add rpath arguments on noneOS (#8358)
1 parent 8e4dd07 commit 7a927cd

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

Sources/Build/BuildDescription/ProductBuildDescription.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
270270

271271
// Set rpath such that dynamic libraries are looked up
272272
// adjacent to the product, unless overridden.
273-
if !self.buildParameters.linkingParameters.shouldDisableLocalRpath {
273+
if triple.os != .noneOS, !self.buildParameters.linkingParameters.shouldDisableLocalRpath {
274274
switch triple.objectFormat {
275275
case .elf:
276276
args += ["-Xlinker", "-rpath=$ORIGIN"]

Tests/BuildTests/BuildPlanTests.swift

+38
Original file line numberDiff line numberDiff line change
@@ -6655,6 +6655,44 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
66556655
}
66566656
}
66576657

6658+
func testNoRpathForOSNone() async throws {
6659+
let fileSystem = InMemoryFileSystem(
6660+
emptyFiles:
6661+
"/Pkg/Sources/exe/main.swift"
6662+
)
6663+
let observability = ObservabilitySystem.makeForTesting()
6664+
let graph = try loadModulesGraph(
6665+
fileSystem: fileSystem,
6666+
manifests: [
6667+
Manifest.createRootManifest(
6668+
displayName: "Pkg",
6669+
path: "/Pkg",
6670+
targets: [
6671+
TargetDescription(name: "exe"),
6672+
]
6673+
),
6674+
],
6675+
observabilityScope: observability.topScope
6676+
)
6677+
XCTAssertNoDiagnostics(observability.diagnostics)
6678+
6679+
let toolchain = try UserToolchain.default
6680+
let result = try await BuildPlanResult(plan: mockBuildPlan(
6681+
triple: Triple("arm64-unknown-none"),
6682+
toolchain: toolchain,
6683+
graph: graph,
6684+
fileSystem: fileSystem,
6685+
observabilityScope: observability.topScope
6686+
))
6687+
result.checkProductsCount(1)
6688+
6689+
// Assert the objects getting linked contain all the bitcode objects
6690+
// built by the Swift Target
6691+
let exeLinkArguments = try result.buildProduct(for: "exe").linkArguments()
6692+
let exeLinkArgumentsNegativePattern: [StringPattern] = ["-rpath"]
6693+
XCTAssertNoMatch(exeLinkArguments, exeLinkArgumentsNegativePattern)
6694+
}
6695+
66586696
func testPackageDependencySetsUserModuleVersion() async throws {
66596697
let fs = InMemoryFileSystem(emptyFiles: "/Pkg/Sources/exe/main.swift", "/ExtPkg/Sources/ExtLib/best.swift")
66606698

0 commit comments

Comments
 (0)