You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Build Swift SDKs for a Linux host if the --host parameter matches a Linux OS (*-unknown-linux-gnu) (#167)
This fixes#114 and provides the following:
- If the `--host` param or auto-detected `hostTriple.os` is `.linux`, the amazonlinux2 Swift toolchain is downloaded and included in the Swift SDK. Examples:
```
swift run swift-sdk-generator make-linux-sdk --swift-version 6.0.3-RELEASE --host x86_64-unknown-linux-gnu --target aarch64-unknown-linux-gnu
swift run swift-sdk-generator make-linux-sdk --swift-version 5.10.1-RELEASE --host aarch64-unknown-linux-gnu --target x86_64-unknown-linux-gnu
```
- I chose `amazonlinux2` for the host toolchain as it seems to be compatible with *every* Swift-supported Linux distribution with glibc versions and included libraries.
- Updated the README.md to show that Ubuntu, RHEL, Amazon Linux 2, and Debian are officially supported as hosts and somewhat supported as targets... :)
For testing all of this, I updated the EndToEndTests:
- If the`SWIFT_SDK_GENERATOR_TEST_LINUX_SWIFT_SDKS` env variable is defined, Swift SDKs are built for a Linux host with the arch matching the machine on which the tests are running. So on an M-series Mac, the triple `aarch64-unknown-linux-gnu` is used. Or on an Intel Mac or PC, then `x86_64-unknown-linux-gnu` is used as the `--host` triple.
- When Linux Swift SDKs are being tested, then a matrix of Swift docker containers are run against each test case to ensure the SDK works on every Linux distribution:
```
[SwiftSDKGeneratorTests] Creating test project /tmp/FDFD488C-089B-4213-B927-0DE0F9BD6B3A/swift-sdk-generator-test
[SwiftSDKGeneratorTests] Updating minimum swift-tools-version in test project...
[SwiftSDKGeneratorTests] Building test project in 6.0-focal container
[SwiftSDKGeneratorTests] Test project built successfully
[SwiftSDKGeneratorTests] Building test project in 6.0-focal container with static-swift-stdlib
[SwiftSDKGeneratorTests] Test project built successfully
[SwiftSDKGeneratorTests] Building test project in 6.0-jammy container
[SwiftSDKGeneratorTests] Test project built successfully
[SwiftSDKGeneratorTests] Building test project in 6.0-jammy container with static-swift-stdlib
[SwiftSDKGeneratorTests] Test project built successfully
[SwiftSDKGeneratorTests] Building test project in 6.0-noble container
[SwiftSDKGeneratorTests] Test project built successfully
[SwiftSDKGeneratorTests] Building test project in 6.0-noble container with static-swift-stdlib
[SwiftSDKGeneratorTests] Test project built successfully
[SwiftSDKGeneratorTests] Building test project in 6.0-fedora39 container
[SwiftSDKGeneratorTests] Test project built successfully
[SwiftSDKGeneratorTests] Building test project in 6.0-fedora39 container with static-swift-stdlib
[SwiftSDKGeneratorTests] Test project built successfully
[SwiftSDKGeneratorTests] Building test project in 6.0-rhel-ubi9 container
[SwiftSDKGeneratorTests] Test project built successfully
[SwiftSDKGeneratorTests] Building test project in 6.0-rhel-ubi9 container with static-swift-stdlib
[SwiftSDKGeneratorTests] Test project built successfully
[SwiftSDKGeneratorTests] Building test project in 6.0-amazonlinux2 container
[SwiftSDKGeneratorTests] Test project built successfully
[SwiftSDKGeneratorTests] Building test project in 6.0-amazonlinux2 container with static-swift-stdlib
[SwiftSDKGeneratorTests] Test project built successfully
[SwiftSDKGeneratorTests] Building test project in 6.0-bookworm container
[SwiftSDKGeneratorTests] Test project built successfully
[SwiftSDKGeneratorTests] Building test project in 6.0-bookworm container with static-swift-stdlib
[SwiftSDKGeneratorTests] Test project built successfully
```
[^1]: Since LLVM project doesn't provide pre-built binaries of `lld` for macOS on x86_64, it will be automatically built
45
46
from sources by the generator, which will increase its run by at least 15 minutes on recent hardware. You will also
46
47
need CMake and Ninja preinstalled (e.g. via `brew install cmake ninja`).
48
+
[^2]: These distributions are only supported by Swift 5.10.1 and later as both host and target platforms.
49
+
[^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).
0 commit comments