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.ghc8107Binary: Remove now-incorrect gmp dependency #138523

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions pkgs/development/compilers/ghc/8.10.2-binary.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -59,6 +60,7 @@ let
};
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
archSpecificLibraries = [
{ nixPackage = gmp; fileToCheckFor = null; }
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
];
};
Expand All @@ -69,6 +71,7 @@ let
};
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
archSpecificLibraries = [
{ nixPackage = gmp; fileToCheckFor = null; }
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
];
};
Expand All @@ -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; }
];
Expand All @@ -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; }
];
Expand All @@ -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"; }
Expand All @@ -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"
Expand All @@ -140,20 +143,35 @@ stdenv.mkDerivation rec {

src = fetchurl binDistUsed.src;

# Note that for GHC 8.10 versions <= 8.10.5, the GHC HQ musl bindist
Copy link
Member

Choose a reason for hiding this comment

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

I think this sentence is missing a word.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

# 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 ]
# 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.
# 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
# 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.)
#
# 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
Expand Down
41 changes: 23 additions & 18 deletions pkgs/development/compilers/ghc/8.10.7-binary.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -60,6 +61,7 @@ let
};
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
archSpecificLibraries = [
{ nixPackage = gmp; fileToCheckFor = null; }
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
];
};
Expand All @@ -70,6 +72,7 @@ let
};
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
archSpecificLibraries = [
{ nixPackage = gmp; fileToCheckFor = null; }
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
];
};
Expand All @@ -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; }
];
Expand All @@ -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; }
];
Expand All @@ -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; }
];
Expand All @@ -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"; }
Expand All @@ -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"
Expand All @@ -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
Copy link
Member

Choose a reason for hiding this comment

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

Can the comment on musl bindists have no .buildinfo further down removed here as well (or clarified wrt musl)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I have fixed the dangling reference.

# 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.
Expand Down Expand Up @@ -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@" {} \;
Expand Down