-
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
Document static compilation (was: Static compile support for AWS Linux (Redhat/CentOS)) #1032
Comments
Can you list the steps you initially took and the error message you received? |
Also, the steps you used to resolve the problem would be very useful too. |
some people including myself would love to have a simple |
I used the compile flags above. Had to use straight GHC since something broke inside Stack on the Redhat 7 install. If you run ldd a.out you get a list of dynamic libs you have to bring in. For each I went to there project page, downloaded them and did the ./configure;make; sudo make install . |
@chadbrewbaker As mentioned above, I'll need to see the error messages generated. And how did you get the |
Stack does not install both static and dynamic versions of all pre-compiled On Sat, Sep 26, 2015 at 11:25 PM, Michael Snoyman [email protected]
|
Maybe I just don't have enough experience with Redhat, but this issue still isn't clear to me. Can you clarify what you mean by "pre-compiled libraries," for instance? Is this Haskell libraries, system libraries, etc? |
/usr/lib type libraries. To statically link you need libfoo.a, not libfoo.so or libfoo.dylib. If libfoo.a doesn't exist you either have to find a libfoo-static package, or download the libfoo source and compile it yourself as a static library. |
If you'd like to send a PR to modify the rpms to include the relevant On Thu, Oct 1, 2015, 2:37 PM Chad Brewbaker [email protected]
|
I'm not quite clear. Stack doesn't install any libraries in /usr/lib. The distro packages (RPMs/.Debs) do list minimal dependencies so that regular Stack functionality works, but I don't know that we should extend the dependencies to cover every possible use case. RPMs don't seem to support recommended vs. required dependencies the way Debian packages packages do either so we can't just add them to a recommended/suggested list in the case of CentOS/RHEL/Amazon. We've already more-or-less decided that "configuration management" (e.g. installing system libs) is out of scope for Stack, much as we'd all love for Stack to do everything. At minimum, though, it's certainly worth documenting what is required to build static binaries. |
I don't disagree. I'll write a bash script this weekend that pulls down other needed packages and builds a static hello world for AWS Lambda then make a pull request to the docs. |
Problem: GMP is LGPL so distributing a statically linked binary without corresponding |
No LGPL violation if you include the source. |
There is no LGPL violation if the software is not being distributed — I guess using AWS Lambda for private stuff / company use counts here. Is it possible to build a custom ghc for use with stack btw? I'd like to be able to not use glibc with ghc (and the one that stack downloads uses it), but with something like ghc-musl instead. |
@proger: Yes it's possible to use a custom GHC with Stack, using the ghc-variant option. |
👍 for having a --static flag :D |
Maybe some bits from this r/haskell thread might be useful for fixing this issue. |
The instructions here are helpful for linux, but I struggle to get them to work on OS X. I've asked a question on Stack Overflow about this; http://stackoverflow.com/questions/39805657/how-can-i-create-static-executables-on-os-x-with-stack |
I've also created a repo that minimally reproduces the problems you might see when trying to statically link an executable that requires a C library: https://github.com/jml/haskell-static-minimal-repro |
https://ghc.haskell.org/trac/ghc/ticket/10912 is this ticket filed against GHC. |
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 refers to it. I tried to grok the code in order to propose a PR, but sadly I don't understand zip of the code. |
|
Stack is very similar to https://rustup.rs . Would it make sense to have some synergy in trying to pin to the same LLVM and try to link in the same manner from the user install path instead of using what may be missing/old versions of libc or libpthread etc on the host? Throw in Clang too so Rust, Haskell, C/C++ all play nice together at the LLVM IR level. |
If you are compiling for AWS Lambda you have to statically link everything, i.e. stack ghc Foo.hs -threaded -static -optl-static
This requires static versions of libffi, glibc, libgmp, ... finally got it working but it was a pain. Could really use support for static compiles out of the box in stack.
The text was updated successfully, but these errors were encountered: