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

ghc: Add variantSuffix, fix musl+integer-simple #138524

Closed
Closed
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
34 changes: 29 additions & 5 deletions pkgs/development/compilers/ghc/8.10.2-binary.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,56 +40,66 @@ let
# nixpkgs uses for the respective system.
defaultLibc = {
i686-linux = {
variantSuffix = "";
src = {
url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
sha256 = "0bvwisl4w0z5z8z0da10m9sv0mhm9na2qm43qxr8zl23mn32mblx";
};
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).
{ nixPackage = ncurses5; fileToCheckFor = "libtinfo.so.5"; }
];
};
x86_64-linux = {
variantSuffix = "";
src = {
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb10-linux.tar.xz";
sha256 = "0chnzy9j23b2wa8clx5arwz8wnjfxyjmz9qkj548z14cqf13slcl";
};
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
archSpecificLibraries = [
{ nixPackage = gmp; fileToCheckFor = null; }
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
];
};
armv7l-linux = {
variantSuffix = "";
src = {
url = "${downloadsUrl}/${version}/ghc-${version}-armv7-deb10-linux.tar.xz";
sha256 = "1j41cq5d3rmlgz7hzw8f908fs79gc5mn3q5wz277lk8zdf19g75v";
};
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
archSpecificLibraries = [
{ nixPackage = gmp; fileToCheckFor = null; }
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
];
};
aarch64-linux = {
variantSuffix = "";
src = {
url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz";
sha256 = "14smwl3741ixnbgi0l51a7kh7xjkiannfqx15b72svky0y4l3wjw";
};
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
archSpecificLibraries = [
{ nixPackage = gmp; fileToCheckFor = null; }
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
{ nixPackage = numactl; fileToCheckFor = null; }
];
};
x86_64-darwin = {
variantSuffix = "";
src = {
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
sha256 = "1hngyq14l4f950hzhh2d204ca2gfc98pc9xdasxihzqd1jq75dzd";
};
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 @@ -98,12 +108,14 @@ let
# Binary distributions for the musl libc for the respective system.
musl = {
x86_64-linux = {
variantSuffix = "-musl";
src = {
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-alpine3.10-linux-integer-simple.tar.xz";
sha256 = "0xpcbyaxqyhbl6f0i3s4rp2jm67nqpkfh2qlbj3i2fiaix89ml0l";
};
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 +133,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 @@ -136,24 +145,39 @@ in
stdenv.mkDerivation rec {
inherit version;

name = "ghc-${version}-binary";
name = "ghc-${version}-binary${binDistUsed.variantSuffix}";
Copy link
Member

Choose a reason for hiding this comment

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

Appending something to a derivation name is usually a bad idea since builtins.parseDrvName interprets everything after the first number after a dash as the version.

We are already doing this for the binary ones, but we shouldn't expand this. So let's take this opportunity to redo the naming of the binary derivations as well and move the -binary suffix before the version number (maybe in a separate commit?):

Suggested change
name = "ghc-${version}-binary${binDistUsed.variantSuffix}";
name = "ghc-binary${binDistUsed.variantSuffix}-${version}";

Of course would need to be reflected in the other derivations as well. If you don't feel like doing it, I can also take care of that for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point.

I think we should do it the way you suggest.

Copy link
Member

Choose a reason for hiding this comment

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

This was done in #139164 which I've already merged into haskell-updates (with the variant suffix changes as well).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was done in PR #139164.


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 ]
# 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
50 changes: 31 additions & 19 deletions pkgs/development/compilers/ghc/8.10.7-binary.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,67 +41,79 @@ let
# nixpkgs uses for the respective system.
defaultLibc = {
i686-linux = {
variantSuffix = "";
src = {
url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
sha256 = "fbfc1ef194f4e7a4c0da8c11cc69b17458a4b928b609b3622c97acc4acd5c5ab";
};
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).
{ nixPackage = ncurses5; fileToCheckFor = "libtinfo.so.5"; }
];
};
x86_64-linux = {
variantSuffix = "";
src = {
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb10-linux.tar.xz";
sha256 = "a13719bca87a0d3ac0c7d4157a4e60887009a7f1a8dbe95c4759ec413e086d30";
};
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
archSpecificLibraries = [
{ nixPackage = gmp; fileToCheckFor = null; }
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
];
};
armv7l-linux = {
variantSuffix = "";
src = {
url = "${downloadsUrl}/${version}/ghc-${version}-armv7-deb10-linux.tar.xz";
sha256 = "3949c31bdf7d3b4afb765ea8246bca4ca9707c5d988d9961a244f0da100956a2";
};
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
archSpecificLibraries = [
{ nixPackage = gmp; fileToCheckFor = null; }
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
];
};
aarch64-linux = {
variantSuffix = "";
src = {
url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz";
sha256 = "fad2417f9b295233bf8ade79c0e6140896359e87be46cb61cd1d35863d9d0e55";
};
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
archSpecificLibraries = [
{ nixPackage = gmp; fileToCheckFor = null; }
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
{ nixPackage = numactl; fileToCheckFor = null; }
];
};
x86_64-darwin = {
variantSuffix = "";
src = {
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
sha256 = "287db0f9c338c9f53123bfa8731b0996803ee50f6ee847fe388092e5e5132047";
};
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; }
];
};
aarch64-darwin = {
variantSuffix = "";
src = {
url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz";
sha256 = "dc469fc3c35fd2a33a5a575ffce87f13de7b98c2d349a41002e200a56d9bba1c";
};
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 @@ -110,12 +122,15 @@ let
# Binary distributions for the musl libc for the respective system.
musl = {
x86_64-linux = {
variantSuffix = "-musl-integer-simple";
src = {
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-alpine3.10-linux-integer-simple.tar.xz";
sha256 = "16903df850ef73d5246f2ff169cbf57ecab76c2ac5acfa9928934282cfad575c";
};
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 +148,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 @@ -148,25 +160,25 @@ in
stdenv.mkDerivation rec {
inherit version;

name = "ghc-${version}-binary";
name = "ghc-${version}-binary${binDistUsed.variantSuffix}";

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.
Expand Down Expand Up @@ -227,9 +239,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
12 changes: 7 additions & 5 deletions pkgs/development/compilers/ghc/8.10.7.nix
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,16 @@ let
targetPackages.stdenv.cc.bintools.bintools
];

# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
variantSuffix = lib.concatStrings [
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
(lib.optionalString enableIntegerSimple "-integer-simple")
];

in
stdenv.mkDerivation (rec {
version = "8.10.7";
name = "${targetPrefix}ghc-${version}";
name = "${targetPrefix}ghc-${version}${variantSuffix}";

src = fetchurl {
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
Expand Down Expand Up @@ -341,10 +347,6 @@ stdenv.mkDerivation (rec {
] ++ lib.teams.haskell.members;
timeout = 24 * 3600;
inherit (ghc.meta) license platforms;

# integer-simple builds are broken when GHC links against musl.
# See https://github.com/NixOS/nixpkgs/pull/129606#issuecomment-881323743.
broken = enableIntegerSimple && hostPlatform.isMusl;
};

} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
Expand Down
12 changes: 7 additions & 5 deletions pkgs/development/compilers/ghc/8.8.4.nix
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,16 @@ let
targetPackages.stdenv.cc.bintools.bintools
];

# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
variantSuffix = lib.concatStrings [
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
(lib.optionalString enableIntegerSimple "-integer-simple")
];

in
stdenv.mkDerivation (rec {
version = "8.8.4";
name = "${targetPrefix}ghc-${version}";
name = "${targetPrefix}ghc-${version}${variantSuffix}";

src = fetchurl {
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
Expand Down Expand Up @@ -340,10 +346,6 @@ stdenv.mkDerivation (rec {
] ++ lib.teams.haskell.members;
timeout = 24 * 3600;
inherit (ghc.meta) license platforms;

# integer-simple builds are broken when GHC links against musl.
# See https://github.com/NixOS/nixpkgs/pull/129606#issuecomment-881323743.
broken = enableIntegerSimple && hostPlatform.isMusl;
};

dontStrip = (targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm);
Expand Down
12 changes: 7 additions & 5 deletions pkgs/development/compilers/ghc/9.0.1.nix
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,16 @@ let
targetPackages.stdenv.cc.bintools.bintools
];

# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
variantSuffix = lib.concatStrings [
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
(lib.optionalString enableIntegerSimple "-integer-simple")
];

in
stdenv.mkDerivation (rec {
version = "9.0.1";
name = "${targetPrefix}ghc-${version}";
name = "${targetPrefix}ghc-${version}${variantSuffix}";

src = fetchurl {
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
Expand Down Expand Up @@ -303,10 +309,6 @@ stdenv.mkDerivation (rec {
] ++ lib.teams.haskell.members;
timeout = 24 * 3600;
inherit (ghc.meta) license platforms;

# integer-simple builds are broken when GHC links against musl.
# See https://github.com/NixOS/nixpkgs/pull/129606#issuecomment-881323743.
broken = enableIntegerSimple && hostPlatform.isMusl;
};

} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
Expand Down
Loading