Distribution of an executable on Linux: lib_InternalSwiftScan.so

When I like to distribute an executable on Linux without demanding an installation of Swift, and I do not want to statically link the Swift libraries because of the missing (or "unstable") LTO functionality, I simply add the dynamic libraries to the folder where the executable resides. (Linux packages do not need to be installed for distribution if no packages of the standard Linux installation have been removed, at least this is the case for Ubuntu.) So I get a "portable" distribution of my executable.

To my knowledge the "so" files (including the symlinks) in usr/lib/swift/linux suffice. But the symlink lib_InternalSwiftScan.so links to ../host/lib_InternalSwiftScan.so, but does not seem to be necessary. What is it for? Is it needed for distribution of the executable?

So should I add usr/lib/swift/host to my distribution, or is a subset of usr/lib/swift/linux enough, and which subset is then OK? And why are the symlinks necessary?

cc @etcwilde

The two lib_InternalSwift*.so libraries are host libraries used by the toolchain, ie they are not used by executable code at runtime, but were probably placed alongside the runtime libraries before because nobody knew where to put them. Now that there is a lib/swift/host/ directory in the Swift toolchain which contains all the swift-syntax host libraries, one of them was moved there, but the symlink was kept in the old location in case somebody still needed it there, as far as I recall.

You don't need any such host libraries to run your code.

1 Like