Swift compiler warning on Linux

Wrote a simple "Hello World" script and used swiftc to compile the program. It does compile and I can run the program, however the compiler issues the following warning:

My setup:

  • Fedora 38 Linux on Intel Core i7
  • Linux fedora 6.2.15-300.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 11 17:37:39 UTC 2023 x86_64 GNU/Linux
  • Swift version 5.8 (swift-5.8-RELEASE)

The program has only one line:

print("Hello, World!")

Compile:

$ swiftc test.swift 

Warning message:

warning: direct reference to protected function $sSJ12isWhitespaceSbvg in /usr/libexec/swift/5.8/bin/../lib/swift/linux/libswiftCore.so may break pointer equality

How to fix, or is this a bug? I can safely ignore it (I think), but I haven't yet built a larger program with Swift on Linux, and not sure what this really means.

Jason

3 Likes

Would you mind giving this a quick check with a 5.9 nightly build if the issue persists there?

5.9 (May 23'rd build) ==> same exact warning.

2 Likes

Can confirm this has been an issue with my builds of the -main toolchain on Linux (Fedora rawhide) for some months, including a build of HEAD as of an hour ago. Doesn't seem to have a functional impact however.

1 Like

Thanks Ryan.

Since it's a "pointer" warning, it should be addressed.

What linker did you use? BFD is known not to work with Swift and can break relocations. gold or lld should work though.

Can you give us the output of swiftc -v test.swift

Edit: Actually, where did you get this toolchain/runtime? If you compiled it yourself, which linker did you use when building the Swift stdlib/runtime?

Built myself on Fedora rawhide, using lld.