ghcWithPackages: add withLLVM

This commit is contained in:
Nikolay Amiantov 2015-03-09 22:11:23 +03:00 committed by Peter Simons
parent 1368206eb8
commit 49f3c375b5
12 changed files with 52 additions and 14 deletions

View file

@ -4,6 +4,9 @@ with import ./lib.nix { inherit pkgs; };
self: super: {
# Use LLVM for particular GHC version.
inherit (self.llvmPackages) llvm;
# Some packages need a non-core version of Cabal.
Cabal_1_18_1_6 = dontCheck super.Cabal_1_18_1_6;
Cabal_1_20_0_3 = dontCheck super.Cabal_1_20_0_3;
@ -485,11 +488,6 @@ self: super: {
# https://github.com/ucsd-progsys/liquid-fixpoint/issues/44
liquid-fixpoint = overrideCabal super.liquid-fixpoint (drv: { preConfigure = "patchShebangs ."; });
# LLVM 3.5 breaks GHC: https://ghc.haskell.org/trac/ghc/ticket/9142.
GlomeVec = super.GlomeVec.override { llvm = pkgs.llvm_34; }; # https://github.com/jimsnow/glome/issues/2
gloss-raster = super.gloss-raster.override { llvm = pkgs.llvm_34; };
repa-examples = super.repa-examples.override { llvm = pkgs.llvm_34; };
# Missing module.
rematch = dontCheck super.rematch; # https://github.com/tcrayford/rematch/issues/5
rematch-text = dontCheck super.rematch-text; # https://github.com/tcrayford/rematch/issues/6

View file

@ -4,6 +4,9 @@ with import ./lib.nix { inherit pkgs; };
self: super: {
# LLVM is not supported on this GHC; use the latest one.
inherit (pkgs) llvmPackages;
# Disable GHC 6.12.x core libraries.
array = null;
base = null;

View file

@ -4,6 +4,9 @@ with import ./lib.nix { inherit pkgs; };
self: super: {
# Suitable LLVM version.
llvmPackages = pkgs.llvmPackages_34;
# Disable GHC 7.0.x core libraries.
array = null;
base = null;

View file

@ -4,6 +4,9 @@ with import ./lib.nix { inherit pkgs; };
self: super: {
# Suitable LLVM version.
llvmPackages = pkgs.llvmPackages_35;
# Disable GHC 7.10.x core libraries.
array = null;
base = null;

View file

@ -4,6 +4,9 @@ with import ./lib.nix { inherit pkgs; };
self: super: {
# Suitable LLVM version.
llvmPackages = pkgs.llvmPackages_34;
# Disable GHC 7.2.x core libraries.
array = null;
base = null;

View file

@ -4,6 +4,9 @@ with import ./lib.nix { inherit pkgs; };
self: super: {
# Suitable LLVM version.
llvmPackages = pkgs.llvmPackages_34;
# Disable GHC 7.4.x core libraries.
array = null;
base = null;

View file

@ -4,6 +4,9 @@ with import ./lib.nix { inherit pkgs; };
self: super: {
# Suitable LLVM version.
llvmPackages = pkgs.llvmPackages_34;
# Disable GHC 7.6.x core libraries.
array = null;
base = null;

View file

@ -4,6 +4,9 @@ with import ./lib.nix { inherit pkgs; };
self: super: {
# Suitable LLVM version.
llvmPackages = pkgs.llvmPackages_34;
# Disable GHC 7.8.x core libraries.
array = null;
base = null;

View file

@ -4,6 +4,9 @@ with import ./lib.nix { inherit pkgs; };
self: super: {
# Use the latest LLVM.
inherit (pkgs) llvmPackages;
# Disable GHC 7.11.x core libraries.
array = null;
base = null;

View file

@ -4,6 +4,9 @@ with import ./lib.nix { inherit pkgs; };
self: super: {
# LLVM is not supported on this GHC; use the latest one.
inherit (pkgs) llvmPackages;
# This is the list of packages that are built into a booted ghcjs installation
# It can be generated with the command:
# nix-shell '<nixpkgs>' -A pkgs.haskellPackages_ghcjs.ghc --command "ghcjs-pkg list | sed -n 's/^ \(.*\)-\([0-9.]*\)$/\1_\2/ p' | sed 's/\./_/g' | sed 's/-\(.\)/\U\1/' | sed 's/^\([^_]*\)\(.*\)$/\1 = null;/'"

View file

@ -54,7 +54,10 @@ let
inherit mkDerivation callPackage;
ghcWithPackages = pkgs: callPackage ./with-packages-wrapper.nix { packages = pkgs self; };
ghcWithPackages = pkgs: callPackage ./with-packages-wrapper.nix {
inherit (self) llvmPackages;
packages = pkgs self;
};
ghc = ghc // { withPackages = self.ghcWithPackages; };

View file

@ -1,7 +1,11 @@
{ stdenv, ghc, packages, buildEnv, makeWrapper, ignoreCollisions ? false }:
{ stdenv, ghc, llvmPackages, packages, buildEnv
, makeWrapper
, ignoreCollisions ? false, withLLVM ? false }:
with stdenv.lib;
# This wrapper works only with GHC 6.12 or later.
assert stdenv.lib.versionOlder "6.12" ghc.version;
assert versionOlder "6.12" ghc.version;
# It's probably a good idea to include the library "ghc-paths" in the
# compiler environment, because we have a specially patched version of
@ -25,15 +29,20 @@ assert stdenv.lib.versionOlder "6.12" ghc.version;
# fi
let
ghc761OrLater = stdenv.lib.versionOlder "7.6.1" ghc.version;
ghc761OrLater = versionOlder "7.6.1" ghc.version;
packageDBFlag = if ghc761OrLater then "--global-package-db" else "--global-conf";
libDir = "$out/lib/ghc-${ghc.version}";
docDir = "$out/share/doc/ghc/html";
packageCfgDir = "${libDir}/package.conf.d";
paths = stdenv.lib.filter (x: x ? isHaskellLibrary) (stdenv.lib.closePropagation packages);
hasLibraries = stdenv.lib.any (x: x.isHaskellLibrary) paths;
paths = filter (x: x ? isHaskellLibrary) (closePropagation packages);
hasLibraries = any (x: x.isHaskellLibrary) paths;
# CLang is needed on Darwin for -fllvm to work:
# https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/code-generators.html
llvm = makeSearchPath "bin"
([ llvmPackages.llvm ]
++ optional stdenv.isDarwin llvmPackages.clang);
in
if paths == [] then ghc else
if paths == [] && !withLLVM then ghc else
buildEnv {
inherit (ghc) name;
paths = paths ++ [ghc];
@ -55,7 +64,8 @@ buildEnv {
--set "NIX_GHC" "$out/bin/ghc" \
--set "NIX_GHCPKG" "$out/bin/ghc-pkg" \
--set "NIX_GHC_DOCDIR" "${docDir}" \
--set "NIX_GHC_LIBDIR" "${libDir}"
--set "NIX_GHC_LIBDIR" "${libDir}" \
${optionalString withLLVM ''--prefix "PATH" ":" "${llvm}"''}
done
for prg in runghc runhaskell; do
@ -73,7 +83,7 @@ buildEnv {
makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}"
done
${stdenv.lib.optionalString hasLibraries "$out/bin/ghc-pkg recache"}
${optionalString hasLibraries "$out/bin/ghc-pkg recache"}
$out/bin/ghc-pkg check
'';
} // {