From 21596d84aee8fc716cd7057ee4d3eb39705598b8 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Tue, 1 Apr 2025 20:32:11 -0400 Subject: [PATCH 1/8] Update default Swift version to 6.1-RELEASE --- Sources/GeneratorCLI/GeneratorCLI.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/GeneratorCLI/GeneratorCLI.swift b/Sources/GeneratorCLI/GeneratorCLI.swift index 82667af..d0e7fc8 100644 --- a/Sources/GeneratorCLI/GeneratorCLI.swift +++ b/Sources/GeneratorCLI/GeneratorCLI.swift @@ -113,7 +113,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: """ From f6fd94d3188475a75b6bbc21f883f71f7c3ebe8a Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Tue, 1 Apr 2025 20:36:20 -0400 Subject: [PATCH 2/8] Exclude including hostLLVM for any Swift 6.x --- Sources/SwiftSDKGenerator/SwiftSDKRecipes/LinuxRecipe.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftSDKGenerator/SwiftSDKRecipes/LinuxRecipe.swift b/Sources/SwiftSDKGenerator/SwiftSDKRecipes/LinuxRecipe.swift index 7d58357..fc7b25a 100644 --- a/Sources/SwiftSDKGenerator/SwiftSDKRecipes/LinuxRecipe.swift +++ b/Sources/SwiftSDKGenerator/SwiftSDKRecipes/LinuxRecipe.swift @@ -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) } @@ -319,7 +319,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) } From 9ba671f5d58ec2165b1e556ca684fab09093de48 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Wed, 2 Apr 2025 07:35:56 -0400 Subject: [PATCH 3/8] Add EndToEnd tests for Swift61 for Ubuntu and RHEL --- .../EndToEndTests.swift | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift b/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift index b067fd7..a2a4eb2 100644 --- a/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift +++ b/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift @@ -447,6 +447,36 @@ 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()) + } +} + final class Swift59_RHELEndToEndTests: XCTestCase { let config = SDKConfiguration( swiftVersion: "5.9.2", @@ -566,3 +596,47 @@ final class Swift60_RHELEndToEndTests: XCTestCase { config: config.withArchitecture("x86_64").withContainerImageSuffix("fedora39")) } } + +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")) + } + + func testFedora39Aarch64FromContainer() async throws { + try skipSlow() + try await buildTestcases( + config: config.withArchitecture("aarch64").withContainerImageSuffix("fedora39")) + } + + func testFedora39X86_64FromContainer() async throws { + try skipSlow() + try await buildTestcases( + config: config.withArchitecture("x86_64").withContainerImageSuffix("fedora39")) + } +} From 705009cbbd936409cb45accc3193c9b7073b9dd6 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Wed, 2 Apr 2025 19:11:54 -0400 Subject: [PATCH 4/8] Remove Fedora39 from Swift61 EndToEnd tests since it is no longer supported --- Tests/SwiftSDKGeneratorTests/EndToEndTests.swift | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift b/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift index a2a4eb2..406dfca 100644 --- a/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift +++ b/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift @@ -627,16 +627,4 @@ final class Swift61_RHELEndToEndTests: XCTestCase { try await buildTestcases( config: config.withArchitecture("x86_64").withContainerImageSuffix("amazonlinux2")) } - - func testFedora39Aarch64FromContainer() async throws { - try skipSlow() - try await buildTestcases( - config: config.withArchitecture("aarch64").withContainerImageSuffix("fedora39")) - } - - func testFedora39X86_64FromContainer() async throws { - try skipSlow() - try await buildTestcases( - config: config.withArchitecture("x86_64").withContainerImageSuffix("fedora39")) - } } From 796fc383bd8c97abc0310f9442918f7a6ffb4224 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Wed, 2 Apr 2025 19:48:48 -0400 Subject: [PATCH 5/8] Add symlinks of /lib and /lib64 to /usr when building from packages - This fixes the issue with the Ubuntu Noble packages not containing /lib64 as other Ubuntu versions do. --- .../Generator/SwiftSDKGenerator+Download.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Download.swift b/Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Download.swift index ad84680..d589932 100644 --- a/Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Download.swift +++ b/Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Download.swift @@ -147,6 +147,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( From 492c9c9e426c37c1b51143c71c9230fd1982c3f3 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Wed, 2 Apr 2025 20:03:11 -0400 Subject: [PATCH 6/8] Add EndToEndTests for Swift61 for Jammy as well as Noble - Excluding Focal since it is EOL this year. --- .../EndToEndTests.swift | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift b/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift index 406dfca..4dba979 100644 --- a/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift +++ b/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift @@ -185,6 +185,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 @@ -475,6 +481,30 @@ final class Swift61_UbuntuEndToEndTests: XCTestCase { 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 { From 0d52feb4e1c0b3ddd8450da7d5142205f91ff411 Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Sun, 23 Mar 2025 15:00:34 -0400 Subject: [PATCH 7/8] Adjust targetSwift path to include swiftPlatform to identify the toolchain - Otherwise weird things happen from the EndToEndTests when running tests that then need to re-download a new toolchain on top. --- .../Artifacts/DownloadableArtifacts.swift | 10 ++++---- .../VersionsConfiguration.swift | 23 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Sources/SwiftSDKGenerator/Artifacts/DownloadableArtifacts.swift b/Sources/SwiftSDKGenerator/Artifacts/DownloadableArtifacts.swift index ec4725e..1af7fd1 100644 --- a/Sources/SwiftSDKGenerator/Artifacts/DownloadableArtifacts.swift +++ b/Sources/SwiftSDKGenerator/Artifacts/DownloadableArtifacts.swift @@ -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 @@ -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 ) } diff --git a/Sources/SwiftSDKGenerator/PlatformModels/VersionsConfiguration.swift b/Sources/SwiftSDKGenerator/PlatformModels/VersionsConfiguration.swift index 88467aa..4bcaeca 100644 --- a/Sources/SwiftSDKGenerator/PlatformModels/VersionsConfiguration.swift +++ b/Sources/SwiftSDKGenerator/PlatformModels/VersionsConfiguration.swift @@ -37,14 +37,19 @@ 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( @@ -52,14 +57,10 @@ public struct VersionsConfiguration: Sendable { 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: """ From 722b690b528dac8e8f0203dc1e887bec6689bf6d Mon Sep 17 00:00:00 2001 From: "Jesse L. Zamora" Date: Thu, 3 Apr 2025 21:53:50 -0400 Subject: [PATCH 8/8] Apply formatting to EndToEndTests --- .../SwiftSDKGeneratorTests/EndToEndTests.swift | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift b/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift index b0a04b2..443fa5b 100644 --- a/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift +++ b/Tests/SwiftSDKGeneratorTests/EndToEndTests.swift @@ -500,25 +500,29 @@ final class Swift61_UbuntuEndToEndTests: XCTestCase { func testJammyAarch64Direct() async throws { try skipSlow() try await buildTestcases( - config: config.withArchitecture("aarch64").withLinuxDistributionVersion("22.04")) + 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")) + 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()) + 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()) + config: config.withArchitecture("x86_64").withLinuxDistributionVersion("22.04").withDocker() + ) } } @@ -674,12 +678,14 @@ final class Swift61_RHELEndToEndTests: XCTestCase { func testAmazonLinux2Aarch64FromContainer() async throws { try skipSlow() try await buildTestcases( - config: config.withArchitecture("aarch64").withContainerImageSuffix("amazonlinux2")) + config: config.withArchitecture("aarch64").withContainerImageSuffix("amazonlinux2") + ) } func testAmazonLinux2X86_64FromContainer() async throws { try skipSlow() try await buildTestcases( - config: config.withArchitecture("x86_64").withContainerImageSuffix("amazonlinux2")) + config: config.withArchitecture("x86_64").withContainerImageSuffix("amazonlinux2") + ) } }