From a51af7d417558ec0c8501412635e8b9b71b59820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Sun, 19 Sep 2021 12:16:59 +0000 Subject: [PATCH] pkgsMusl.haskell.compiler.ghc8107Binary: Remove now-incorrect gmp dependency. GHC HQ switched the musl bindists from gmp to `integer-simple` with GHC >= 8.10.6, but this was not reflected in the nixpkgs update: * commit 6f1242469a: ghc: 8.10.5-binary -> 8.10.7-binary From PR #135453 See also #130441. --- .../compilers/ghc/8.10.2-binary.nix | 26 ++++++++++-- .../compilers/ghc/8.10.7-binary.nix | 41 +++++++++++-------- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.2-binary.nix b/pkgs/development/compilers/ghc/8.10.2-binary.nix index c21096b5920efb5..b571149e5967a74 100644 --- a/pkgs/development/compilers/ghc/8.10.2-binary.nix +++ b/pkgs/development/compilers/ghc/8.10.2-binary.nix @@ -46,6 +46,7 @@ let }; exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; archSpecificLibraries = [ + { nixPackage = gmp; fileToCheckFor = null; } # The i686-linux bindist provided by GHC HQ is currently built on Debian 9, # which link it against `libtinfo.so.5` (ncurses 5). # Other bindists are linked `libtinfo.so.6` (ncurses 6). @@ -59,6 +60,7 @@ let }; exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; archSpecificLibraries = [ + { nixPackage = gmp; fileToCheckFor = null; } { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; } ]; }; @@ -69,6 +71,7 @@ let }; exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; archSpecificLibraries = [ + { nixPackage = gmp; fileToCheckFor = null; } { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; } ]; }; @@ -79,6 +82,7 @@ let }; exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; archSpecificLibraries = [ + { nixPackage = gmp; fileToCheckFor = null; } { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; } { nixPackage = numactl; fileToCheckFor = null; } ]; @@ -90,6 +94,7 @@ let }; exePathForLibraryCheck = null; # we don't have a library check for darwin yet archSpecificLibraries = [ + { nixPackage = gmp; fileToCheckFor = null; } { nixPackage = ncurses6; fileToCheckFor = null; } { nixPackage = libiconv; fileToCheckFor = null; } ]; @@ -104,6 +109,7 @@ let }; exePathForLibraryCheck = "bin/ghc"; archSpecificLibraries = [ + { nixPackage = gmp; fileToCheckFor = null; } # In contrast to glibc builds, the musl-bindist uses `libncursesw.so.*` # instead of `libtinfo.so.*.` { nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; } @@ -121,11 +127,8 @@ let libPath = lib.makeLibraryPath ( - [ - gmp - ] # Add arch-specific libraries. - ++ map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries + map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries ); libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY" @@ -140,6 +143,12 @@ stdenv.mkDerivation rec { src = fetchurl binDistUsed.src; + # Note that for GHC 8.10 versions <= 8.10.5, the GHC HQ musl bindist + # has a `gmp` dependency: + # https://gitlab.haskell.org/ghc/ghc/-/commit/8306501020cd66f683ad9c215fa8e16c2d62357d + # Related nixpkgs issues: + # * https://github.com/NixOS/nixpkgs/pull/130441#issuecomment-922452843 + nativeBuildInputs = [ perl ]; propagatedBuildInputs = lib.optionals useLLVM [ llvmPackages.llvm ] @@ -147,6 +156,9 @@ stdenv.mkDerivation rec { # libgmp is (see not [musl bindists have no .buildinfo]), we need # to propagate `gmp`, otherwise programs built by this ghc will # fail linking with `cannot find -lgmp` errors. + # Concrete cases are listed in: + # https://github.com/NixOS/nixpkgs/pull/130441#issuecomment-922459988 + # # Also, as of writing, the release pages of musl bindists claim # that they use `integer-simple` and do not require `gmp`; however # that is incorrect, so `gmp` is required until a release has been @@ -154,6 +166,12 @@ stdenv.mkDerivation rec { # (Note that for packaging the `-binary` compiler, nixpkgs does not care # about whether or not `gmp` is used; this comment is just here to explain # why the `gmp` dependency exists despite what the release page says.) + # + # For GHC >= 8.10.6, `gmp` was switched out for `integer-simple` + # (https://gitlab.haskell.org/ghc/ghc/-/commit/8306501020cd66f683ad9c215fa8e16c2d62357d), + # fixing the above-mentioned release issue, + # and for GHC >= 9.* it is not clear as of writing whether that switch + # will be made there too. ++ lib.optionals stdenv.hostPlatform.isMusl [ gmp ]; # musl bindist needs this # Set LD_LIBRARY_PATH or equivalent so that the programs running as part diff --git a/pkgs/development/compilers/ghc/8.10.7-binary.nix b/pkgs/development/compilers/ghc/8.10.7-binary.nix index ad106f2f2a54035..34bb25e8983e34e 100644 --- a/pkgs/development/compilers/ghc/8.10.7-binary.nix +++ b/pkgs/development/compilers/ghc/8.10.7-binary.nix @@ -47,6 +47,7 @@ let }; exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; archSpecificLibraries = [ + { nixPackage = gmp; fileToCheckFor = null; } # The i686-linux bindist provided by GHC HQ is currently built on Debian 9, # which link it against `libtinfo.so.5` (ncurses 5). # Other bindists are linked `libtinfo.so.6` (ncurses 6). @@ -60,6 +61,7 @@ let }; exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; archSpecificLibraries = [ + { nixPackage = gmp; fileToCheckFor = null; } { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; } ]; }; @@ -70,6 +72,7 @@ let }; exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; archSpecificLibraries = [ + { nixPackage = gmp; fileToCheckFor = null; } { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; } ]; }; @@ -80,6 +83,7 @@ let }; exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; archSpecificLibraries = [ + { nixPackage = gmp; fileToCheckFor = null; } { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; } { nixPackage = numactl; fileToCheckFor = null; } ]; @@ -91,6 +95,7 @@ let }; exePathForLibraryCheck = null; # we don't have a library check for darwin yet archSpecificLibraries = [ + { nixPackage = gmp; fileToCheckFor = null; } { nixPackage = ncurses6; fileToCheckFor = null; } { nixPackage = libiconv; fileToCheckFor = null; } ]; @@ -102,6 +107,7 @@ let }; exePathForLibraryCheck = null; # we don't have a library check for darwin yet archSpecificLibraries = [ + { nixPackage = gmp; fileToCheckFor = null; } { nixPackage = ncurses6; fileToCheckFor = null; } { nixPackage = libiconv; fileToCheckFor = null; } ]; @@ -116,6 +122,8 @@ let }; exePathForLibraryCheck = "bin/ghc"; archSpecificLibraries = [ + # No `gmp` here, since this is an `integer-simple` bindist. + # In contrast to glibc builds, the musl-bindist uses `libncursesw.so.*` # instead of `libtinfo.so.*.` { nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; } @@ -133,11 +141,8 @@ let libPath = lib.makeLibraryPath ( - [ - gmp - ] # Add arch-specific libraries. - ++ map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries + map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries ); libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY" @@ -152,21 +157,21 @@ stdenv.mkDerivation rec { src = fetchurl binDistUsed.src; + # Note that for GHC 8.10 versions >= 8.10.6, the GHC HQ musl bindist + # uses `integer-simple` and has no `gmp` dependency: + # https://gitlab.haskell.org/ghc/ghc/-/commit/8306501020cd66f683ad9c215fa8e16c2d62357d + # Related nixpkgs issues: + # * https://github.com/NixOS/nixpkgs/pull/130441#issuecomment-922452843 + # TODO: When this file is copied to `ghc-9.*-binary.nix`, determine whether + # the GHC 9 branch also switched from `gmp` to `integer-simple` via the + # currently-open issue: + # https://gitlab.haskell.org/ghc/ghc/-/issues/20059 + # and update this comment accordingly. + nativeBuildInputs = [ perl ]; propagatedBuildInputs = lib.optionals useLLVM [ llvmPackages.llvm ] - # Because musl bindists currently provide no way to tell where - # libgmp is (see not [musl bindists have no .buildinfo]), we need - # to propagate `gmp`, otherwise programs built by this ghc will - # fail linking with `cannot find -lgmp` errors. - # Also, as of writing, the release pages of musl bindists claim - # that they use `integer-simple` and do not require `gmp`; however - # that is incorrect, so `gmp` is required until a release has been - # made that includes https://gitlab.haskell.org/ghc/ghc/-/issues/20059. - # (Note that for packaging the `-binary` compiler, nixpkgs does not care - # about whether or not `gmp` is used; this comment is just here to explain - # why the `gmp` dependency exists despite what the release page says.) - ++ lib.optionals stdenv.hostPlatform.isMusl [ gmp ]; # musl bindist needs this + ; # Set LD_LIBRARY_PATH or equivalent so that the programs running as part # of the bindist installer can find the libraries they expect. @@ -227,9 +232,9 @@ stdenv.mkDerivation rec { patchShebangs ghc-${version}/configure '' + # We have to patch the GMP paths for the integer-gmp package. - # Note [musl bindists have no .buildinfo] - # Note that musl bindists do not contain them; unclear if that's intended; + # Note that musl bindists do not contain them, # see: https://gitlab.haskell.org/ghc/ghc/-/issues/20073#note_363231 + # However, musl bindists >= 8.10.6 use `integer-simple`, not `gmp`. '' find . -name integer-gmp.buildinfo \ -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;