Right now, if you do the following on Ubuntu 22.04:
swift run swift-sdk-generator make-linux-sdk --swift-version 5.10.1-RELEASE --host x86_64-unknown-linux-gnu
The generator will still download the OSX package for the Swift 5.10.1, resulting in an SDK that is unusable on Ubuntu. If you pass --host-swift-package-path /path/to/swift/installation to the generator, then it will use the correct version of the Swift toolchain and package it in the generated SDK. However, there are errors involved since the Swift distribution for Linux includes extra libraries:
~/.swiftpm/swift-sdks/5.10.1-RELEASE_ubuntu_jammy_aarch64.artifactbundle/5.10.1-RELEASE_ubuntu_jammy_aarch64/aarch64-unknown-linux-gnu/ubuntu-jammy.sdk/usr/include/CoreFoundation/module.map:1:8: error: redefinition of module 'CoreFoundation'
module CoreFoundation [extern_c] [system] {
^
~/.swiftpm/swift-sdks/5.10.1-RELEASE_ubuntu_jammy_aarch64.artifactbundle/5.10.1-RELEASE_ubuntu_jammy_aarch64/aarch64-unknown-linux-gnu/swift.xctoolchain/usr/lib/swift/CoreFoundation/module.map:1:8: note: previously defined here
module CoreFoundation [extern_c] [system] {
^
~/.swiftpm/swift-sdks/5.10.1-RELEASE_ubuntu_jammy_aarch64.artifactbundle/5.10.1-RELEASE_ubuntu_jammy_aarch64/aarch64-unknown-linux-gnu/ubuntu-jammy.sdk/usr/include/dispatch/module.modulemap:1:8: error: redefinition of module 'Dispatch'
module Dispatch {
^
~/.swiftpm/swift-sdks/5.10.1-RELEASE_ubuntu_jammy_aarch64.artifactbundle/5.10.1-RELEASE_ubuntu_jammy_aarch64/aarch64-unknown-linux-gnu/swift.xctoolchain/usr/lib/swift/dispatch/module.modulemap:1:8: note: previously defined here
module Dispatch {
This can be resolved by simply removing these extra libraries (dispatch and CoreFoundation) from the swift.xctoolchain directory. However, it would be nice if the generator could do all this for us and correctly pull the Swift distribution for Linux automatically, if running on a Ubuntu or RHEL host.
Right now, if you do the following on Ubuntu 22.04:
swift run swift-sdk-generator make-linux-sdk --swift-version 5.10.1-RELEASE --host x86_64-unknown-linux-gnu
The generator will still download the OSX package for the Swift 5.10.1, resulting in an SDK that is unusable on Ubuntu. If you pass
--host-swift-package-path /path/to/swift/installation
to the generator, then it will use the correct version of the Swift toolchain and package it in the generated SDK. However, there are errors involved since the Swift distribution for Linux includes extra libraries:This can be resolved by simply removing these extra libraries (dispatch and CoreFoundation) from the swift.xctoolchain directory. However, it would be nice if the generator could do all this for us and correctly pull the Swift distribution for Linux automatically, if running on a Ubuntu or RHEL host.