-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[Swift Build] Default to the package's declared deployment target if none is explicitly specified #9139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Swift Build] Default to the package's declared deployment target if none is explicitly specified #9139
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@available(macOS, obsoleted: 13.0) | ||
func foo() { | ||
|
||
} | ||
|
||
func bar() { | ||
foo() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// swift-tools-version:6.1 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "Foo", | ||
platforms: [.macOS(.v12)], | ||
products: [ | ||
.library(name: "Foo", targets: ["Foo"]), | ||
], | ||
targets: [ | ||
.target(name: "Foo", path: "./"), | ||
] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1440,6 +1440,69 @@ struct BuildCommandTestCases { | |
} | ||
} | ||
} | ||
|
||
@Test(.requireHostOS(.macOS), arguments: SupportedBuildSystemOnPlatform) | ||
func buildingPackageWhichRequiresOlderDeploymentTarget(buildSystem: BuildSystemProvider.Kind) async throws { | ||
// This fixture specifies a deployment target of macOS 12, and uses API obsoleted in macOS 13. The goal | ||
// of this test is to ensure that SwiftPM respects the deployment target specified in the package manifest | ||
// when passed no triple of an unversioned triple, rather than using the latests deployment target. | ||
|
||
// No triple - build should pass | ||
try await fixture(name: "Miscellaneous/RequiresOlderDeploymentTarget") { path in | ||
try await executeSwiftBuild( | ||
path, | ||
buildSystem: buildSystem, | ||
throwIfCommandFails: true | ||
) | ||
} | ||
|
||
let hostArch: String | ||
#if arch(arm64) | ||
hostArch = "arm64" | ||
#elseif arch(x86_64) | ||
hostArch = "x86_64" | ||
#else | ||
Issue.record("test is not supported on host arch") | ||
return | ||
#endif | ||
|
||
// Unversioned triple - build should pass | ||
try await fixture(name: "Miscellaneous/RequiresOlderDeploymentTarget") { path in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: can we make these as parameterized tests? the test arguments can be the the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO it's a bit easier to read written out like this since we're already parameterizing based on build system |
||
try await executeSwiftBuild( | ||
path, | ||
extraArgs: ["--triple", "\(hostArch)-apple-macosx"], | ||
buildSystem: buildSystem, | ||
throwIfCommandFails: true | ||
) | ||
} | ||
|
||
// Versioned triple with supported deployment target - build should pass | ||
try await fixture(name: "Miscellaneous/RequiresOlderDeploymentTarget") { path in | ||
try await executeSwiftBuild( | ||
path, | ||
extraArgs: ["--triple", "\(hostArch)-apple-macosx12.0"], | ||
buildSystem: buildSystem, | ||
throwIfCommandFails: true | ||
) | ||
} | ||
|
||
// Versioned triple with unsupported deployment target - build should fail | ||
try await withKnownIssue { | ||
_ = try await fixture(name: "Miscellaneous/RequiresOlderDeploymentTarget") { path in | ||
await #expect(throws: Error.self) { | ||
try await executeSwiftBuild( | ||
path, | ||
extraArgs: ["--triple", "\(hostArch)-apple-macosx14.0"], | ||
buildSystem: buildSystem, | ||
throwIfCommandFails: true | ||
) | ||
} | ||
} | ||
} when: { | ||
// The native build system does not correctly pass the elevated deployment target | ||
buildSystem != .swiftbuild | ||
} | ||
} | ||
} | ||
|
||
extension Triple { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (possibly-blocking) the path setup on linux is fixed in #9218. This PR depend on it so it provides the proper fix/solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stdlib rpaths are a different set from those added in #9218. We can likely drop these runtime paths entirely soon but I need to test that out in another patch first