Static linking libFoundation fails when using string contains function

So, I've been trying to static build the following code:

import Foundation
print("Hello planet".contains("planet"));

using swiftc file.swift -static-stdlib -emit-executable

And i get a long linker error about undefined references in libfoundation: https://hastebin.com/ritomoyehe.lua

Tried on 5.3 toolchain, both Ubuntu 18.04 and Archlinux AUR toolchain (swift-bin 5.3).

That flag only works for the stdlib right now, not the corelibs, not without adding more linker flags. There is a patch that fixes this that has been merged to the 5.3 branch, but it didn't make the 5.3 release for some reason. It should be there in the next 5.3.1 patch release, you can use the workarounds in my first link in the meantime.

Terms of Service

Privacy Policy

Cookie Policy