nh2 / static-haskell-nix

easily build most Haskell programs into fully static Linux executables
388 stars 36 forks source link

Update to nixos-23.05 #116

Closed nh2 closed 1 year ago

nh2 commented 1 year ago

Work on ZuriHac 2023 with @jonathanlking:

nh2 commented 1 year ago

Trying

nix-build --no-out-link survey/default.nix -A working.hello

fails with linker errors regarding libelf. Investigating the linker invocation (revealed by passing -v to ghc), we see ... -lelf -ldw .... That's the wrong way around. Inverting them, we see linker errors regaring symbols from ZSTD and other compression libraries that libdw uses. Adding:

-L/nix/store/lh5mwy1f0ncakvahryrs3qfxd9pgp81c-zstd-static-x86_64-unknown-linux-musl-1.5.5/lib -lzstd
-L/nix/store/xyc3qbpkamyjif6aryrdkfwybsax8fqr-zlib-static-x86_64-unknown-linux-musl-1.2.13/lib -lz
-L/nix/store/vf10zcfikzhxa8lzbr3wy7pfvzyzhr3r-bzip2-static-x86_64-unknown-linux-musl-1.0.8/lib -lbz2
-L/nix/store/adas6a61mndhcb3sflxgrnpykhdq7acn-xz-static-x86_64-unknown-linux-musl-5.4.3/lib -llzma

Then we get

ld: /nix/store/13gccvgy3br4jdacyc7ir7h37231d7ib-elfutils-0.189/lib/libdw.a(libdw_alloc.o): in function `__libdw_oom':
(.text+0x2c0): undefined reference to `error'

Unclear what error function it is referring to.

nh2 commented 1 year ago

Debugging why it still has the elf-related linker error after disabling DWARF:

nix-build --no-out-link --expr '(import ./survey/default.nix {}).working.hello.overrideAttrs (old: { configureFlags = (old.configureFlags or []) ++ ["--ghc-options=-v"]; })'
nh2 commented 1 year ago

Debugging why it still has the elf-related linker error after disabling DWARF:

We overrode the GHC incorrectly, overriding only ghc but not buildHaskellPackages.

nh2 commented 1 year ago

@jonathanlking, @chpatrick and me added support for useArchiveFilesForTemplateHaskell and basic support for ghc962.

ghc962 can build hello:

nix-build --expr '(import ./survey/default.nix { compiler = "ghc962"; useArchiveFilesForTemplateHaskell = true; }).working.hello'

but not much more because the Stackage in nixpkgs is targeting GHC 9.2. But that's fine because Bazel users likely don't need Haskell packages building in nixpkgs, as they build those themselves.

nh2 commented 1 year ago

@jonathanlking @aherrmann

I pushed some new fixes.

Now only 9 packages fail for workingStackageExecutables.

nh2 commented 1 year ago

I have fixed a few more of the workingStackageExecutables set, and made some more nixpkgs PRs (see abvoe).

368 Stackage executables build statically:

% nix-build --no-link survey/default.nix -A workingStackageExecutables | wc -l
368

The 28 that do not build are:

Agda
Allure
csg
cuda
debug
diagrams-builder
diagrams-cairo
gloss-examples
gtk-sni-tray
gtk3
H
hackage-cli
hamilton
hquantlib
ihaskell
LambdaHack
language-puppet
learn-physics
LPFP
magico
monomer
nanovg
odbc
pango
qchas
rhine-gloss
soxlib
termonad

Compare this to previous numbers.


Merging.