https://cs-syd.eu/posts/2024-04-20_static-linking-haskell-nix
15 Likes
Nice! I like to use file
to tell if a binary is executable, viz.
$ file $(which ja)
/home/vanessa/.local/bin/ja: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=224fa312cf92297cbd4ed8fe488f77155434ac6f, stripped
``
I’ve also had success using the Cabal flag --enable-executable-static
in place of --ghc-option=-optl=-static
.
According to the docs, it passes -optl=-static
and -static
to GHC.
1 Like
That used to be broken on install
(as opposed to build
).
It was fixed here: Apply local configuration to install targets by alt-romes · Pull Request #9697 · haskell/cabal · GitHub
But I don’t know if that made it into a release yet.
You can use the gchup cabal prerelease 3.11.0.0.2024.4.19: ghcup-metadata/ghcup-prereleases-0.0.8.yaml at develop · haskell/ghcup-metadata · GitHub
ghcup config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml
ghcup install cabal latest-prerelease
1 Like