File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -338,6 +338,35 @@ Yes, Stack supports using Docker with images that contain preinstalled Stackage
338338packages and the tools. See [ Docker integration] ( docker_integration.md ) for
339339details.
340340
341+ ## How do I build a statically-linked executable on Linux?
342+
343+ The way that Stack itself builds statically-linked Stack executables for Linux
344+ is as follows:
345+
346+ * In the Cabal file, the following
347+ [ ` ld-options ` ] ( https://cabal.readthedocs.io/en/stable/cabal-package.html#pkg-field-ld-options )
348+ are set: ` -static ` and ` -pthread ` .
349+
350+ * The Stack command is run in a Docker container based on Alpine Linux. The
351+ relevant Docker image repository is set out in Stack's ` stack.yaml ` file. See
352+ also https://gitlab.com/benz0li/ghc-musl .
353+
354+ * Stack's configuration includes:
355+
356+ ~~~ yaml
357+ extra-include-dirs :
358+ - /usr/include
359+ extra-lib-dirs :
360+ - /lib
361+ - /usr/lib
362+ ~~~
363+
364+ * The build command is `stack build --docker --system-ghc --no-install-ghc` (on
365+ x86_64) or
366+ ` stack build --docker --docker-stack-exe=image --system-ghc --no-install-ghc`
367+ (on AArch64; the host Stack and the image Stack must have the same version
368+ number).
369+
341370# # How do I use this with Travis CI?
342371
343372See the [Travis CI instructions](travis_ci.md)
You can’t perform that action at this time.
0 commit comments