This repository provides an easy way to build a single statically linked binary that does not depend on Glibc or other shared libraries.
Currently, only GHC 8.10.1 is supported.
The advantage is that anyone can easily add dependent libraries by not using long, time-consuming GHC builds or unfamiliar nix hacks
shin-sakata/ghc-single-binary-builder
shinsakata/ghc-single-binary-builder
- Change resolver in
stack.yaml
Use one of the resolvers where ghc8.10.1 is used
resolver: ghc-8.10.1
# or resolver: nightly-2020-07-12
- Add the following to
stack.yaml
docker:
enable: true
repo: shinsakata/ghc-single-binary-builder:ghc8.10.1-v1.1.0
- Add options to package.yaml
executables:
stack-minimum-example-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
- -static -optl-static -optl-pthread -fPIC # <- Add options here.
dependencies:
- stack-minimum-example
- Get the binary
Execute the following command.
$ stack install --local-bin-path=./bin
A single binary will be built in ./bin/
.