I want to build a static binary executable for a Haskell (it is important not to depend on any system libraries in my case). I use stack as my preferred build tool. Which flags should be set to achieve this? Bonus points for a brief explanation of each one.
Asked
Active
Viewed 1,412 times
8
-
2As the ghc provides it's runtime to each executable statically by default, you should be fine, if you use no FFI-bindings to external libraries. – Tobi Nary Mar 02 '16 at 16:42
-
Except for libgmp. IIRC that one is always dynamically linked. You can [link that one statically too](https://stackoverflow.com/questions/10539857/statically-link-gmp-to-an-haskell-application-using-ghc-llvm). – Zeta Mar 02 '16 at 16:55
-
You can also avoi dusing libgmp entirely, but that takes a specially compiled ghc. – Thomas M. DuBuisson Mar 02 '16 at 17:31
-
3You should also be aware that even programs statically linked against glibc still have runtime dependencies on system files for things like locales and `dlopen`. – Reid Barton Mar 02 '16 at 18:13
-
1While googling the same problem, i found both your question and this answer: https://ro-che.info/articles/2015-10-26-static-linking-ghc. I haven't had a chance to try it out, though. – Fried Brice Aug 31 '18 at 17:31