-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add --static compiler option #4872
Conversation
When attempting to statically link the compiler, we need to statically link llvm. This means we need to pass --link-static to llvm-config. This is achieved by adding an official --static compiler option, which both adds -static to the cc invocation, and sets a "static" compiler flag. This is utilised in lib_llvm.cr to add --link-static to our llvm-config invocation.
fd02456
to
37d1242
Compare
We should probably ensure that specs pass on a static build on CI. Or at least assert that the spec can compile. |
Most wanted infrastructure feature. |
I'm submitting this and #4874 because I've automated building a statically-linked portable omnibus, and I'm upstreaming the patches which made it buildable. I hope that this can replace the current fragile omnibus with something a bit more robust. The source code is available here: https://github.com/RX14/crystal-dist-static. Simply run |
Hey crystal folks, Could this information be included into wiki + main tutorial too? Perhaps some advanced section or something like this. I'll explain why next. First, searching via google, I found this link: https://github.com/crystal-lang/crystal/wiki/Static-Linking This is a stub though; might be useful to extend it. Anyway - I am a ruby person (no surprise with this nick, I only use the github account to provide feedback and sometimes discuss a few things), but due to various reasons I need a "base" For example, I have static binaries for sed, make, most of coreutils + binutils, awk/gawk and so However had, it is a bit difficult to get a statically compiled version of ruby; even a statically So my next step was ... "what if I could just use crystal, rather than struggle with python and I had a look in this thread; and also other threads but the information is a bit ... dispersed My goal would then be to actually look at the ruby code that I need, and see how to then So essentially what I am asking here - would some heroic person write some documentation The two ideal places I can think of would be a) the crystal wiki and perhaps b) the official |
@rubyFeedback The distributed linux binaries for Crystal are already fully statically linked. If you want to compile it yourself, you can use our distribution-script (or adapt the steps to the build system of your choice). I've added a few more information to the Static Linking wiki page. A fully-featured tutorial would be nice, but that's another story. |
When attempting to statically link the compiler, we need to statically link llvm. This means we need to pass
--link-static
tollvm-config
. This is achieved by adding an official--static
compiler option, which both adds-static
to thecc
invocation, and sets a "static" compiler flag. This is utilised inlib_llvm.cr
to add--link-static
to ourllvm-config
invocation.