about summary refs log tree commit diff
path: root/pkgs/development/haskell-modules
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2015-03-09 22:11:23 +0300
committerPeter Simons <simons@cryp.to>2015-03-26 11:29:05 +0100
commit49f3c375b50eea5f7e3bc59c7ee687fb507edf2e (patch)
tree21518bc85057167243eef683684e4dbc546998f9 /pkgs/development/haskell-modules
parent1368206eb8463dffee6a3c43fdf7ee12ca0aa468 (diff)
downloadnixlib-49f3c375b50eea5f7e3bc59c7ee687fb507edf2e.tar
nixlib-49f3c375b50eea5f7e3bc59c7ee687fb507edf2e.tar.gz
nixlib-49f3c375b50eea5f7e3bc59c7ee687fb507edf2e.tar.bz2
nixlib-49f3c375b50eea5f7e3bc59c7ee687fb507edf2e.tar.lz
nixlib-49f3c375b50eea5f7e3bc59c7ee687fb507edf2e.tar.xz
nixlib-49f3c375b50eea5f7e3bc59c7ee687fb507edf2e.tar.zst
nixlib-49f3c375b50eea5f7e3bc59c7ee687fb507edf2e.zip
ghcWithPackages: add withLLVM
Diffstat (limited to 'pkgs/development/haskell-modules')
-rw-r--r--pkgs/development/haskell-modules/configuration-common.nix8
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-6.12.x.nix3
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-7.0.x.nix3
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-7.10.x.nix3
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-7.2.x.nix3
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-7.4.x.nix3
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-7.6.x.nix3
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-7.8.x.nix3
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-head.nix3
-rw-r--r--pkgs/development/haskell-modules/configuration-ghcjs.nix3
-rw-r--r--pkgs/development/haskell-modules/default.nix5
-rw-r--r--pkgs/development/haskell-modules/with-packages-wrapper.nix26
12 files changed, 52 insertions, 14 deletions
diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix
index 76910ed61f98..d959e91cf2a8 100644
--- a/pkgs/development/haskell-modules/configuration-common.nix
+++ b/pkgs/development/haskell-modules/configuration-common.nix
@@ -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
diff --git a/pkgs/development/haskell-modules/configuration-ghc-6.12.x.nix b/pkgs/development/haskell-modules/configuration-ghc-6.12.x.nix
index cccf5833c8a5..2a5213d4e121 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-6.12.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-6.12.x.nix
@@ -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;
diff --git a/pkgs/development/haskell-modules/configuration-ghc-7.0.x.nix b/pkgs/development/haskell-modules/configuration-ghc-7.0.x.nix
index 4343970bb007..27c4b642c4b7 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-7.0.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-7.0.x.nix
@@ -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;
diff --git a/pkgs/development/haskell-modules/configuration-ghc-7.10.x.nix b/pkgs/development/haskell-modules/configuration-ghc-7.10.x.nix
index a70597e6ee52..f04ad96fc5f7 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-7.10.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-7.10.x.nix
@@ -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;
diff --git a/pkgs/development/haskell-modules/configuration-ghc-7.2.x.nix b/pkgs/development/haskell-modules/configuration-ghc-7.2.x.nix
index 9c03b7e469dd..8428af7ca6e8 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-7.2.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-7.2.x.nix
@@ -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;
diff --git a/pkgs/development/haskell-modules/configuration-ghc-7.4.x.nix b/pkgs/development/haskell-modules/configuration-ghc-7.4.x.nix
index 383a03183906..fd4109fad72e 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-7.4.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-7.4.x.nix
@@ -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;
diff --git a/pkgs/development/haskell-modules/configuration-ghc-7.6.x.nix b/pkgs/development/haskell-modules/configuration-ghc-7.6.x.nix
index b7cf7c77e10c..fceb444b3e2c 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-7.6.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-7.6.x.nix
@@ -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;
diff --git a/pkgs/development/haskell-modules/configuration-ghc-7.8.x.nix b/pkgs/development/haskell-modules/configuration-ghc-7.8.x.nix
index 9d4bf40eca69..e53ea6fc4c88 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-7.8.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-7.8.x.nix
@@ -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;
diff --git a/pkgs/development/haskell-modules/configuration-ghc-head.nix b/pkgs/development/haskell-modules/configuration-ghc-head.nix
index 4c4065e8889a..47b450afc4ea 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-head.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-head.nix
@@ -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;
diff --git a/pkgs/development/haskell-modules/configuration-ghcjs.nix b/pkgs/development/haskell-modules/configuration-ghcjs.nix
index 000a0647bef1..9ae45e9425b4 100644
--- a/pkgs/development/haskell-modules/configuration-ghcjs.nix
+++ b/pkgs/development/haskell-modules/configuration-ghcjs.nix
@@ -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;/'"
diff --git a/pkgs/development/haskell-modules/default.nix b/pkgs/development/haskell-modules/default.nix
index 973ff83c42df..673855227b88 100644
--- a/pkgs/development/haskell-modules/default.nix
+++ b/pkgs/development/haskell-modules/default.nix
@@ -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; };
 
diff --git a/pkgs/development/haskell-modules/with-packages-wrapper.nix b/pkgs/development/haskell-modules/with-packages-wrapper.nix
index 763164cec876..b2071fa61c0f 100644
--- a/pkgs/development/haskell-modules/with-packages-wrapper.nix
+++ b/pkgs/development/haskell-modules/with-packages-wrapper.nix
@@ -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
   '';
 } // {