Change:
Describe the bug Trying to build GHC 8.8.3 on pkgsMusl (in order to build static Haskell executables) fails with: To Reproduce On a recent pin of nixpkgs-unstable (rev ): Expected behavior GHC 8.8.3 is built based on Musl Notify maintainers Metadata system: host os: multi-user?: sandbox: version: channels(remo): nixpkgs:
Thanks for creating this issue. Unfortunately, we don't always check to make sure the musl builds succeed before merging stuff in. If you wanted to fix this issue, we'd happily accept a PR. Also, is doing a lot with the musl builds, especially in If you absolutely need a musl'd GHC, I'd suggest to use
To add to that: I pin a nixpkgs that works well in a submodule: ! and the same in the : On the issue: We've seen build failures on latest nixpkgs with musl recently, hopefulyy they will be fixed soon!
Just for the record, current versions of (and ) still have this issue. We'll try to build the package with reverted to check whether the update of the boot compiler caused this problem.
Many thanks all for your help and quick responses! As suggested I reverted and is currently building, getting much further than on ghc865-binary - looking good! I'll update once the build is done, takes quite a bit of time... Edit: Confirmed, successfully built ! I would like to contribute a fix if possible, but I'm not sure what direction would be best to take - GHC 8.8.3 binaries are , would it make sense to bootstrap from there? Edit2: Maybe it just needs in Trying that out right now. Would that be likely to break anything else? Edit3: Couldn't get the dependency from ncurses to work for 8.6.5-binary on pkgsMusl... , I saw that you worked on related things, do you have an idea maybe how to solve this?
CC
It looks to me like this is a bug in the derivation. In particular, the it exposes has the incorrect soname. This is likely because is isn't at all; rather, it's simply a symlink to . In general I don't see how this could work.
We work around this in mpickering/ghc-artefact-nix via
Collecting some info for myself: The derivation refers to (called rather in the issue description) is Question: Do you know what a fix could look like? Instead of a symlink, should it be a copy of the file, on which is subsequently run, as shown in your link? If yes, should that happen unconditionally or only for ? I don't know anything about the ncurses 5-6 switch, so I have no idea why this sophisticated mechanism is there in the first place.
The ideal solution would be to rather use a GHC binary distribution which expects ABI 6. For instance, this patch appears to work around the issue locally:
I have opened to track the symlink issue.
Is it feasible to add to hydra to prevent this from happening?
FWIW this also happens with the ghc-8.10.2 binary used to bootstrap ghc901:
I built things with patch above and it all went very smoothly, is there a reason against including it in nixpkgs, even if just for musl builds?

Discussion:
{ stdenv , fetchurl, perl, gcc <del> , ncurses5, gmp, glibc, libiconv </del> <ins> , ncurses5, ncurses6, gmp, glibc, libiconv </ins> , llvmPackages }:

let useLLVM = !stdenv.targetPlatform.isx86; <ins> useNcurses6 = stdenv.hostPlatform.system == "x86_64-linux"; ourNcurses = if useNcurses6 then ncurses6 else ncurses5; </ins> libPath = stdenv.lib.makeLibraryPath ([ <del> ncurses5 gmp </del> <ins> ourNcurses gmp </ins> ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv); libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"

# https://downloads.haskell.org/~ghc/8.6.5/ src = fetchurl ({ i686-linux = { <ins> # Don't use the Fedora27 build (as below) because there isn't one! </ins> url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-deb9-linux.tar.xz"; sha256 = "1p2h29qghql19ajk755xa0yxkn85slbds8m9n5196ris743vkp8w"; }; x86_64-linux = { <del> url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-deb9-linux.tar.xz"; sha256 = "1pqlx6rdjs2110g0y1i9f8x18lmdizibjqd15f5xahcz39hgaxdw"; </del> <ins> # This is the Fedora build because it links against ncurses6 where the # deb9 one links against ncurses5, see here # https://github.com/NixOS/nixpkgs/issues/85924 for a discussion url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-fedora27-linux.tar.xz"; sha256 = "18dlqm5d028fqh6ghzn7pgjspr5smw030jjzl3kq6q1kmwzbay6g"; </ins> }; aarch64-linux = { url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-aarch64-ubuntu18.04-linux.tar.xz";

'' + # Rename needed libraries and binaries, fix interpreter stdenv.lib.optionalString stdenv.isLinux '' <del> find . -type f -perm -0100 -exec patchelf  </del> <ins> find . -type f -perm -0100  -exec patchelf  </ins> --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so  <del> --replace-needed libtinfo.so libtinfo.so.5  </del> <ins> ${ # This isn't required for x86_64-linux where we use ncurses6 stdenv.lib.optionalString (!useNcurses6) "--replace-needed libtinfo.so libtinfo.so.5" }  </ins> --interpreter ${glibcDynLinker} {} ; sed -i "s|/usr/bin/perl|perlx00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2

<ins> @@ -, +, @@ --- bfd/elf32-arm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/bfd/elf32-arm.c +++ a/bfd/elf32-arm.c @@ -15398,7 +15398,11 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info, linker to copy the initial value out of the dynamic object and into the runtime process image.  We need to remember the offset into the .rel(a).bss section we are going to use.  */ -  if ((h->root.u.def.section->flags & SEC_READONLY) != 0) +  if (info->nocopyreloc == 0 +      && (h->root.u.def.section->flags & SEC_ALLOC) != 0 +      /* PR 16177: A copy is only needed if the input section is readonly.  */ +      && (h->root.u.def.section->flags & SEC_READONLY) != 0 +      && h->size != 0) { s = globals->root.sdynrelro; srel = globals->root.sreldynrelro; @@ -15410,6 +15414,8 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info, } if (info->nocopyreloc == 0 && (h->root.u.def.section->flags & SEC_ALLOC) != 0 +      /* PR 16177: A copy is only needed if the input section is readonly.  */ +      && (h->root.u.def.section->flags & SEC_READONLY) != 0 && h->size != 0) { elf32_arm_allocate_dynrelocs (info, srel, 1); </ins>

./patches/2.31/0001-x86-Properly-add-X86_ISA_1_NEEDED-property.patch ] ++ lib.optional stdenv.targetPlatform.isiOS ./support-ios.patch <ins> ++ # This patch was suggested by Nick Clifton to fix # https://sourceware.org/bugzilla/show_bug.cgi?id=16177 # It can be removed when that 7-year-old bug is closed. # This binutils bug causes GHC to emit broken binaries on armv7, and # indeed GHC will refuse to compile with a binutils suffering from it. See # this comment for more information: # https://gitlab.haskell.org/ghc/ghc/issues/4210#note_78333 lib.optional stdenv.targetPlatform.isAarch32 ./R_ARM_COPY.patch </ins> ; outputs = [ "out" "info" "man" ];