Skip to content

Support downloading & installing Swift toolchain for Ubuntu/RHEL hosts when on Linux #115

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

Closed
xtremekforever opened this issue Jul 9, 2024 · 3 comments

Comments

@xtremekforever
Copy link
Contributor

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.

@xtremekforever
Copy link
Contributor Author

@MaxDesiatov @euanh question for you guys. Do you think it would be acceptable/okay for the swift-sdk-generator to have an option to generate an SDK with just the sysroot for the target and no version of Swift included, like the static Linux SDKs?

I would like to use the SDK generator to build some SDKs for various targets, but I do not want Swift included so that they can be used on any host (macOS, Linux, etc).

@euanh
Copy link
Contributor

euanh commented Dec 16, 2024

I think this would be a nice option. It was not possible before #155 because, as you noticed, we were copying some of the target SDK files into the toolchain. After #155 the SDK and toolchain should be completely separate, so you should be able to remove the toolchain and still have a working SDK.

⚠️ If you don't include a toolchain in the SDK then on macOS you will need to install a matching version of the OSS Swift toolchain rfom https://www.swift.org/install/macos/package_installer in order to use the SDK. This is the same situation as the Static Linux SDK: https://www.swift.org/documentation/articles/static-linux-getting-started.html#installing-the-sdk

@xtremekforever
Copy link
Contributor Author

Indeed. I think that's an acceptable compromise for an SDK that is compatible with a wider range of hosts, as long as you have the exact version of Swift installed :). Thank you, I shall have a look here and see if I can add an option. Do I need to file a ticket for this as well?

xtremekforever added a commit to xtremekforever/swift-sdk-generator that referenced this issue Jan 6, 2025
xtremekforever added a commit to xtremekforever/swift-sdk-generator that referenced this issue Jan 8, 2025
… github.com:xtremekforever/swift-sdk-generator into swiftlang#115-linux-host-toolchain-from-host-triple
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants