Distributing binaries for linuxes (static linking?)

To elaborate on the segfault problem, this isn't actually a problem with the Static SDK for Linux — it's an issue with the toolchain where it's trying to use libraries from the OS, but because of a problem with the OS hosted libraries we end up thinking that things are marked with the in-development availability (9999) are available when in fact in the OS libraries they are not.

This should be fixed already in the Sequoia (macOS 15) developer seed. There is a workaround here: SwiftPM built with Swift 6.0 and later snapshots crashes on macOS 14 · Issue #73327 · apple/swift · GitHub courtesy of @kateinoigakukun which I will reproduce below for convenience:

Step 1. Strip hardened runtime flag by replacing existing signature of toolchain binaries

PATH_TO_TOOLCHAIN=/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-05-15-a.xctoolchain
find $PATH_TO_TOOLCHAIN/usr/bin -type f | \
  while read line; do sudo codesign --force --preserve-metadata=identifier,entitlements --sign - $line; done

Step 2. Use toolchain binaries with DYLD_LIBRARY_PATH

DYLD_LIBRARY_PATH=$PATH_TO_TOOLCHAIN/usr/lib/swift/macosx $PATH_TO_TOOLCHAIN/usr/bin/swift-package --version
3 Likes