Errors using Swift on Fedora 43

I'm on Fedora 43 and trying to get Swift to work. Even basic commands like swift package resolve on a fresh project error. Here's the full set of commands I ran (starting in /home/bbrk24/workspace):

mkdir swift-test
cd swift-test
swift package init
swift package resolve -v

Here's the output of that last command:

error: 'swift-test': Invalid manifest (compiled with: ["/home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/bin/swiftc", "-vfsoverlay", "/tmp/TemporaryDirectory.YmhkWB/vfs.yaml", "-L", "/home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/pm/ManifestAPI", "-lPackageDescription", "-Xlinker", "-rpath", "-Xlinker", "/home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/pm/ManifestAPI", "-swift-version", "6", "-I", "/home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/pm/ManifestAPI", "-package-description-version", "6.2.0", "/home/bbrk24/workspace/swift-test/Package.swift", "-v", "-o", "/tmp/TemporaryDirectory.fSbKaO/swift-test-manifest"])
/home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/bin/swift-frontend -frontend -c -primary-file /home/bbrk24/workspace/swift-test/Package.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/pm/ManifestAPI -vfsoverlay /tmp/TemporaryDirectory.YmhkWB/vfs.yaml -no-color-diagnostics -Xcc -fno-color-diagnostics -swift-version 6 -package-description-version 6.2.0 -empty-abi-descriptor -no-auto-bridging-header-chaining -module-name main -in-process-plugin-server-path /home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/host/libSwiftInProcPluginServer.so -plugin-path /home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/host/plugins -plugin-path /home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/local/lib/swift/host/plugins -o /tmp/TemporaryDirectory.rPgsBI/Package-1.o
/home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/bin/swift-autolink-extract /tmp/TemporaryDirectory.rPgsBI/Package-1.o -o /tmp/TemporaryDirectory.rPgsBI/main-1.autolink
/home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/bin/clang -pie -Xlinker --build-id -Xlinker -rpath -Xlinker /home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/linux /home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/linux/x86_64/swiftrt.o /tmp/TemporaryDirectory.rPgsBI/Package-1.o @/tmp/TemporaryDirectory.rPgsBI/main-1.autolink -L /home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/linux -lswiftCore --target=x86_64-unknown-linux-gnu -v -L /home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/pm/ManifestAPI -lPackageDescription -Xlinker -rpath -Xlinker /home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/pm/ManifestAPI -o /tmp/TemporaryDirectory.fSbKaO/swift-test-manifest
Swift version 6.2.3 (swift-6.2.3-RELEASE)
Target: x86_64-unknown-linux-gnu
error: link command failed with exit code 1 (use -v to see invocation)
clang version 17.0.0 (https://github.com/swiftlang/llvm-project.git 9784760565e8cae0bc0b97bad69aaf498408dc3d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/15
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/15
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/15
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
 "/usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/bin/ld" --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -pie -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o /tmp/TemporaryDirectory.fSbKaO/swift-test-manifest /usr/lib/gcc/x86_64-linux-gnu/15/../../../../lib64/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/15/../../../../lib64/crti.o /usr/lib/gcc/x86_64-linux-gnu/15/crtbeginS.o -L/home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/linux -L/home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/pm/ManifestAPI -L/usr/lib/gcc/x86_64-linux-gnu/15 -L/usr/lib/gcc/x86_64-linux-gnu/15/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib --build-id -rpath /home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/linux /home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/linux/x86_64/swiftrt.o /tmp/TemporaryDirectory.rPgsBI/Package-1.o -lswiftSwiftOnoneSupport -lswiftCore -lswift_Concurrency -lswift_StringProcessing -lswift_RegexParser -lswiftCore -lPackageDescription -rpath /home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/pm/ManifestAPI -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/15/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/15/../../../../lib64/crtn.o
/usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/bin/ld: cannot find -lgcc_s: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I see that the linker is blowing up with "cannot find -lgcc_s", but shouldn't it be parsing that as a flag and looking for something like /lib*/libgcc_s.so*, not a file called -lgcc_s in the current directory? In fact I do have both /lib/libgcc_s.so.1 and /lib64/libgcc_s.so.1.

(This particular output is if I install Swift via Swiftly and tell it to set up as if for Fedora 39. If I instead sudo dnf install swift-lang, I get a very similar error, but the output isn't identical -- the linker it chooses is different, but it still says "cannot find -lgcc_s".)

1 Like

I am running Swift 6.2 on Fedora 43 (on a framework desktop - pretty cool :wink: ) succesfully after applying this preview patch: https://bodhi.fedoraproject.org/updates/FEDORA-2025-db571dad17

His error is completely different from the warnings you noted earlier, doubt that patch helps with this one.

True, but I think I saw the same errors when trying to use `swiftly` to install swift on fedora 43…

@bbrk24, can you make sure you have all package dependencies listed here for Fedora installed?

1 Like

Thank you :folded_hands: After installing the dependencies for Fedora (39), swiftly was able to install a working toolchain - at least for me! Yay :slight_smile:

Thank you both for the suggestions! I'm not at my computer right now but I'll be able to test it later today.

Some relevant information I didn't include in the original post:

I'll have to double-check that I have everything on that list. swift repl works now, but it didn't at first -- I had to manually install Python. So it's very probable I'm missing another package on that list as well.

If I install Swift through dnf, I see the warnings mentioned in the other post in addition to the error I mentioned here. The output above, which does not include those warnings, is what I see iff I install it via swiftly.

While that did add some packages I didn't have before, I still get the same error, unfortunately.

This said "Nothing to do." (I removed the dnf swift-lang so I currently only have Swift through swiftly.)

Try running swift package reset or rm -rf .build/ in the package directory you are trying to build, before trying to build again.

Even if I completely start fresh (rm -Rf * .*; swift package init) I still get the error.

Can you try building a simple "hello world" executable with the Swift clang and see if it works, ie

> cat main.c
#include <stdio.h>
int main() { puts("check linker object");}

> /home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/bin/clang -o check main.c

> ./check

The SwiftPM build of the package manifest is failing to find a fairly basic binutils object file, which suggests either something wrong with your local installation of those tool dependencies or how swiftly is using it.

Ah yeah, that gives me the same error:

bbrk24@fedora:~$ which clang
~/.local/share/swiftly/bin/clang
bbrk24@fedora:~$ clang -xc - <<<'#include <stdio.h>
int main() {
  puts("Hello, world!");
  return 0;
}'
/usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/bin/ld: cannot find -lgcc_s: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
bbrk24@fedora:~$ gcc -xc - <<<'#include <stdio.h>
int main() {
  puts("Hello, world!");
  return 0;
}'
bbrk24@fedora:~$ ./a.out
Hello, world!

Notice that the linker is failing to find -lgcc_s, not libgcc_s.so or similar.

Ok, so the problem is with the Swift clang install interacting with the system libraries, nothing specific to Swift here. There was some work in swift-driver to delegate to the system clang by @etcwilde, I wonder if that would help here: try installing the system clang package and check if it has the same problem, and if not, try SwiftPM again and see if it picks up the system clang instead.

1 Like

System clang works fine:

bbrk24@fedora:~$ /usr/bin/clang -xc - <<<'#include <stdio.h>
> int main() {
>   puts("Hello, world!");
>   return 0;
> }'
bbrk24@fedora:~$ ./a.out
Hello, world!

But Swiftly does not appear to defer to it:

bbrk24@fedora:~/workspace/swift-test$ rm -Rf * .*
bbrk24@fedora:~/workspace/swift-test$ swift package init
Creating library package: swift-test
Creating Package.swift
Creating .gitignore
Creating Sources
Creating Sources/swift-test/swift_test.swift
Creating Tests/
Creating Tests/swift-testTests/
Creating Tests/swift-testTests/swift_testTests.swift
bbrk24@fedora:~/workspace/swift-test$ which -a clang
~/.local/share/swiftly/bin/clang
/usr/bin/clang
/usr/sbin/clang
bbrk24@fedora:~/workspace/swift-test$ swift package resolve
error: 'swift-test': Invalid manifest (compiled with: ["/home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/bin/swiftc", "-vfsoverlay", "/tmp/TemporaryDirectory.3XxCVL/vfs.yaml", "-L", "/home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/pm/ManifestAPI", "-lPackageDescription", "-Xlinker", "-rpath", "-Xlinker", "/home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/pm/ManifestAPI", "-swift-version", "6", "-I", "/home/bbrk24/.local/share/swiftly/toolchains/6.2.3/usr/lib/swift/pm/ManifestAPI", "-package-description-version", "6.2.0", "/home/bbrk24/workspace/swift-test/Package.swift", "-o", "/tmp/TemporaryDirectory.lqEmxa/swift-test-manifest"])
error: link command failed with exit code 1 (use -v to see invocation)
/usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/bin/ld: cannot find -lgcc_s: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Thanks for checking that. I went back and looked at Evan's pulls and it appears that while the intention was to defer to the system clang, they ended up just using the Swift clang, as there was a system clang that invoked the bfd linker instead, which doesn't work with the Swift runtime. Obviously, when the Swift clang is misconfigured like this, that won't help.

I notice that Swiftly only advertises Fedora 39 support, with the current release of the Swift toolchain not shipping for Fedora 41 and Swiftly saying the same.

This is obviously a bit of a complicated question, ie when it is better to defer to the system clang versus the Swift-forked clang and Swiftly has not figured out the balance on newer Fedora.

Maybe paste your log output on that Swiftly issue, and chip in on fixing it if you have the time and knowledge.

I’m going to be away from my computer for the next 2 weeks, but after that I can definitely take a look at the issue. Thanks for the advice!

Just wanted to add to all of this. I did a brand new Fedora 43 install on my machine with Swiftly 1.1.1 and got the RHEL UBI 9 toolchain installed. It seems to work fine….so I’m guessing something on your environment is being used which must be causing your issues…

Ah, I told it to install as if for Fedora 39, not RHEL 9. Maybe that’s it. How would I change that?

I think you can modify ~/.local/share/swiftly/config.json and set the distribution:

  "platform" : {
    "nameFull" : "ubi9",
    "name" : "ubi9",
    "namePretty" : "RHEL 9"
  },

Then uninstall your Swift toolchain and reinstall it to get the ubi9 version…

Just got back to my computer. Changing it from Fedora 39 to RHEL 9 and reinstalling Swift didn't help. I'll take a look at the links @Finagolfin provided aboce.