vak: (Default)
[personal profile] vak
[personal profile] ufm задал важный вопрос: умеет ли Swift собирать бинарники в статике, чтобы без зависимостей. И он таки умеет! Фича описана в отдельной статье: Getting Started with the Static Linux SDK.

Для этого надо скачать и установить дополнительный пакет.
wget https://download.swift.org/swift-6.0-release/static-sdk/swift-6.0-RELEASE/swift-6.0-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz
swift sdk install swift-6.0-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz
Пересобираем тот же пример в статике:
$ cd ~/hello-swift

$ swift build --swift-sdk aarch64-swift-linux-musl -c release

Building for production...
[5/5] Linking hello-swift
Build complete! (0.59s)

$ .build/release/hello-swift
Hello, world!

$ ldd .build/release/hello-swift
not a dynamic executable

$ size .build/release/hello-swift
text data bss dec hex filename
5092581 1125304 180652 6398537 61a249 .build/release/hello-swift
Размер бинарника 5 мегабайт. Немало, но и не ужас-ужас.
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org