Additional Linux Distributions

I tried

swift -sdk /Library/Developer/Platforms/Linux.platform/Developer/SDKs/Linux.sdk bla.swift

and then I get:

<unknown>:0: error: could not load the swift standard library

strace shows

openat(AT_FDCWD, "/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/lib/swift/linux/libswiftCore.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT

but doing

dpkg -L swift-linux-sdk|grep libswiftCore

gives

/Library/Developer/Platforms/Linux.platform/Developer/SDKs/Linux.sdk/usr/lib/swift/linux/libswiftCore.so

So it seems to search in the wrong place.

This is Ubuntu 20.04.

That sentence is confusing. Is it integrated or not? If it is what help is needed and if not, can you give a hint how to help?

That is really odd; I've definitely had this working on Ubuntu previously as I had this setup in docker with VSCode: https://github.com/compnerd/swift-build/blob/master/docs/GettingStartedDocker.md

I would recommend mirroring the Windows flags for now:

export SDKROOT=/Library/Developer/Platforms/Linux.platform/Developer/SDKs/Linux.sdk
swiftc -sdk ${SDKROOT} -I ${SDKROOT}/usr/lib/swift -L ${SDKROOT}/usr/lib/swift/linux -emit-executable -o /tmp/reduced /tmp/reduced.swift

Sorry, this is what happens with an early morning reply. The s-p-m builds are not integrated yet :-(. That is the help that is needed, the configuration for that is at https://github.com/compnerd/swift-build/blob/master/.ci/templates/linux-devtools.yml; updating that to finish building it and packaging it up into a dpkg (https://github.com/compnerd/swift-build/blob/master/.ci/templates/devtools-deb.yml) should enable it to be uploaded as well.

How is the versioning managed?

I'm not sure.

Pinging @Ron_Olson

I only release "-RELEASE" versions; typically I try to build it the same day as I get the notification from GitHub that the Release version is available. There's typically a week (two in the case of RHEL/CentOS) of testing from getting the rpm built to it being pushed to stable and subsequently available as part of a dnf update or new installation.

1 Like

I'm highlighting this because Swift has no ABI guarantees on Linux β€” installing a new Swift version immediately invalidates all binaries built previously that still reside on the system. It's something that I generally warn against.

5 Likes

Ouch. Are there any actual plans to fix this? Meanwhile it's probably OK to set the soname to the full version.
Did it actually break between subminor versions, or is it a precaution that it might?

Are those packages doing a distinction between a Swift runtime package and a -dev one? Or are they one big blob?

OK, Thanks!

I just found this repology page, that lists all package repositories with a Swift compiler. I added the Termux package for Android listed there last month: you can write basic Swift code (only stdlib so far, working on cross-compiling the corelibs and Swift package manager to Android) on most Android phones and tablets (64-bit AArch64 running Android 7 or later) by installing the Termux app and typing pkg install swift.

If there's interest, I can submit a pull to add the repology badge listing all Swift repositories, from this page of badges, to the Swift README:

Packaging status

1 Like

That fails with:

/usr/bin/ld.gold: error: cannot open Scrt1.o: No such file or directory
/usr/bin/ld.gold: error: cannot open crti.o: No such file or directory
/usr/bin/ld.gold: error: cannot open crtbeginS.o: No such file or directory
/usr/bin/ld.gold: error: cannot open crtendS.o: No such file or directory
/usr/bin/ld.gold: error: cannot open crtn.o: No such file or directory
/usr/bin/ld.gold: error: cannot find -lgcc
/usr/bin/ld.gold: error: cannot find -lgcc_s
/usr/bin/ld.gold: error: cannot find -lc
/usr/bin/ld.gold: error: cannot find -lgcc
/usr/bin/ld.gold: error: cannot find -lgcc_s

Any ideas? (This is Ubuntu 20.04.)

The Ubuntu 18.04 (flowkey) build fails with

2020-05-14T13:18:13.3647816Z CMake Error at CMakeLists.txt:45 (find_package):
2020-05-14T13:18:13.3648536Z   Could not find a package configuration file provided by "Yams" with any of
2020-05-14T13:18:13.3649087Z   the following names:
2020-05-14T13:18:13.3649666Z 
2020-05-14T13:18:13.3650275Z     YamsConfig.cmake
2020-05-14T13:18:13.3650939Z     yams-config.cmake

After a quick look I wasn't able to find said CMakeLists.txt. Can you give me a pointer?

That's true. Up until 5.2.x swift-lang-runtime was a subpackage of swift-lang but ultimately with no ABI guarantee it seemed like the runtime package was making a promise that couldn't be delivered; so with 5.2.x I removed it.

1 Like

I recall there was breakage back in the 4.x versions, I've had success running 5.2.1 binaries against later versions of 5.2. I mentioned below that I did break out runtime into a separate sub-package, but since there was no guarantee it would work with later versions, I figured having the whole thing available for easier recompilation would be better.

The problem is that people are just going to end up to depend on the whole swift toolchain to get the runtime?

I think it would be preferable to just have the different runtime versions available. E.g. libswift5.2.1.rpm having libswift5.2.1.so with the soname set to the full 5.2.1. So that parallel installs of binaries work.
I mean it is not like we get a new Swift version every two weeks :slight_smile:

I did consider, early on, having a totally separate Swift Runtime package that was separate and exclusive from the Swift package, that was versioned and added to /usr/ld.so.conf.d in way similar to how LLVM does it, but it got dropped just trying to get Swift working. It might be worth considering doing that now.

2 Likes

The link failures are due to missing dependencies. You should install: libc6-dev libgcc-8-dev libncurses-dev libstdc++-8-dev and that should then succeed to link.

Note that this is what the docker image that I create is for - it basically packages the toolchain and the small set of packages needed to use it. Additionally it includes a copy of VSCode that runs entirely in the docker image. Ideally, it would be setup with SourceKit-LSP and everything but I've got a bunch of other stuff to do. If you want to help push forward on that, Im happy to have help!

Oh, I didn't notice the failures because Im dealing with a pretty nasty runtime issue at the moment.

Seems that s-p-m has grown a dependency on Yams which I've not added to the build yet. This is more tricky as the repository needs to be cloned on all jobs as otherwise we end up with longer builds. Seems reasonable to add that though.

It might be instructive to look at how the distributions deal with packaging LLVM, which has the same general issue of no ABI guarantees for most of its libraries.

1 Like

Nope, that's not it:

sudo apt install libc6-dev libgcc-8-dev libncurses-dev libstdc++-8-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libc6-dev is already the newest version (2.31-0ubuntu9).
libncurses-dev is already the newest version (6.2-0ubuntu2).
libgcc-8-dev is already the newest version (8.4.0-3ubuntu2).
libstdc++-8-dev is already the newest version (8.4.0-3ubuntu2).

I'd like the deb packages to be in a state where they could be uploaded to Debian. Since Ubuntu basically imports everything from there Swift would be very easy to install on a huge number of computers (Debian, Ubuntu, all other derivatives), just like clang: Debian -- Details of package clang in sid

If you can guide me I'm willing to invest some time. :slight_smile:

Debian -- Package Contents Search Results -- Scrt1.o verifies that libc6-dev definitely provides the C library support files. Can you verify that they are present on the system?

Debian -- Package Contents Search Results -- libgcc_s.so verifies that libgcc-8-dev provides the compiler runtime libraries. Can you verify that they are present on the system?

Sounds great to me!