Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription

// Set rpath such that dynamic libraries are looked up
// adjacent to the product, unless overridden.
if !self.buildParameters.linkingParameters.shouldDisableLocalRpath {
if triple.os != .noneOS, !self.buildParameters.linkingParameters.shouldDisableLocalRpath {
switch triple.objectFormat {
case .elf:
args += ["-Xlinker", "-rpath=$ORIGIN"]
Expand Down
38 changes: 38 additions & 0 deletions Tests/BuildTests/BuildPlanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6655,6 +6655,44 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
}
}

func testNoRpathForOSNone() async throws {
let fileSystem = InMemoryFileSystem(
emptyFiles:
"/Pkg/Sources/exe/main.swift"
)
let observability = ObservabilitySystem.makeForTesting()
let graph = try loadModulesGraph(
fileSystem: fileSystem,
manifests: [
Manifest.createRootManifest(
displayName: "Pkg",
path: "/Pkg",
targets: [
TargetDescription(name: "exe"),
]
),
],
observabilityScope: observability.topScope
)
XCTAssertNoDiagnostics(observability.diagnostics)

let toolchain = try UserToolchain.default
let result = try await BuildPlanResult(plan: mockBuildPlan(
triple: Triple("arm64-unknown-none"),
toolchain: toolchain,
graph: graph,
fileSystem: fileSystem,
observabilityScope: observability.topScope
))
result.checkProductsCount(1)

// Assert the objects getting linked contain all the bitcode objects
// built by the Swift Target
let exeLinkArguments = try result.buildProduct(for: "exe").linkArguments()
let exeLinkArgumentsNegativePattern: [StringPattern] = ["-rpath"]
XCTAssertNoMatch(exeLinkArguments, exeLinkArgumentsNegativePattern)
}

func testPackageDependencySetsUserModuleVersion() async throws {
let fs = InMemoryFileSystem(emptyFiles: "/Pkg/Sources/exe/main.swift", "/ExtPkg/Sources/ExtLib/best.swift")

Expand Down