-
Notifications
You must be signed in to change notification settings - Fork 844
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
Adding --static flag for building static executables with stack? #3420
Comments
Hello, Please see this I would like to fight this miss-conception of the crtbeginT hack, as it is mentioned almost everywhere when this subject is talked about and too many post now refer to it. I tried to grok the code in order to propose a PR, but sadly I don't understand zip of the code. |
Would certainly be nice to support this without modification of the cabal package, though. So maybe by having |
@erebe ah, nice! I found several sources that mentioned the crtbeginT hack, am glad to see it's not necessary! @mgsloan Am I correct in the understanding that |
@Tehnix Yep, that's right! |
So how can we go further with this request ? Do you see a way @mgsloan to unlock the situation in order to get a --static ? |
I'd say it's reasonable to unblock that issue. Unfortunately, it's probably trickier than I'd thought, if you need everything to be built with -fPIC. There's no straightforward way to reliably do this. The problem is that snapshot packages do not get rebuilt, even if they were built with different options. Workarounds:
Even though it wouldn't work ideally, it makes sense to me to implement Here's what the implementation would look like:
I'd accept a PR for this, even if the more complicated issue of snapshot package options isn't resolved. |
ack, I am finishing some work on an other project and will try to submit something after that |
I have opened an issue in cabal haskell/cabal#4925, as after a few hours I didn't understood why my flag options were not taken into account |
I have PR'd a feature to
|
Beyond that, we need to make it easy to provide a libc that can be easily linked statically (like
|
How this task is working on? I'm interested with it, seems that the crtbeginT hack it still necessary for me, but even with it I didn't successfully get. Maybe I'm doing something outdated/wrong? Anyone can share workarounds to achieve this without the hack? Currently I'm doing this:
Output:
Where MUSL_PATH it's a path containing the |
Just to share for someone lost as me: https://www.reddit.com/r/haskell/comments/9on8gi/is_there_an_easy_way_to_compile_static_binaries/ This helped me a lot! Sorry for the annoying comments. Bye |
@ryukinix For posterity, which change fixed your exact problem above? |
@nh2 In my case, I followed the first reasonable suggestion from that thread, updating the
..and then running
It was easy, and I was surprised. Basic tests of the executable have passed (the tool works as expected). I was able to use this to build the executable on ubuntu 18.04 that runs fine on ubuntu 16.04. |
commercialhaskell/stack#3420 や `stack build --help` を読む限り、そもそもstackに `--static` というオプションはまだ実装されていないようですが、 `stack build --static` というのはオプションはどこから出てきた情報でしょうか?
The suggested solution doesn't seem to work any longer on Ubuntu. I'm on 20.04 (focal) and I get errors as documented in icfpcontest2020/starterkit-haskell#2 |
@nh2 regarding #3420 (comment) , LGPL does allow static linking against proprietary software under a condition that the proprietary software, whilst being distributed as a fully compiled program, also provides itself in either source code (not suitable for most commercial projects) or compiled object code that can be linked together with the LGPL code in question (suitable for commercial projects, but requires extra work). https://www.gnu.org/licenses/gpl-faq.en.html#LGPLStaticVsDynamic |
A great question was posed in the comments to this article https://www.fpcomplete.com/blog/2016/10/static-compilation-with-stack, although it seems to have been left unanswered.
Mainly, if it could be possible to have a
--static
flag in stack, that would set the flags necessary for building a statically linked binary, and perhaps be aware of thecrtbeginT
and suggest/link to the proposed fix.This issue #1032 which is still open, seems to be somewhat related, but has been left without any activity (except for a few semi-related comments) for quite a while.
Any thoughts if it is even feasible to begin such work?
The text was updated successfully, but these errors were encountered: