-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
How to build statically linked Haskell binaries? #6855
Comments
ld-options
in cabal for static compilation causes nix-build
to fail.
@aaronlevin, thank you very much for the detailed bug report. I really appreciate the effort you've put into setting up an easily reproducible test case! The problems you're experiencing aren't caused by the use of Now, the proper way to build statically linked Haskell libraries with Cabal is to configure the build with the flag Generally speaking, I'd recommend against hard-coding these kind of flags in the Cabal file and to leave those choices to the user running
the the |
@peti thanks for the detailed (and enlightening) response! One note I wanted to make: I was able to hop into a Thanks again for your notes. PS - the fact that Nix provides some safe reproducibility and because we can make a |
Our builder doesn't use |
Sorry for a bit of an offtopic. |
@AleXoundOS as with the release of Stack 1.7.1 statically linked Linux bindists are no longer available, due to difficulty with GHC 8.2.2 on Alpine Linux. Source and more information on the Haskell Cafe Mailing List. It looks like this is a problem also affecting Stack 1.6, relevant Issue here. @kindaro has done an excellent brief report about the current situation. You may avoid this problem on Windows or OSX, but I‘m unsure if this is really true. I‘m not sure if the now unavailable feature would solve your problem. If it does, a downgrade may help. |
@emanuelbuholzer, thank you for the info. |
I PR's a flag to Cabal to make building static binaries easier: haskell/cabal#5446 To answer the original question
https://github.com/nh2/static-haskell-nix shows how you can do that with the It can build many Haskell exes already, and I wouldn't be surprised if with nixpkgs 18.09 all of it is easily available. (Most of the background work has been done by others such as @dtzWill and @Ericson2314) |
See #43795 for an overview issue |
I'm not sure if this is known or not.
If I add
-static
and-pthread
told-options
in myproject.cabal
file and try to build withnix-build
(full steps below) I will get a failure. It looks likeld
cannot find certain libraries.Steps to Recreate
I've created a repository that will allow you to clone and
nix-build run.nix
to see the issue. The repository is here: https://github.com/aaronlevin/nixpkgsissueHere is an overview of the steps:
project.cabal
file:project.nix
:cabal2Nix . > project.nix
nix-build run.nix
One should see errors similar to this output: http://lpaste.net/126997 and the build will fail.
The text was updated successfully, but these errors were encountered: