Skip to content

Support Debian 11 and Debian 12 distributions in the generator #203

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f52aa21
Increase unzip stream limit for larger package lists
xtremekforever Mar 3, 2025
8e0ffcf
Merge branch 'main' into #116-support-debian-distributions
xtremekforever Mar 4, 2025
dedcd6d
Add missing --linux-distribution-version to sdkGeneratorArguments
xtremekforever Mar 4, 2025
fd58911
Add Debian 11/12 as potential distributions for building SDKs for
xtremekforever Feb 16, 2025
c28cbc0
Initial code to download dependencies for Debian distributions from p…
xtremekforever Mar 4, 2025
e8aa0c3
Support downloading Debian packages on top of Ubuntu packages
xtremekforever Mar 7, 2025
da140b3
Add support for Debian 11 build from packages
xtremekforever Mar 7, 2025
a41ce54
Add EndToEndTests for all supported Debian Swift SDK builds
xtremekforever Mar 7, 2025
4ebb1ae
Merge branch 'main' into #116-support-debian-distributions
xtremekforever Mar 12, 2025
051985a
Restore missing withContainerImageSuffix
xtremekforever Mar 23, 2025
ea57421
Update comments for Debian 11 end-to-end tests
xtremekforever Mar 23, 2025
72588ac
Support building Swift 5.9 SDKs for Debian Bookworm using Ubuntu Jamm…
xtremekforever Mar 23, 2025
f4d0922
Adjust targetSwift path to include swiftPlatform to identify the tool…
xtremekforever Mar 23, 2025
5462ab0
Add tests for downloading Ubuntu toolchains when Debian targets are s…
xtremekforever Mar 24, 2025
ad87cf8
Merge branch 'main' into #116-support-debian-distributions
xtremekforever Mar 24, 2025
9bf533b
Also update README.md to recognize new Debian 11/12 support
xtremekforever Mar 26, 2025
144b407
Copy /lib and /lib64 for Debian 11 containers
xtremekforever Mar 26, 2025
b199eef
Fix missing syntax for switch statement in 5.8
xtremekforever Mar 28, 2025
8f00942
Merge branch 'main' into #116-support-debian-distributions
xtremekforever Apr 4, 2025
fd400b1
Merge branch 'main' into #116-support-debian-distributions
xtremekforever Apr 4, 2025
1e59866
Merge branch 'main' into #116-support-debian-distributions
MaxDesiatov Apr 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ The generator also allows cross-compiling between any Linux distributions offici
| macOS (arm64) | ✅ macOS 13.0+ | ❌ |
| macOS (x86_64) | ✅ macOS 13.0+[^1] | ❌ |
| Ubuntu | ✅ 20.04+ | ✅ 20.04+ |
| RHEL | ✅ Fedora 39[^2], UBI 9 | ✅ UBI 9 |
| Debian | ✅ 11, 12[^2] | ✅ 11, 12[^2] |
| RHEL | ✅ Fedora 39, UBI 9 | ✅ Fedora 39, UBI 9[^3] |
| Amazon Linux 2 | ✅ Supported | ✅ Supported[^3] |
| Debian 12 | ✅ Supported[^2] | ✅ Supported[^2][^3] |

[^1]: Since LLVM project doesn't provide pre-built binaries of `lld` for macOS on x86_64, it will be automatically built
from sources by the generator, which will increase its run by at least 15 minutes on recent hardware. You will also
need CMake and Ninja preinstalled (e.g. via `brew install cmake ninja`).
[^2]: These distributions are only supported by Swift 5.10.1 and later as both host and target platforms.
[^2]: Swift does not officially support Debian 11 or Debian 12 with Swift versions before 5.10.1. However, the Ubuntu 20.04/22.04 toolchains can be used with Debian 11 and 12 (respectively) since they are binary compatible.
[^3]: These versions are technically supported but require custom commands and a Docker container to build the Swift SDK, as the generator will not download dependencies for these distributions automatically. See [issue #138](https://github.com/swiftlang/swift-sdk-generator/issues/138).

## How to use it
Expand Down
10 changes: 7 additions & 3 deletions Sources/GeneratorCLI/GeneratorCLI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ extension GeneratorCLI {

@Option(
help: """
Linux distribution to use if the target platform is Linux. Available options: `ubuntu`, `rhel`. Default is `ubuntu`.
Linux distribution to use if the target platform is Linux.
- Available options: `ubuntu`, `debian`, `rhel`. Default is `ubuntu`.
""",
transform: LinuxDistribution.Name.init(nameString:)
)
Expand All @@ -208,8 +209,9 @@ extension GeneratorCLI {
@Option(
help: """
Version of the Linux distribution used as a target platform.
Available options for Ubuntu: `20.04`, `22.04` (default when `--linux-distribution-name` is `ubuntu`), `24.04`.
Available options for RHEL: `ubi9` (default when `--linux-distribution-name` is `rhel`).
- Available options for Ubuntu: `20.04`, `22.04` (default when `--distribution-name` is `ubuntu`), `24.04`.
- Available options for Debian: `11`, `12` (default when `--distribution-name` is `debian`).
- Available options for RHEL: `ubi9` (default when `--distribution-name` is `rhel`).
"""
)
var linuxDistributionVersion: String?
Expand Down Expand Up @@ -239,6 +241,8 @@ extension GeneratorCLI {
linuxDistributionDefaultVersion = "ubi9"
case .ubuntu:
linuxDistributionDefaultVersion = "22.04"
case .debian:
linuxDistributionDefaultVersion = "12"
}
let linuxDistributionVersion =
self.linuxDistributionVersion ?? linuxDistributionDefaultVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extension SwiftSDKGenerator {
logger.info("Launching a container to extract the Swift SDK for the target triple...")
try await withDockerContainer(fromImage: baseDockerImage) { containerID in
try await inTemporaryDirectory { generator, _ in
let sdkLibPath = sdkDirPath.appending("lib")
let sdkUsrPath = sdkDirPath.appending("usr")
try await generator.createDirectoryIfNeeded(at: sdkUsrPath)
try await generator.copyFromDockerContainer(
Expand Down Expand Up @@ -60,6 +61,15 @@ extension SwiftSDKGenerator {
to: sdkUsrLib64Path
)
try await createSymlink(at: sdkDirPath.appending("lib64"), pointingTo: "./usr/lib64")
} else if case let containerLib64 = FilePath("/lib64"),
try await generator.doesPathExist(containerLib64, inContainer: containerID)
{
let sdkLib64Path = sdkDirPath.appending("lib64")
try await generator.copyFromDockerContainer(
id: containerID,
from: containerLib64,
to: sdkLib64Path
)
}

let sdkUsrLibPath = sdkUsrPath.appending("lib")
Expand All @@ -72,13 +82,26 @@ extension SwiftSDKGenerator {
// architecture-specific directories:
// https://wiki.ubuntu.com/MultiarchSpec
// But not in all containers, so don't fail if it does not exist.
if case .ubuntu = targetDistribution {
subpaths += [("\(targetTriple.archName)-linux-gnu", false)]
if targetDistribution.name == .ubuntu || targetDistribution.name == .debian {
var archSubpath = "\(targetTriple.archName)-linux-gnu"

// Custom subpath for armv7
// armv7 with Debian uses a custom subpath for armhf
if targetTriple.archName == "armv7" {
subpaths += [("arm-linux-gnueabihf", false)]
archSubpath = "arm-linux-gnueabihf"
}

// Copy /lib/<archSubpath> for Debian 11
if case let .debian(debian) = targetDistribution, debian == .bullseye {
try await generator.createDirectoryIfNeeded(at: sdkLibPath)
try await generator.copyFromDockerContainer(
id: containerID,
from: FilePath("/lib").appending(archSubpath),
to: sdkLibPath.appending(archSubpath),
failIfNotExists: false
)
}

subpaths += [(archSubpath, false)]
}

for (subpath, failIfNotExists) in subpaths {
Expand All @@ -89,7 +112,11 @@ extension SwiftSDKGenerator {
failIfNotExists: failIfNotExists
)
}
try await generator.createSymlink(at: sdkDirPath.appending("lib"), pointingTo: "usr/lib")

// Symlink if we do not have a /lib directory in the SDK
if await !generator.doesFileExist(at: sdkLibPath) {
try await generator.createSymlink(at: sdkLibPath, pointingTo: "usr/lib")
}

// Look for 32-bit libraries to remove from RHEL-based distros
// These are not needed, and the amazonlinux2 x86_64 symlinks are messed up
Expand Down
Loading