2017-10-18 20:05:39 +02:00
|
|
|
{ stdenv, lib, fetchgit, bootPkgs, perl, ncurses, libiconv, targetPackages, coreutils
|
2017-01-15 23:31:52 +01:00
|
|
|
, autoconf, automake, happy, alex, python3, buildPlatform, targetPlatform
|
|
|
|
, selfPkgs, cross ? null
|
2017-01-25 00:00:54 +01:00
|
|
|
|
|
|
|
# If enabled GHC will be build with the GPL-free but slower integer-simple
|
|
|
|
# library instead of the faster but GPLed integer-gmp library.
|
|
|
|
, enableIntegerSimple ? false, gmp
|
2017-08-08 19:32:26 +02:00
|
|
|
, version ? "8.3.20170808"
|
2015-12-16 19:18:29 +01:00
|
|
|
}:
|
2015-01-16 19:31:34 +01:00
|
|
|
|
2016-02-21 19:15:04 +01:00
|
|
|
let
|
|
|
|
inherit (bootPkgs) ghc;
|
|
|
|
|
2017-09-06 09:40:01 +02:00
|
|
|
commonBuildInputs = [ ghc perl autoconf automake happy alex python3 ];
|
2016-11-15 22:59:09 +01:00
|
|
|
|
2017-08-08 19:32:26 +02:00
|
|
|
rev = "14457cf6a50f708eecece8f286f08687791d51f7";
|
2016-11-15 22:59:09 +01:00
|
|
|
|
|
|
|
commonPreConfigure = ''
|
2017-01-07 04:10:29 +01:00
|
|
|
echo ${version} >VERSION
|
|
|
|
echo ${rev} >GIT_COMMIT_ID
|
|
|
|
./boot
|
2016-11-15 22:59:09 +01:00
|
|
|
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
|
|
|
'' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
|
|
|
|
export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}"
|
|
|
|
'' + stdenv.lib.optionalString stdenv.isDarwin ''
|
|
|
|
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
2017-01-25 00:00:54 +01:00
|
|
|
'' + stdenv.lib.optionalString enableIntegerSimple ''
|
|
|
|
echo "INTEGER_LIBRARY=integer-simple" > mk/build.mk
|
2016-11-15 22:59:09 +01:00
|
|
|
'';
|
|
|
|
in stdenv.mkDerivation (rec {
|
2017-01-07 04:10:29 +01:00
|
|
|
inherit version rev;
|
2017-05-09 17:59:28 +02:00
|
|
|
name = "ghc-${version}";
|
2011-08-08 21:47:31 +02:00
|
|
|
|
2015-02-12 21:18:06 +01:00
|
|
|
src = fetchgit {
|
|
|
|
url = "git://git.haskell.org/ghc.git";
|
|
|
|
inherit rev;
|
2017-08-08 19:32:26 +02:00
|
|
|
sha256 = "08vj9ca7rq7rv8pjfl14fg2lg9d6zisrwlq6bi5vzr006816dy8y";
|
2010-09-28 15:48:22 +02:00
|
|
|
};
|
|
|
|
|
2016-12-24 18:37:58 +01:00
|
|
|
postPatch = "patchShebangs .";
|
|
|
|
|
2017-01-07 04:10:29 +01:00
|
|
|
preConfigure = commonPreConfigure;
|
2015-02-04 00:34:08 +01:00
|
|
|
|
2016-11-15 22:59:09 +01:00
|
|
|
buildInputs = commonBuildInputs;
|
2010-09-28 15:48:22 +02:00
|
|
|
|
2015-12-16 19:18:29 +01:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2014-12-18 17:31:37 +01:00
|
|
|
configureFlags = [
|
2016-11-16 00:30:26 +01:00
|
|
|
"CC=${stdenv.cc}/bin/cc"
|
2016-02-01 18:16:50 +01:00
|
|
|
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
2017-06-17 21:13:01 +02:00
|
|
|
"--datadir=$doc/share/doc/ghc"
|
2017-01-25 00:00:54 +01:00
|
|
|
] ++ stdenv.lib.optional (! enableIntegerSimple) [
|
|
|
|
"--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib"
|
2015-12-16 19:18:29 +01:00
|
|
|
] ++ stdenv.lib.optional stdenv.isDarwin [
|
|
|
|
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
|
2014-12-18 17:31:37 +01:00
|
|
|
];
|
|
|
|
|
2010-09-28 15:48:22 +02:00
|
|
|
# required, because otherwise all symbols from HSffi.o are stripped, and
|
|
|
|
# that in turn causes GHCi to abort
|
2015-02-04 00:34:08 +01:00
|
|
|
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
|
2010-09-28 15:48:22 +02:00
|
|
|
|
2016-12-24 18:37:04 +01:00
|
|
|
checkTarget = "test";
|
|
|
|
|
2015-12-16 19:18:29 +01:00
|
|
|
postInstall = ''
|
2016-12-15 01:25:58 +01:00
|
|
|
paxmark m $out/lib/${name}/bin/{ghc,haddock}
|
|
|
|
|
2015-12-16 19:18:29 +01:00
|
|
|
# Install the bash completion file.
|
|
|
|
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/ghc
|
|
|
|
|
|
|
|
# Patch scripts to include "readelf" and "cat" in $PATH.
|
|
|
|
for i in "$out/bin/"*; do
|
|
|
|
test ! -h $i || continue
|
|
|
|
egrep --quiet '^#!' <(head -n 1 $i) || continue
|
2017-10-18 20:05:39 +02:00
|
|
|
sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
|
2015-12-16 19:18:29 +01:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2017-06-22 20:52:35 +02:00
|
|
|
outputs = [ "out" "doc" ];
|
|
|
|
|
2016-02-21 19:15:04 +01:00
|
|
|
passthru = {
|
|
|
|
inherit bootPkgs;
|
2017-01-15 23:31:52 +01:00
|
|
|
} // stdenv.lib.optionalAttrs (targetPlatform != buildPlatform) {
|
2016-11-18 16:44:53 +01:00
|
|
|
crossCompiler = selfPkgs.ghc.override {
|
2017-01-15 23:31:52 +01:00
|
|
|
cross = targetPlatform;
|
2016-11-18 16:44:53 +01:00
|
|
|
bootPkgs = selfPkgs;
|
|
|
|
};
|
2016-02-21 19:15:04 +01:00
|
|
|
};
|
|
|
|
|
2010-09-28 15:48:22 +02:00
|
|
|
meta = {
|
2017-08-01 22:03:30 +02:00
|
|
|
homepage = http://haskell.org/ghc;
|
2010-09-28 15:48:22 +02:00
|
|
|
description = "The Glasgow Haskell Compiler";
|
2016-05-16 22:30:20 +02:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
|
2013-03-23 13:05:43 +01:00
|
|
|
inherit (ghc.meta) license platforms;
|
2010-09-28 15:48:22 +02:00
|
|
|
};
|
|
|
|
|
2016-11-15 22:59:09 +01:00
|
|
|
} // stdenv.lib.optionalAttrs (cross != null) {
|
|
|
|
name = "${cross.config}-ghc-${version}";
|
|
|
|
|
|
|
|
preConfigure = commonPreConfigure + ''
|
2017-01-24 00:37:15 +01:00
|
|
|
sed 's|#BuildFlavour = quick-cross|BuildFlavour = perf-cross|' mk/build.mk.sample > mk/build.mk
|
2016-11-15 22:59:09 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
configureFlags = [
|
2017-05-31 02:17:10 +02:00
|
|
|
"CC=${stdenv.cc}/bin/${cross.config}-cc"
|
|
|
|
"LD=${stdenv.cc}/bin/${cross.config}-ld"
|
|
|
|
"AR=${stdenv.cc}/bin/${cross.config}-ar"
|
|
|
|
"NM=${stdenv.cc}/bin/${cross.config}-nm"
|
|
|
|
"RANLIB=${stdenv.cc}/bin/${cross.config}-ranlib"
|
2016-11-15 22:59:09 +01:00
|
|
|
"--target=${cross.config}"
|
2016-11-18 16:44:53 +01:00
|
|
|
"--enable-bootstrap-with-devel-snapshot"
|
2017-02-25 23:45:40 +01:00
|
|
|
] ++
|
|
|
|
# fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
|
|
|
lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space";
|
2016-11-15 22:59:09 +01:00
|
|
|
|
2017-05-31 02:17:10 +02:00
|
|
|
buildInputs = commonBuildInputs;
|
2016-11-15 22:59:09 +01:00
|
|
|
|
2017-04-26 06:06:11 +02:00
|
|
|
configurePlatforms = [];
|
2016-11-18 16:44:53 +01:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit bootPkgs cross;
|
|
|
|
|
2017-05-31 02:17:10 +02:00
|
|
|
cc = "${stdenv.cc}/bin/${cross.config}-cc";
|
2016-11-18 16:44:53 +01:00
|
|
|
|
2017-05-31 02:17:10 +02:00
|
|
|
ld = "${stdenv.cc}/bin/${cross.config}-ld";
|
2016-11-18 16:44:53 +01:00
|
|
|
};
|
2016-11-15 22:59:09 +01:00
|
|
|
})
|