Skip to content

GHC does not build with musl (ZuriHac 2021 edition) #129247

@nh2

Description

@nh2

In this issue I'm writing up 3 problems that broke GHC on musl (e.g. pkgsMusl.ghc, and all of static-haskell-nix on current nixpkgs) during the last half year.

We started investigating these at ZuriHac, but didn't get to the bottom; with some more weekends sunk into it, I've now figured them out.

The key problems:

  1. GHC bootstrap binaries segfault on musl (link)
  2. check_match: Assertion `version->filename == NULL error due to mismatching versions of ncurses in the GHC bindists (link)
  3. ghc-8.6.5-binary.nix compilation fails with recompile with -fPIE (explained in this issue)

The challenging part about these problems are that they (and some fixes) were introduced in roughly the same time, such that one had to fix all 3 of them to actually get pkgsMusl.ghc to compile again, and making bisection much harder.

This meant that we were unable to make any real progress during ZuriHac 2021, and a lot more contributor free time had to be spent to figure it out.

lobby time:

An always-green Hydra that builds pkgsMusl.ghc would have saved multiple workdays of multiple people here.


If you are interested in these topics, here is the table of contents of problems plus their fixes, with links to the detail investigations:

  1. GHC bootstrap binaries segfault on musl (GHC-8.6.5 bootstrap binary installation segfault on musl #118731)
    • I bisected this (writeup here to a musl change that suggests that our current way to use glibc bindists from GHC HQ, and patch musl in so that there are 2 different libcs used in the same program, only worked out of luck so far.
    • I plan to fix it by using the newer musl/Alpine based bindists from GHC HQ that exist for GHC > 8.10.
  2. check_match: Assertion version->filename == NULLerror due to mismatching versions ofncurses` in the GHC bindists (pkgsMusl.haskell.compiler.ghc883 is broken (bootstrap with ghc865-binary fails) #85924)
  3. ghc-8.6.5-binary.nix compilation fails with recompile with -fPIE
    • A new issue introduced when nixpkgs started to enable "pie" hardening for musl only. Works fine for C, but GHC cannot yet emit outputs that are ready for pie hardening.
    • Explained in detail in this issue.
    • Conflated by the fact that the nixpkgs manual doesn't make clear that pie hardening is disabled by default for glibc, because, the heading structure of that manual section is poor, making it easy to read it as part of the enabled-by-default hardening options.
    • I plan to fix it by disabling pie hardening for Haskell builds, but found is already done in master by 830ef64 via PR Haskell updates #123682.

This issue can be closed when all above problems are addressed on nixpkgs master.


CC the people involved in these topics: @expipiplus1 @bgamari @nomeata @domenkozar @dtzWill @lunaris @NorfairKing @maralorn @sternenseemann

Special thanks to @aveltras and tristanC who helped me debug a lot during ZuriHac.

Metadata

Metadata

Assignees

Labels

6.topic: haskellGeneral-purpose, statically typed, purely functional programming language6.topic: muslRunning or building packages with musl libc
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions