Skip to content

Commit

Permalink
ghc:8.10.2 self-bootstrap and workaround for aarch64 (NixOS#97407)
Browse files Browse the repository at this point in the history
  • Loading branch information
lostnet committed Oct 14, 2020
1 parent b50ef4e commit 2764755
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 20 deletions.
14 changes: 7 additions & 7 deletions doc/languages-frameworks/haskell.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ nix-env -qaP -A nixos.haskellPackages
nix-env -iA nixos.haskellPackages.cabal-install
```

Our current default compiler is GHC 8.8.x and the `haskellPackages` set
contains packages built with that particular version. Nixpkgs contains the last
three major releases of GHC and there is a whole family of package sets
available that defines Hackage packages built with each of those compilers,
too:
Our current default compiler is GHC 8.8.x (or 8.10.2 on aarch64) and the
`haskellPackages` set contains packages built with that particular version.
Nixpkgs contains the last three major releases of GHC and there is a whole
family of package sets available that defines Hackage packages built with
each of those compilers, too:
```shell
nix-env -f "<nixpkgs>" -qaP -A haskell.packages.ghc865
nix-env -f "<nixpkgs>" -qaP -A haskell.packages.ghc8101
nix-env -f "<nixpkgs>" -qaP -A haskell.packages.ghc8102
```

The name `haskellPackages` is really just a synonym for
`haskell.packages.ghc882`, because we prefer that package set internally and
`haskell.packages.ghc884`, because we prefer that package set internally and
recommend it to our users as their default choice, but ultimately you are free
to compile your Haskell packages with any GHC version you please. The following
command displays the complete list of available compilers:
Expand Down
48 changes: 37 additions & 11 deletions pkgs/development/compilers/ghc/8.10.2-binary.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ stdenv.mkDerivation rec {
patchShebangs ghc-${version}/utils/
patchShebangs ghc-${version}/configure
'' +

# We have to patch the GMP paths for the integer-gmp package.
''
find . -name integer-gmp.buildinfo \
-exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
'' + stdenv.lib.optionalString stdenv.isDarwin ''
find . -name base.buildinfo \
-exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
'' + stdenv.lib.optionalString stdenv.hostPlatform.isAarch64 ''
find . -name package.conf.in \
-exec sed -i "s@FFI_LIB_DIR@FFI_LIB_DIR ${numactl.out}/lib@g" {} \;
'' +
# Rename needed libraries and binaries, fix interpreter
stdenv.lib.optionalString stdenv.isLinux ''
Expand Down Expand Up @@ -128,14 +130,33 @@ stdenv.mkDerivation rec {

# On Linux, use patchelf to modify the executables so that they can
# find editline/gmp.
postFixup = stdenv.lib.optionalString stdenv.isLinux ''
for p in $(find "$out" -type f -executable); do
if isELF "$p"; then
echo "Patchelfing $p"
patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
fi
done
'' + stdenv.lib.optionalString stdenv.isDarwin ''
postFixup = stdenv.lib.optionalString stdenv.isLinux
(if stdenv.hostPlatform.isAarch64 then
# Keep rpath as small as possible on aarch64 for patchelf#244
''
(cd $out/lib; ln -s ${ncurses6.out}/lib/libtinfo.so.6)
(cd $out/lib; ln -s ${gmp.out}/lib/libgmp.so.10)
(cd $out/lib; ln -s ${numactl.out}/lib/libnuma.so.1)
for p in $(find "$out/lib" -type f -name "*\.so*"); do
(cd $out/lib; ln -s $p)
done
for p in $(find "$out/lib" -type f -executable); do
if isELF "$p"; then
echo "Patchelfing $p"
patchelf --set-rpath "\$ORIGIN:\$ORIGIN/../.." $p
fi
done
''
else
''
for p in $(find "$out" -type f -executable); do
if isELF "$p"; then
echo "Patchelfing $p"
patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
fi
done
'') + stdenv.lib.optionalString stdenv.isDarwin ''
# not enough room in the object files for the full path to libiconv :(
for exe in $(find "$out" -type f -executable); do
isScript $exe && continue
Expand Down Expand Up @@ -169,6 +190,11 @@ stdenv.mkDerivation rec {
enableShared = true;
};

meta.license = stdenv.lib.licenses.bsd3;
meta.platforms = ["x86_64-linux" "armv7l-linux" "aarch64-linux" "i686-linux" "x86_64-darwin"];
meta = {
homepage = "http://haskell.org/ghc";
description = "The Glasgow Haskell Compiler";
license = stdenv.lib.licenses.bsd3;
platforms = ["x86_64-linux" "armv7l-linux" "aarch64-linux" "i686-linux" "x86_64-darwin"];
maintainers = with stdenv.lib.maintainers; [ lostnet ];
};
}
5 changes: 4 additions & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9008,7 +9008,10 @@ in

# Please update doc/languages-frameworks/haskell.section.md, “Our
# current default compiler is”, if you bump this:
haskellPackages = dontRecurseIntoAttrs haskell.packages.ghc884;
haskellPackages = if stdenv.isAarch64 then
dontRecurseIntoAttrs haskell.packages.ghc8102
else
dontRecurseIntoAttrs haskell.packages.ghc884;

inherit (haskellPackages) ghc;

Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/haskell-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ in {
llvmPackages = pkgs.llvmPackages_9;
};
ghc8102 = callPackage ../development/compilers/ghc/8.10.2.nix {
bootPkgs = packages.ghc865Binary;
bootPkgs = packages.ghc8102Binary;
inherit (buildPackages.python3Packages) sphinx;
buildLlvmPackages = buildPackages.llvmPackages_9;
llvmPackages = pkgs.llvmPackages_9;
Expand Down

0 comments on commit 2764755

Please sign in to comment.