About static linking and Swift SDKs

Hello,

Recently, I gave a try to the so-called Linux Static SDK, that in turn sent me down the rabbit hole of Swift SDKs and the swift-sdk-generator repository.

My questions:

  1. If I were to create my custom musl-based SDK, probably with no other dependency than musl itself, would I be on the right path with this tool?
  2. Is a PITA to be expected in the process?
  3. Is there a source repo of how the Linux Static SDK was created? Maybe it's my fault, but I can only find a copy/paste URL to the binary artifact in the Swift Linux download page. A live GitHub reference would be more helpful.

Thanks!

Probably not, because Musl out of the box is not strictly compatible with Clang modules that Swift relies on for C interop. Musl is patched in the existing Swift SDK for Musl scripts, which Swift SDK Generator doesn't do at the moment (probably not too hard to add though). If you were interested in porting this to Swift SDK Generator, I'd greatly appreciate it of course and happy to review PRs that do it. But if you're looking for a path of least resistance, then utilizing existing scripts would probably be a better option.

Depends on the nature of your customisations.

Yes, see the link to the scripts above.

1 Like

Awesome, this is a great point to start. Well, my main blocker with the prebuilt SDK is BoringSSL, because I need to use OpenSSL, and they clash with each other. Other things I'm not sure, but at some point, I probably won't even need Foundation.

Another thing that I expect a static SDK to help me with, if I understood correctly, is that it allows me to run apps on Linux distros with "older" glibc, due to not using glibc at all. My Raspberry Pi 4 was the first place where I struggled to distribute Linux binaries, but Ubuntu 22 also has an older glibc than Swift requires (the 6.1 runtime requires 2.38).