Skip to content

Commit a3e3c73

Browse files
Update defaults for Swift 6.1-RELEASE tag (#204)
- Defaulted `swiftVersion` to "6.1-RELEASE". - Added EndToEndTests for Ubuntu and RHEL for Swift61, including some additional tests for Ubuntu Jammy. - Fixed missing /lib and /lib64 directories in Ubuntu Noble when building from deb packages. If these directories don't exist, they are symlinked to the correct directories in /usr, which is consistent to what happens when copying from the Docker containers. - Added the fix for downloading Swift for the target that adds the platform name to the cache file, to avoid corruption of the artifacts: * <img width="375" alt="image" src="https://github.com/user-attachments/assets/b18efd38-2cbe-44e1-a6fd-2fbb1a13002b" /> ALSO: I did not include EndToEndTests for Fedora39 for Swift 6.1 since the container is non-existent, likely because it's EOL.
1 parent 0158a41 commit a3e3c73

File tree

6 files changed

+130
-18
lines changed

6 files changed

+130
-18
lines changed

Sources/GeneratorCLI/GeneratorCLI.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ extension GeneratorCLI {
114114
var swiftBranch: String? = nil
115115

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

119119
@Option(
120120
help: """

Sources/SwiftSDKGenerator/Artifacts/DownloadableArtifacts.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ struct DownloadableArtifacts: Sendable {
5454

5555
if hostTriple.os == .linux {
5656
// Amazon Linux 2 is chosen for its best compatibility with all Swift-supported Linux hosts
57-
let linuxArchSuffix =
57+
let hostArchSuffix =
5858
hostTriple.arch == .aarch64 ? "-\(Triple.Arch.aarch64.linuxConventionName)" : ""
5959
self.hostSwift = .init(
6060
remoteURL: versions.swiftDownloadURL(
61-
subdirectory: "amazonlinux2\(linuxArchSuffix)",
62-
platform: "amazonlinux2\(linuxArchSuffix)",
61+
subdirectory: "amazonlinux2\(hostArchSuffix)",
62+
platform: "amazonlinux2\(hostArchSuffix)",
6363
fileExtension: "tar.gz"
6464
),
6565
localPath: paths.artifactsCachePath
@@ -97,7 +97,9 @@ struct DownloadableArtifacts: Sendable {
9797
self.targetSwift = .init(
9898
remoteURL: versions.swiftDownloadURL(),
9999
localPath: paths.artifactsCachePath
100-
.appending("target_swift_\(versions.swiftVersion)_\(targetTriple.triple).tar.gz"),
100+
.appending(
101+
"target_swift_\(versions.swiftVersion)_\(versions.swiftPlatform)_\(targetTriple.archName).tar.gz"
102+
),
101103
isPrebuilt: true
102104
)
103105
}

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Download.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@ extension SwiftSDKGenerator {
153153
try await fs.unpack(file: tmpDir.appending(fileName), into: sdkDirPath)
154154
}
155155
}
156+
157+
// Make sure we have /lib and /lib64, and if not symlink from /usr
158+
// This makes building from packages more consistent with copying from the Docker container
159+
let libDirectories = ["lib", "lib64"]
160+
for dir in libDirectories {
161+
let sdkLibPath = sdkDirPath.appending(dir)
162+
let sdkUsrLibPath = sdkDirPath.appending("usr/\(dir)")
163+
if !doesFileExist(at: sdkLibPath) && doesFileExist(at: sdkUsrLibPath) {
164+
try createSymlink(at: sdkLibPath, pointingTo: FilePath("./usr/\(dir)"))
165+
}
166+
}
156167
}
157168

158169
func downloadFiles(

Sources/SwiftSDKGenerator/PlatformModels/VersionsConfiguration.swift

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,30 @@ public struct VersionsConfiguration: Sendable {
3737
var swiftPlatform: String {
3838
switch self.linuxDistribution {
3939
case let .ubuntu(ubuntu):
40-
return "ubuntu\(ubuntu.version)\(self.linuxArchSuffix)"
40+
return "ubuntu\(ubuntu.version)"
4141
case let .rhel(rhel):
42-
return "\(rhel.rawValue)\(self.linuxArchSuffix)"
42+
return rhel.rawValue
4343
}
4444
}
4545

46+
var swiftPlatformAndSuffix: String {
47+
return "\(self.swiftPlatform)\(self.linuxArchSuffix)"
48+
}
49+
4650
func swiftDistributionName(platform: String? = nil) -> String {
47-
"swift-\(self.swiftVersion)-\(platform ?? self.swiftPlatform)"
51+
return
52+
"swift-\(self.swiftVersion)-\(platform ?? self.swiftPlatformAndSuffix)"
4853
}
4954

5055
func swiftDownloadURL(
5156
subdirectory: String? = nil,
5257
platform: String? = nil,
5358
fileExtension: String = "tar.gz"
5459
) -> URL {
55-
let computedSubdirectory: String
56-
switch self.linuxDistribution {
57-
case let .ubuntu(ubuntu):
58-
computedSubdirectory =
59-
"ubuntu\(ubuntu.version.replacingOccurrences(of: ".", with: ""))\(self.linuxArchSuffix)"
60-
case let .rhel(rhel):
61-
computedSubdirectory = rhel.rawValue
62-
}
60+
let computedPlatform = platform ?? self.swiftPlatformAndSuffix
61+
let computedSubdirectory =
62+
subdirectory
63+
?? computedPlatform.replacingOccurrences(of: ".", with: "")
6364

6465
return URL(
6566
string: """

Sources/SwiftSDKGenerator/SwiftSDKRecipes/LinuxRecipe.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public struct LinuxRecipe: SwiftSDKRecipe {
178178
var items: [DownloadableArtifacts.Item] = []
179179
if self.hostSwiftSource != .preinstalled
180180
&& self.mainHostTriple.os != .linux
181-
&& !self.versionsConfiguration.swiftVersion.hasPrefix("6.0")
181+
&& !self.versionsConfiguration.swiftVersion.hasPrefix("6.")
182182
{
183183
items.append(artifacts.hostLLVM)
184184
}
@@ -324,7 +324,7 @@ public struct LinuxRecipe: SwiftSDKRecipe {
324324

325325
if self.hostSwiftSource != .preinstalled {
326326
if self.mainHostTriple.os != .linux
327-
&& !self.versionsConfiguration.swiftVersion.hasPrefix("6.0")
327+
&& !self.versionsConfiguration.swiftVersion.hasPrefix("6.")
328328
{
329329
try await generator.prepareLLDLinker(engine, llvmArtifact: downloadableArtifacts.hostLLVM)
330330
}

Tests/SwiftSDKGeneratorTests/EndToEndTests.swift

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ struct SDKConfiguration {
191191
return res
192192
}
193193

194+
func withLinuxDistributionVersion(_ version: String) -> SDKConfiguration {
195+
var res = self
196+
res.linuxDistributionVersion = version
197+
return res
198+
}
199+
194200
func withArchitecture(_ arch: String) -> SDKConfiguration {
195201
var res = self
196202
res.architecture = arch
@@ -462,6 +468,64 @@ final class Swift60_UbuntuEndToEndTests: XCTestCase {
462468
}
463469
}
464470

471+
final class Swift61_UbuntuEndToEndTests: XCTestCase {
472+
let config = SDKConfiguration(
473+
swiftVersion: "6.1",
474+
linuxDistributionName: "ubuntu",
475+
linuxDistributionVersion: "24.04",
476+
architecture: "aarch64",
477+
withDocker: false
478+
)
479+
480+
func testAarch64Direct() async throws {
481+
try skipSlow()
482+
try await buildTestcases(config: config.withArchitecture("aarch64"))
483+
}
484+
485+
func testX86_64Direct() async throws {
486+
try skipSlow()
487+
try await buildTestcases(config: config.withArchitecture("x86_64"))
488+
}
489+
490+
func testAarch64FromContainer() async throws {
491+
try skipSlow()
492+
try await buildTestcases(config: config.withArchitecture("aarch64").withDocker())
493+
}
494+
495+
func testX86_64FromContainer() async throws {
496+
try skipSlow()
497+
try await buildTestcases(config: config.withArchitecture("x86_64").withDocker())
498+
}
499+
500+
func testJammyAarch64Direct() async throws {
501+
try skipSlow()
502+
try await buildTestcases(
503+
config: config.withArchitecture("aarch64").withLinuxDistributionVersion("22.04")
504+
)
505+
}
506+
507+
func testJammyX86_64Direct() async throws {
508+
try skipSlow()
509+
try await buildTestcases(
510+
config: config.withArchitecture("x86_64").withLinuxDistributionVersion("22.04")
511+
)
512+
}
513+
514+
func testJammyAarch64FromContainer() async throws {
515+
try skipSlow()
516+
try await buildTestcases(
517+
config: config.withArchitecture("aarch64").withLinuxDistributionVersion("22.04").withDocker()
518+
)
519+
}
520+
521+
func testJammyX86_64FromContainer() async throws {
522+
try skipSlow()
523+
try await buildTestcases(
524+
config: config.withArchitecture("x86_64").withLinuxDistributionVersion("22.04").withDocker()
525+
)
526+
}
527+
}
528+
465529
final class Swift59_RHELEndToEndTests: XCTestCase {
466530
let config = SDKConfiguration(
467531
swiftVersion: "5.9.2",
@@ -591,3 +655,37 @@ final class Swift60_RHELEndToEndTests: XCTestCase {
591655
)
592656
}
593657
}
658+
659+
final class Swift61_RHELEndToEndTests: XCTestCase {
660+
let config = SDKConfiguration(
661+
swiftVersion: "6.1",
662+
linuxDistributionName: "rhel",
663+
linuxDistributionVersion: "ubi9",
664+
architecture: "aarch64",
665+
withDocker: true // RHEL-based SDKs can only be built from containers
666+
)
667+
668+
func testAarch64FromContainer() async throws {
669+
try skipSlow()
670+
try await buildTestcases(config: config.withArchitecture("aarch64"))
671+
}
672+
673+
func testX86_64FromContainer() async throws {
674+
try skipSlow()
675+
try await buildTestcases(config: config.withArchitecture("x86_64"))
676+
}
677+
678+
func testAmazonLinux2Aarch64FromContainer() async throws {
679+
try skipSlow()
680+
try await buildTestcases(
681+
config: config.withArchitecture("aarch64").withContainerImageSuffix("amazonlinux2")
682+
)
683+
}
684+
685+
func testAmazonLinux2X86_64FromContainer() async throws {
686+
try skipSlow()
687+
try await buildTestcases(
688+
config: config.withArchitecture("x86_64").withContainerImageSuffix("amazonlinux2")
689+
)
690+
}
691+
}

0 commit comments

Comments
 (0)