Re: Linking completely statically
Hi Volker, > Is it possible to link the remaining libraries statically too? > Yes, it is possible to generate fully statically linked Haskell binaries. Though it requires a bit of setup. For example the GNU C library glibc is not really intended for fully static linking, but you can use musl as an alternative libc instead. Probably the easiest way is to use static-haskell-nix [1]. Usage instructions are available in the project README. See [2] if you're not familiar with Nix. Recently, the Haskell extension to Bazel, rules_haskell, also gained the ability to generate fully statically linked binaries building on top of Nix, see [3]. Best, Andreas [1]: https://github.com/nh2/static-haskell-nix [2]: https://nixos.org/ [3]: https://rules-haskell.readthedocs.io/en/latest/haskell-use-cases.html#building-fully-statically-linked-binaries ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Re: Linking completely statically
Am Dienstag, den 11.08.2020, 10:26 +0200 schrieb Herrmann, Andreas: > Hi Volker, Hi! > > Is it possible to link the remaining libraries statically too? > > Yes, it is possible to generate fully statically linked Haskell > binaries. Though it requires a bit of setup. For example the GNU C > library glibc is not really intended for fully static linking, but > you can use musl as an alternative libc instead. > > Probably the easiest way is to use static-haskell-nix [1]. Usage > instructions are available in the project README. See [2] if you're > not familiar with Nix. This looks complicated, even though it is the easiest way. I've tried to build it from the git sources, as well as from the latest release, but that failed. I'd have to look into nix, which is new to me. Be it as it may, it isn't that important for me right now. But thank you very much for your tips. Maybe I'll be going back to them later. Cheers, Volker > Recently, the Haskell extension to Bazel, rules_haskell, also gained > the ability to generate fully statically linked binaries building on > top of Nix, see [3]. > > Best, Andreas > > [1]: https://github.com/nh2/static-haskell-nix > [2]: https://nixos.org/ > [3]: > https://rules-haskell.readthedocs.io/en/latest/haskell-use-cases.html#building-fully-statically-linked-binaries signature.asc Description: This is a digitally signed message part ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Re: Linking completely statically
Hi Volker, You may also want to check out ghc-musl project https://github.com/utdemir/ghc-musl which provides compiled docker images to build atatic executables for various ghc versions. Cheers, -- aycan > On Aug 11, 2020, at 5:59 AM, Volker Wysk wrote: > > Am Dienstag, den 11.08.2020, 10:26 +0200 schrieb Herrmann, Andreas: >> Hi Volker, > > Hi! > >>> Is it possible to link the remaining libraries statically too? >> >> Yes, it is possible to generate fully statically linked Haskell >> binaries. Though it requires a bit of setup. For example the GNU C >> library glibc is not really intended for fully static linking, but >> you can use musl as an alternative libc instead. >> >> Probably the easiest way is to use static-haskell-nix [1]. Usage >> instructions are available in the project README. See [2] if you're >> not familiar with Nix. > > This looks complicated, even though it is the easiest way. I've tried > to build it from the git sources, as well as from the latest release, > but that failed. I'd have to look into nix, which is new to me. > > Be it as it may, it isn't that important for me right now. > > But thank you very much for your tips. Maybe I'll be going back to them > later. > > > Cheers, > Volker > >> Recently, the Haskell extension to Bazel, rules_haskell, also gained >> the ability to generate fully statically linked binaries building on >> top of Nix, see [3]. >> >> Best, Andreas >> >> [1]: https://github.com/nh2/static-haskell-nix >> [2]: https://nixos.org/ >> [3]: >> https://rules-haskell.readthedocs.io/en/latest/haskell-use-cases.html#building-fully-statically-linked-binaries > > > ___ > Glasgow-haskell-users mailing list > Glasgow-haskell-users@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Re: Linking completely statically
I was able to get static linking working recently using docker alpine images and ghcup to install GHC based on the musl library. The details are in my Stan fork [1]. This borrowed heavily from ShellCheck's static linking release system except it uses cabal v2-build instead of v1. [1] Script: https://github.com/TomMD/stan/blob/feature/basic-json-output/mkRelease.sh Dockerfile: https://github.com/TomMD/stan/blob/feature/basic-json-output/Dockerfile On Sun, Aug 9, 2020 at 5:51 AM Volker Wysk wrote: > Hi! > > I know of the command line argument "-static". But this only affects > the Haskell libraries. I want to link some programs completely > statically, no external libraries needed. > > When just linking with "-static" I still have those dynamically linked > things: > > desktop ~/bin $ ldd sicherung > linux-vdso.so.1 (0x7ffdab53f000) > libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 > (0x7f3633da) > librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 > (0x7f3633d95000) > libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 > (0x7f3633d9) > libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 > (0x7f3633d8a000) > libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 > (0x7f3633d67000) > libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10 > (0x7f3633ce3000) > libatomic.so.1 => /lib/x86_64-linux-gnu/libatomic.so.1 > (0x7f3633cd7000) > libffi.so.7 => /lib/x86_64-linux-gnu/libffi.so.7 > (0x7f3633ccb000) > libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 > (0x7f3633ad9000) > /lib64/ld-linux-x86-64.so.2 (0x7f3633f0c000) > > > Is it possible to link the remaining libraries statically too? > > Regards, > Volker > ___ > Glasgow-haskell-users mailing list > Glasgow-haskell-users@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users > ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users