Skip to content

Update defaults for Swift 6.1-RELEASE #204

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

Merged
2 changes: 1 addition & 1 deletion Sources/GeneratorCLI/GeneratorCLI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ extension GeneratorCLI {
var swiftBranch: String? = nil

@Option(help: "Version of Swift to supply in the bundle.")
var swiftVersion = "6.0.3-RELEASE"
var swiftVersion = "6.1-RELEASE"

@Option(
help: """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ struct DownloadableArtifacts: Sendable {

if hostTriple.os == .linux {
// Amazon Linux 2 is chosen for its best compatibility with all Swift-supported Linux hosts
let linuxArchSuffix =
let hostArchSuffix =
hostTriple.arch == .aarch64 ? "-\(Triple.Arch.aarch64.linuxConventionName)" : ""
self.hostSwift = .init(
remoteURL: versions.swiftDownloadURL(
subdirectory: "amazonlinux2\(linuxArchSuffix)",
platform: "amazonlinux2\(linuxArchSuffix)",
subdirectory: "amazonlinux2\(hostArchSuffix)",
platform: "amazonlinux2\(hostArchSuffix)",
fileExtension: "tar.gz"
),
localPath: paths.artifactsCachePath
Expand Down Expand Up @@ -97,7 +97,9 @@ struct DownloadableArtifacts: Sendable {
self.targetSwift = .init(
remoteURL: versions.swiftDownloadURL(),
localPath: paths.artifactsCachePath
.appending("target_swift_\(versions.swiftVersion)_\(targetTriple.triple).tar.gz"),
.appending(
"target_swift_\(versions.swiftVersion)_\(versions.swiftPlatform)_\(targetTriple.archName).tar.gz"
),
isPrebuilt: true
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ extension SwiftSDKGenerator {
try await fs.unpack(file: tmpDir.appending(fileName), into: sdkDirPath)
}
}

// Make sure we have /lib and /lib64, and if not symlink from /usr
// This makes building from packages more consistent with copying from the Docker container
let libDirectories = ["lib", "lib64"]
for dir in libDirectories {
let sdkLibPath = sdkDirPath.appending(dir)
let sdkUsrLibPath = sdkDirPath.appending("usr/\(dir)")
if !doesFileExist(at: sdkLibPath) && doesFileExist(at: sdkUsrLibPath) {
try createSymlink(at: sdkLibPath, pointingTo: FilePath("./usr/\(dir)"))
}
}
}

func downloadFiles(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,30 @@ public struct VersionsConfiguration: Sendable {
var swiftPlatform: String {
switch self.linuxDistribution {
case let .ubuntu(ubuntu):
return "ubuntu\(ubuntu.version)\(self.linuxArchSuffix)"
return "ubuntu\(ubuntu.version)"
case let .rhel(rhel):
return "\(rhel.rawValue)\(self.linuxArchSuffix)"
return rhel.rawValue
}
}

var swiftPlatformAndSuffix: String {
return "\(self.swiftPlatform)\(self.linuxArchSuffix)"
}

func swiftDistributionName(platform: String? = nil) -> String {
"swift-\(self.swiftVersion)-\(platform ?? self.swiftPlatform)"
return
"swift-\(self.swiftVersion)-\(platform ?? self.swiftPlatformAndSuffix)"
}

func swiftDownloadURL(
subdirectory: String? = nil,
platform: String? = nil,
fileExtension: String = "tar.gz"
) -> URL {
let computedSubdirectory: String
switch self.linuxDistribution {
case let .ubuntu(ubuntu):
computedSubdirectory =
"ubuntu\(ubuntu.version.replacingOccurrences(of: ".", with: ""))\(self.linuxArchSuffix)"
case let .rhel(rhel):
computedSubdirectory = rhel.rawValue
}
let computedPlatform = platform ?? self.swiftPlatformAndSuffix
let computedSubdirectory =
subdirectory
?? computedPlatform.replacingOccurrences(of: ".", with: "")

return URL(
string: """
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftSDKGenerator/SwiftSDKRecipes/LinuxRecipe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public struct LinuxRecipe: SwiftSDKRecipe {
var items: [DownloadableArtifacts.Item] = []
if self.hostSwiftSource != .preinstalled
&& self.mainHostTriple.os != .linux
&& !self.versionsConfiguration.swiftVersion.hasPrefix("6.0")
&& !self.versionsConfiguration.swiftVersion.hasPrefix("6.")
{
items.append(artifacts.hostLLVM)
}
Expand Down Expand Up @@ -324,7 +324,7 @@ public struct LinuxRecipe: SwiftSDKRecipe {

if self.hostSwiftSource != .preinstalled {
if self.mainHostTriple.os != .linux
&& !self.versionsConfiguration.swiftVersion.hasPrefix("6.0")
&& !self.versionsConfiguration.swiftVersion.hasPrefix("6.")
{
try await generator.prepareLLDLinker(engine, llvmArtifact: downloadableArtifacts.hostLLVM)
}
Expand Down
98 changes: 98 additions & 0 deletions Tests/SwiftSDKGeneratorTests/EndToEndTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ struct SDKConfiguration {
return res
}

func withLinuxDistributionVersion(_ version: String) -> SDKConfiguration {
var res = self
res.linuxDistributionVersion = version
return res
}

func withArchitecture(_ arch: String) -> SDKConfiguration {
var res = self
res.architecture = arch
Expand Down Expand Up @@ -462,6 +468,64 @@ final class Swift60_UbuntuEndToEndTests: XCTestCase {
}
}

final class Swift61_UbuntuEndToEndTests: XCTestCase {
let config = SDKConfiguration(
swiftVersion: "6.1",
linuxDistributionName: "ubuntu",
linuxDistributionVersion: "24.04",
architecture: "aarch64",
withDocker: false
)

func testAarch64Direct() async throws {
try skipSlow()
try await buildTestcases(config: config.withArchitecture("aarch64"))
}

func testX86_64Direct() async throws {
try skipSlow()
try await buildTestcases(config: config.withArchitecture("x86_64"))
}

func testAarch64FromContainer() async throws {
try skipSlow()
try await buildTestcases(config: config.withArchitecture("aarch64").withDocker())
}

func testX86_64FromContainer() async throws {
try skipSlow()
try await buildTestcases(config: config.withArchitecture("x86_64").withDocker())
}

func testJammyAarch64Direct() async throws {
try skipSlow()
try await buildTestcases(
config: config.withArchitecture("aarch64").withLinuxDistributionVersion("22.04")
)
}

func testJammyX86_64Direct() async throws {
try skipSlow()
try await buildTestcases(
config: config.withArchitecture("x86_64").withLinuxDistributionVersion("22.04")
)
}

func testJammyAarch64FromContainer() async throws {
try skipSlow()
try await buildTestcases(
config: config.withArchitecture("aarch64").withLinuxDistributionVersion("22.04").withDocker()
)
}

func testJammyX86_64FromContainer() async throws {
try skipSlow()
try await buildTestcases(
config: config.withArchitecture("x86_64").withLinuxDistributionVersion("22.04").withDocker()
)
}
}

final class Swift59_RHELEndToEndTests: XCTestCase {
let config = SDKConfiguration(
swiftVersion: "5.9.2",
Expand Down Expand Up @@ -591,3 +655,37 @@ final class Swift60_RHELEndToEndTests: XCTestCase {
)
}
}

final class Swift61_RHELEndToEndTests: XCTestCase {
let config = SDKConfiguration(
swiftVersion: "6.1",
linuxDistributionName: "rhel",
linuxDistributionVersion: "ubi9",
architecture: "aarch64",
withDocker: true // RHEL-based SDKs can only be built from containers
)

func testAarch64FromContainer() async throws {
try skipSlow()
try await buildTestcases(config: config.withArchitecture("aarch64"))
}

func testX86_64FromContainer() async throws {
try skipSlow()
try await buildTestcases(config: config.withArchitecture("x86_64"))
}

func testAmazonLinux2Aarch64FromContainer() async throws {
try skipSlow()
try await buildTestcases(
config: config.withArchitecture("aarch64").withContainerImageSuffix("amazonlinux2")
)
}

func testAmazonLinux2X86_64FromContainer() async throws {
try skipSlow()
try await buildTestcases(
config: config.withArchitecture("x86_64").withContainerImageSuffix("amazonlinux2")
)
}
}