-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support fully-static linking #8
Comments
It seems Swift 5.3 packaged all static libs (Dispatch, Foundation etc.) for their Linux dist. Let me try to hack it a bit see if it roughly works. |
Got some time to do some investigations in what's needed:
With these, a minimal viable patch I made will generate binary that doesn't link to any Swift runtime (still have glibc / pthread etc): https://gist.github.com/liuliu/9450547b0c12488a95ad7f2485395407. Note that at the moment, this has to be compiled with By doing this, I successfully compiled https://github.com/liuliu/s4nnc/tree/main/examples/ddpg with the following
Before this patch, the output looks like this:
@keith , I think this makes a good case to move forward with this task, given other discussions such as https://forums.swift.org/t/pre-pitch-statically-link-by-default-on-linux/52837 What I need for guidance, mostly due to that I am not familiar with how
Above investigations only done with Swift 5.5.1 on Ubuntu 20.04. |
I don't see from your patch what |
It is a file under |
Right now, we only support kind-of-static linking: the
swift_library
targets that the binary depends on are statically linked into the final binary, but the Swift runtime libraries are dynamically linked. This is fine (and in fact, desired) on Apple's mobile platforms (iOS, tvOS, watchOS), but on Linux (and probably macOS), we should offer static linking against the runtime as well.One interesting catch: Linux toolchains do not come with a static version of
libdispatch
, which would seem to mean you can't do a whole lot of interesting stuff in a statically linked environment. So this might reduce the usefulness and urgency of this feature.The text was updated successfully, but these errors were encountered: