Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to nixos-23.05 #116

Merged
merged 29 commits into from
Jul 13, 2023
Merged

Update to nixos-23.05 #116

merged 29 commits into from
Jul 13, 2023

Conversation

nh2
Copy link
Owner

@nh2 nh2 commented Jun 10, 2023

@nh2
Copy link
Owner Author

nh2 commented Jun 10, 2023

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
Copy link
Owner Author

nh2 commented Jun 10, 2023

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 added 5 commits June 11, 2023 15:13
It picked the one from the line below it due to `let rec` instead
of the one from the top-level arguments.
The motivation is that @aherrmann and @jonathanlking want to use Bazel
and found that it might it easier to use `.a` files in TH than to try
to provide `.so` AND `.a` files of all dependencies.
@nh2
Copy link
Owner Author

nh2 commented Jun 11, 2023

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
Copy link
Owner Author

nh2 commented Jun 11, 2023

@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.

Comment on lines 1562 to 1564
(ghcPackage:
ghcPackage.override { enableRelocatedStaticLibs = useArchiveFilesForTemplateHaskell; }
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the rules_haskell use-case this requires

Suggested change
(ghcPackage:
ghcPackage.override { enableRelocatedStaticLibs = useArchiveFilesForTemplateHaskell; }
)
(ghcPackage:
ghcPackage.override {
enableRelocatedStaticLibs = useArchiveFilesForTemplateHaskell;
enableShared = !useArchiveFilesForTemplateHaskell;
}
)

That is because we require a static runtime to load static Haskell libraries for template Haskell.
Otherwise the build fails with errors like these (tested here):

/nix/store/fhr7av2b52a8dz8lii59bvydgx0vw5ap-binutils-2.39/bin/ld: cannot find -lHScolour-2.3.6-ghc9.0.2: No such file or directory
collect2: error: ld returned 1 exit status
`cc_wrapper-python' failed in phase `Linker'. (Exit code: 1)

@nh2
Copy link
Owner Author

nh2 commented Jun 13, 2023

@jonathanlking @aherrmann

I pushed some new fixes.

Now only 9 packages fail for workingStackageExecutables.

nh2 added 2 commits July 13, 2023 19:39
…s-23.05.

Only minimal patches are put on top of the `nixos-23.05` branch to
support more of Stackage. All have nixpkgs PRs.

    nix-build --no-link survey/default.nix -A workingStackageExecutables | wc -l
    368
@nh2 nh2 marked this pull request as ready for review July 13, 2023 19:49
@nh2
Copy link
Owner Author

nh2 commented Jul 13, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants