Skip to content

Commit 72588ac

Browse files
Support building Swift 5.9 SDKs for Debian Bookworm using Ubuntu Jammy toolchain
1 parent ea57421 commit 72588ac

File tree

3 files changed

+40
-27
lines changed

3 files changed

+40
-27
lines changed

Sources/SwiftSDKGenerator/PlatformModels/LinuxDistribution.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public enum LinuxDistribution: Hashable, Sendable {
125125
"libc6-dev",
126126
"libgcc-s1",
127127
"libgcc-10-dev",
128-
"libicu66",
128+
"libicu67",
129129
"libicu-dev",
130130
"libstdc++-10-dev",
131131
"libstdc++6",

Sources/SwiftSDKGenerator/PlatformModels/VersionsConfiguration.swift

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,63 +26,63 @@ public struct VersionsConfiguration: Sendable {
2626
self.swiftVersion = swiftVersion
2727
self.swiftBranch = swiftBranch ?? "swift-\(swiftVersion.lowercased())"
2828
self.lldVersion = lldVersion
29-
if case let .debian(debian) = linuxDistribution, debian.version == "11" {
30-
logger.warning(
31-
"Debian 11 selected but not officially supported by Swift, falling back on Ubuntu 20.04 toolchain..."
32-
)
33-
self.linuxDistribution = try .init(name: .ubuntu, version: "20.04")
34-
} else {
35-
self.linuxDistribution = linuxDistribution
36-
}
29+
self.linuxDistribution = linuxDistribution
3730
self.linuxArchSuffix =
3831
targetTriple.arch == .aarch64 ? "-\(Triple.Arch.aarch64.linuxConventionName)" : ""
32+
self.logger = logger
3933
}
4034

4135
let swiftVersion: String
4236
let swiftBranch: String
4337
let lldVersion: String
4438
let linuxDistribution: LinuxDistribution
4539
let linuxArchSuffix: String
40+
private let logger: Logger
4641

4742
var swiftPlatform: String {
4843
switch self.linuxDistribution {
4944
case let .ubuntu(ubuntu):
5045
return "ubuntu\(ubuntu.version)\(self.linuxArchSuffix)"
5146
case let .debian(debian):
47+
if debian.version == "11" {
48+
logger.warning(
49+
"Debian 11 selected but not officially supported by Swift, falling back on Ubuntu 20.04 toolchain..."
50+
)
51+
// Ubuntu 20.04 toolchain is binary compatible with Debian 11
52+
return "ubuntu20.04\(self.linuxArchSuffix)"
53+
} else if self.swiftVersion.hasPrefix("5.9") || self.swiftVersion == "5.10" {
54+
logger.warning(
55+
"Debian 12 selected but not officially supported by Swift version, falling back on Ubuntu 22.04 toolchain...",
56+
metadata: ["swiftVersion": .string(self.swiftVersion)]
57+
)
58+
// Ubuntu 22.04 toolchain is binary compatible with Debian 12
59+
return "ubuntu22.04\(self.linuxArchSuffix)"
60+
}
5261
return "debian\(debian.version)\(self.linuxArchSuffix)"
5362
case let .rhel(rhel):
5463
return "\(rhel.rawValue)\(self.linuxArchSuffix)"
5564
}
5665
}
5766

5867
func swiftDistributionName(platform: String? = nil) -> String {
59-
"swift-\(self.swiftVersion)-\(platform ?? self.swiftPlatform)"
68+
return "swift-\(self.swiftVersion)-\(platform ?? self.swiftPlatform)"
6069
}
6170

6271
func swiftDownloadURL(
6372
subdirectory: String? = nil,
6473
platform: String? = nil,
6574
fileExtension: String = "tar.gz"
6675
) -> URL {
67-
let computedSubdirectory: String
68-
switch self.linuxDistribution {
69-
case let .ubuntu(ubuntu):
70-
computedSubdirectory =
71-
"ubuntu\(ubuntu.version.replacingOccurrences(of: ".", with: ""))\(self.linuxArchSuffix)"
72-
case let .debian(debian):
73-
computedSubdirectory =
74-
"debian\(debian.version.replacingOccurrences(of: ".", with: ""))\(self.linuxArchSuffix)"
75-
case let .rhel(rhel):
76-
computedSubdirectory = rhel.rawValue
77-
}
76+
let computedPlatform = platform ?? self.swiftPlatform
77+
let computedSubdirectory =
78+
subdirectory ?? computedPlatform.replacingOccurrences(of: ".", with: "")
7879

7980
return URL(
8081
string: """
8182
https://download.swift.org/\(
8283
self.swiftBranch
83-
)/\(
84-
subdirectory ?? computedSubdirectory
85-
)/swift-\(self.swiftVersion)/\(self.swiftDistributionName(platform: platform)).\(fileExtension)
84+
)/\(computedSubdirectory)/\
85+
swift-\(self.swiftVersion)/\(self.swiftDistributionName(platform: computedPlatform)).\(fileExtension)
8686
"""
8787
)!
8888
}

Tests/SwiftSDKGeneratorTests/EndToEndTests.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,17 +462,30 @@ final class Swift59_DebianEndToEndTests: XCTestCase {
462462
withDocker: false
463463
)
464464

465-
func testAarch64Direct() async throws {
465+
func testBullseyeAarch64Direct() async throws {
466466
try skipSlow()
467467
try await buildTestcases(config: config.withArchitecture("aarch64"))
468468
}
469469

470-
func testX86_64Direct() async throws {
470+
func testBullseyeX86_64Direct() async throws {
471471
try skipSlow()
472472
try await buildTestcases(config: config.withArchitecture("x86_64"))
473473
}
474474

475-
// NOTE: we do support building a Swift SDK from a pre-built Debian 11 Bullseye container
475+
func testBookwormAarch64Direct() async throws {
476+
try skipSlow()
477+
try await buildTestcases(
478+
config: config.withLinuxDistributionVersion("12").withArchitecture("aarch64"))
479+
}
480+
481+
func testBookwormX86_64Direct() async throws {
482+
try skipSlow()
483+
try await buildTestcases(
484+
config: config.withLinuxDistributionVersion("12").withArchitecture("x86_64"))
485+
}
486+
487+
// NOTE: the generator does not support building a Debian 11/Debian 12 Swift SDK for
488+
// Swift 5.9.x and 5.10 without a pre-built container, so we do not test this here.
476489
}
477490

478491
final class Swift510_DebianEndToEndTests: XCTestCase {

0 commit comments

Comments
 (0)