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

pkgsMusl.haskell.compiler.ghc883 is broken (bootstrap with ghc865-binary fails) #85924

Closed
monacoremo opened this issue Apr 24, 2020 · 13 comments · Fixed by #103183
Closed

pkgsMusl.haskell.compiler.ghc883 is broken (bootstrap with ghc865-binary fails) #85924

monacoremo opened this issue Apr 24, 2020 · 13 comments · Fixed by #103183

Comments

@monacoremo
Copy link

Describe the bug

Trying to build GHC 8.8.3 on pkgsMusl (in order to build static Haskell executables) fails with:

...
Installing library in /nix/store/1pqmyrp2f4y3kwnvp2isc09jff91f1bw-ghc-8.6.5-binary/lib/ghc-8.6.5/ghc-8.6.5
"/nix/store/1pqmyrp2f4y3kwnvp2isc09jff91f1bw-ghc-8.6.5-binary/lib/ghc-8.6.5/bin/ghc-pkg" --force --global-package-db "/nix/store/1pqmyrp2f4y3kwnvp2isc09jff91f1bw-ghc-8.6.5-binary/lib/ghc-8.6.5/package.conf.d" update rts/dist/package.conf.install
/nix/store/1pqmyrp2f4y3kwnvp2isc09jff91f1bw-ghc-8.6.5-binary/lib/ghc-8.6.5/bin/ghc-pkg: /nix/store/1i32nv0sm71qr3qak4jg9bqmlq4pq1la-ncurses-6.2-abi5-compat/lib/libtinfo.so.5: no version information available (required by /nix/store/1pqmyrp2f4y3kwnvp2isc09jff91f1bw-ghc-8.6.5-binary/lib/ghc-8.6.5/bin/ghc-pkg)
/nix/store/1pqmyrp2f4y3kwnvp2isc09jff91f1bw-ghc-8.6.5-binary/lib/ghc-8.6.5/bin/ghc-pkg: /nix/store/1i32nv0sm71qr3qak4jg9bqmlq4pq1la-ncurses-6.2-abi5-compat/lib/libtinfo.so.5: no version information available (required by /nix/store/1pqmyrp2f4y3kwnvp2isc09jff91f1bw-ghc-8.6.5-binary/lib/ghc-8.6.5/bin/../terminfo-0.4.1.2/libHSterminfo-0.4.1.2-ghc8.6.5.so)
Inconsistency detected by ld.so: dl-lookup.c: 111: check_match: Assertion `version->filename == NULL || ! _dl_name_match_p (version->filename, map)' failed!
make[1]: *** [ghc.mk:991: install_packages] Error 127
make: *** [Makefile:51: install] Error 2
builder for '/nix/store/ywiy47vvr8b9blq32kw2zcqqqpqrs7kc-ghc-8.6.5-binary.drv' failed with exit code 2
cannot build derivation '/nix/store/0aivgs76j9xrf9flbbs5mhlfc0gfqyk9-ghc-8.8.3.drv': 1 dependencies couldn't be built

To Reproduce

On a recent pin of nixpkgs-unstable (rev 10100a9):

nix-build -A pkgsMusl.haskell.compiler.ghc883  

Expected behavior

GHC 8.8.3 is built based on Musl

Notify maintainers

@MarcWeber @andres @peti

Metadata

  • system: "x86_64-linux"
  • host os: Linux 5.0.0-38-generic, Ubuntu, 19.04 (Disco Dingo)
  • multi-user?: no
  • sandbox: yes
  • version: nix-env (Nix) 2.3.1
  • channels(remo): "nixos-20.03pre204199.3140fa89c51, nixpkgs-20.03pre204216.cc6cf0a96a6"
  • nixpkgs: /home/remo/.nix-defexpr/channels/nixpkgs
@cdepillabout
Copy link
Member

@monacoremo 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, @nh2 is doing a lot with the musl builds, especially in https://github.com/nh2/static-haskell-nix. If you absolutely need a musl'd GHC, I'd suggest to use https://github.com/nh2/static-haskell-nix.

@nh2
Copy link
Contributor

nh2 commented Apr 24, 2020

To add to that: I pin a nixpkgs that works well in a submodule:

image

and the same in the nixpkgs.file:

https://github.com/nh2/static-haskell-nix/blob/acaffd5fb807aa78f106eb3b4a99b05d3a1ec043/nixpkgs.nix#L27-L28

On the issue: We've seen build failures on latest nixpkgs master with musl recently, hopefulyy they will be fixed soon!

@peti
Copy link
Member

peti commented Apr 24, 2020

Just for the record, current versions of master (and haskell-updates) still have this issue. We'll try to build the package with 3c7ef6b reverted to check whether the update of the boot compiler caused this problem.

@monacoremo
Copy link
Author

monacoremo commented Apr 25, 2020

Many thanks all for your help and quick responses!

As @peti suggested I reverted 3c7ef6b and pkgsMusl.haskell.compiler.ghc883 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 /nix/store/x03kyh5mfrapm1mjrh5a5v4ygly6rzwz-ghc-8.8.3 !

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 now available, would it make sense to bootstrap from there?

Edit2: Maybe it just needs s/ncurses5/ncurses6/ in https://github.com/nixos/nixpkgs/blob/master/pkgs/development/compilers/ghc/8.6.5-binary.nix? Trying that out right now. Would that be likely to break anything else?

Edit3: Couldn't get the libtinfo.so dependency from ncurses to work for 8.6.5-binary on pkgsMusl... @dtzWill , I saw that you worked on related things, do you have an idea maybe how to solve this?

@nh2
Copy link
Contributor

nh2 commented Jun 7, 2020

CC @bgamari

@bgamari
Copy link
Contributor

bgamari commented Jun 7, 2020

It looks to me like this is a bug in the ncurses-abi-compat derivation. In particular, the libtinfo it exposes has the incorrect soname. This is likely because is isn't libtinfo at all; rather, it's simply a symlink to libncursesw. In general I don't see how this could work.

@bgamari
Copy link
Contributor

bgamari commented Jun 7, 2020

@nh2
Copy link
Contributor

nh2 commented Jun 7, 2020

Collecting some info for myself:

Question:

@bgamari Do you know what a fix could look like? Instead of a symlink, should it be a copy of the .so file, on which patchelf --replace-needed is subsequently run, as shown in your link? If yes, should that happen unconditionally or only for abiVersion == "5"?

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.

@bgamari
Copy link
Contributor

bgamari commented Jun 7, 2020

The ideal solution would be to rather use a GHC binary distribution which expects ncurses ABI 6. For instance, this patch appears to work around the issue locally:

diff --git a/pkgs/development/compilers/ghc/8.6.5-binary.nix b/pkgs/development/compilers/ghc/8.6.5-binary.nix
index 97793d91289..188b12f5dad 100644
--- a/pkgs/development/compilers/ghc/8.6.5-binary.nix
+++ b/pkgs/development/compilers/ghc/8.6.5-binary.nix
@@ -1,6 +1,6 @@
 { stdenv
 , fetchurl, perl, gcc
-, ncurses5, gmp, glibc, libiconv
+, ncurses6, gmp, glibc, libiconv
 , llvmPackages
 }:
 
@@ -11,7 +11,7 @@ let
   useLLVM = !stdenv.targetPlatform.isx86;
 
   libPath = stdenv.lib.makeLibraryPath ([
-    ncurses5 gmp
+    ncurses6 gmp
   ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
 
   libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
@@ -38,8 +38,8 @@ stdenv.mkDerivation rec {
       sha256 = "1p2h29qghql19ajk755xa0yxkn85slbds8m9n5196ris743vkp8w";
     };
     x86_64-linux = {
-      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-deb9-linux.tar.xz";
-      sha256 = "1pqlx6rdjs2110g0y1i9f8x18lmdizibjqd15f5xahcz39hgaxdw";
+      url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-fedora27-linux.tar.xz";
+      sha256 = "18dlqm5d028fqh6ghzn7pgjspr5smw030jjzl3kq6q1kmwzbay6g";
     };
     aarch64-linux = {
       url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-aarch64-ubuntu18.04-linux.tar.xz";
@@ -100,9 +100,9 @@ stdenv.mkDerivation rec {
     '' +
     # Rename needed libraries and binaries, fix interpreter
     stdenv.lib.optionalString stdenv.isLinux ''
-      find . -type f -perm -0100 -exec patchelf \
+      find . -type f -perm -0100 \
+          -exec patchelf \
           --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
-          --replace-needed libtinfo.so libtinfo.so.5 \
           --interpreter ${glibcDynLinker} {} \;
 
       sed -i "s|/usr/bin/perl|perl\x00        |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2

@bgamari
Copy link
Contributor

bgamari commented Jun 7, 2020

@nh2, I have opened #89769 to track the symlink issue.

nh2 added a commit to nh2/static-haskell-nix that referenced this issue Jul 27, 2020
nh2 added a commit to nh2/static-haskell-nix that referenced this issue Jul 30, 2020
* include workaround for NixOS/nixpkgs#85924
* musl 1.2.0 (#98 (comment))
* workaround for fontforge execution failure due to wrong RPATH (NixOS/nixpkgs#94126)
* ilmbase musl compilation error
nh2 added a commit to nh2/static-haskell-nix that referenced this issue Jul 30, 2020
* include workaround for NixOS/nixpkgs#85924
* musl 1.2.0 (#98 (comment))
* workaround for fontforge execution failure due to wrong RPATH (NixOS/nixpkgs#94126)
* ilmbase musl compilation error (NixOS/nixpkgs#94205)
* mesa: Fix `-Werror=int-conversion` build error on musl

fixup! nixpkgs: Update submodule:
nh2 added a commit to nh2/static-haskell-nix that referenced this issue Jul 30, 2020
* include workaround for NixOS/nixpkgs#85924
* musl 1.2.0 (#98 (comment))
* workaround for fontforge execution failure due to wrong RPATH (NixOS/nixpkgs#94126)
* ilmbase musl compilation error (NixOS/nixpkgs#94205)
* mesa: Fix `-Werror=int-conversion` build error on musl (NixOS/nixpkgs#94207)
Gabriella439 added a commit to dhall-lang/dhall-haskell that referenced this issue Aug 16, 2020
This is a revamp of our use of
[fully static Haskell executables](NixOS/nixpkgs#43795).
The main changes are:

* We can now use a newer revision of Nixpkgs

  The current revision we're using corresponds to Nixpkgs 20.03

* We can now more easily update Nixpkgs

  The logic in this repository more closely tracks how `static-haskell-nix`
  works, so whenever that repository updates Nixpkgs we can pick up the change
  here, too.

  Note that we cannot currently use Nixpkgs `master` due to
  [this issue](NixOS/nixpkgs#85924), but once that is
  fixed when we can track Nixpkgs `master` more freely.

* We no longer need to keep track of separate Nixpkgs revisions for
  static vs. non-static builds

  The two builds can also share dependencies, too.  Only the top-level
  derivations differ now.

The reason that this doesn't use `static-haskell-nix` directly is because of
[`cabal2nix` evaluation failures](nh2/static-haskell-nix#73),
so this change works by lifting just the minimum logic that we need from
the `static-haskell-nix` repository until we can finally use that
repository (or Nixpkgs directly when it's upstreamed).
Gabriella439 added a commit to dhall-lang/dhall-haskell that referenced this issue Aug 22, 2020
This is a revamp of our use of
[fully static Haskell executables](NixOS/nixpkgs#43795).
The main changes are:

* We can now use a newer revision of Nixpkgs

  The current revision we're using corresponds to Nixpkgs 20.03

* We can now more easily update Nixpkgs

  The logic in this repository more closely tracks how `static-haskell-nix`
  works, so whenever that repository updates Nixpkgs we can pick up the change
  here, too.

  Note that we cannot currently use Nixpkgs `master` due to
  [this issue](NixOS/nixpkgs#85924), but once that is
  fixed when we can track Nixpkgs `master` more freely.

* We no longer need to keep track of separate Nixpkgs revisions for
  static vs. non-static builds

  The two builds can also share dependencies, too.  Only the top-level
  derivations differ now.

The reason that this doesn't use `static-haskell-nix` directly is because of
[`cabal2nix` evaluation failures](nh2/static-haskell-nix#73),
so this change works by lifting just the minimum logic that we need from
the `static-haskell-nix` repository until we can finally use that
repository (or Nixpkgs directly when it's upstreamed).
@expipiplus1
Copy link
Contributor

Is it feasible to add pkgsMusl.haskell.compiler.ghc* to hydra to prevent this from happening?

@expipiplus1
Copy link
Contributor

FWIW this also happens with the ghc-8.10.2 binary used to bootstrap ghc901:

$ nb -A pkgsMusl.haskell.compiler.ghc901
...
Inconsistency detected by ld.so: dl-lookup.c: 105: check_match: Assertion `version->filename == NULL || ! _dl_name_match_p (version->filename, map)' failed!
make[1]: *** [ghc.mk:973: install_packages] Error 127
make: *** [Makefile:51: install] Error 2
builder for '/nix/store/d6a8i0q7yiv97rsi9yz38p7f8ykhn7c6-ghc-8.10.2-binary.drv' failed with exit code 2
cannot build derivation '/nix/store/z3kk34qqqnncsc132v899yscxanfrpb6-ghc-9.0.0.20200925.drv': 1 dependencies couldn't be built
error: build of '/nix/store/z3kk34qqqnncsc132v899yscxanfrpb6-ghc-9.0.0.20200925.drv' failed

@expipiplus1
Copy link
Contributor

I built things with @bgamari's patch above and it all went very smoothly, is there a reason against including it in nixpkgs, even if just for musl builds?

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

Successfully merging a pull request may close this issue.

7 participants