2017-02-25 22:44:04 +00:00
|
|
|
{ stdenv, lib, fetchgit, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
|
2017-01-15 22:31:52 +00:00
|
|
|
, autoconf, automake, happy, alex, python3, buildPlatform, targetPlatform
|
|
|
|
, selfPkgs, cross ? null
|
2017-01-24 23:00:54 +00: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 18:32:26 +01:00
|
|
|
, version ? "8.3.20170808"
|
2015-12-16 18:18:29 +00:00
|
|
|
}:
|
2015-01-16 18:31:34 +00:00
|
|
|
|
2016-02-21 18:15:04 +00:00
|
|
|
let
|
|
|
|
inherit (bootPkgs) ghc;
|
|
|
|
|
2016-12-24 17:37:04 +00:00
|
|
|
commonBuildInputs = [ ghc perl autoconf automake happy alex python3 ];
|
2016-11-15 21:59:09 +00:00
|
|
|
|
2017-08-08 18:32:26 +01:00
|
|
|
rev = "14457cf6a50f708eecece8f286f08687791d51f7";
|
2016-11-15 21:59:09 +00:00
|
|
|
|
|
|
|
commonPreConfigure = ''
|
2017-01-07 03:10:29 +00:00
|
|
|
echo ${version} >VERSION
|
|
|
|
echo ${rev} >GIT_COMMIT_ID
|
|
|
|
./boot
|
2016-11-15 21:59:09 +00: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-24 23:00:54 +00:00
|
|
|
'' + stdenv.lib.optionalString enableIntegerSimple ''
|
|
|
|
echo "INTEGER_LIBRARY=integer-simple" > mk/build.mk
|
2016-11-15 21:59:09 +00:00
|
|
|
'';
|
|
|
|
in stdenv.mkDerivation (rec {
|
2017-01-07 03:10:29 +00:00
|
|
|
inherit version rev;
|
2017-05-09 16:59:28 +01:00
|
|
|
name = "ghc-${version}";
|
2011-08-08 20:47:31 +01:00
|
|
|
|
2015-02-12 20:18:06 +00:00
|
|
|
src = fetchgit {
|
|
|
|
url = "git://git.haskell.org/ghc.git";
|
|
|
|
inherit rev;
|
2017-08-08 18:32:26 +01:00
|
|
|
sha256 = "08vj9ca7rq7rv8pjfl14fg2lg9d6zisrwlq6bi5vzr006816dy8y";
|
2010-09-28 14:48:22 +01:00
|
|
|
};
|
|
|
|
|
2016-12-24 17:37:58 +00:00
|
|
|
postPatch = "patchShebangs .";
|
|
|
|
|
2017-01-07 03:10:29 +00:00
|
|
|
preConfigure = commonPreConfigure;
|
2015-02-03 23:34:08 +00:00
|
|
|
|
2016-11-15 21:59:09 +00:00
|
|
|
buildInputs = commonBuildInputs;
|
2010-09-28 14:48:22 +01:00
|
|
|
|
2015-12-16 18:18:29 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2014-12-18 16:31:37 +00:00
|
|
|
configureFlags = [
|
2016-11-15 23:30:26 +00:00
|
|
|
"CC=${stdenv.cc}/bin/cc"
|
2016-02-01 17:16:50 +00:00
|
|
|
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
2017-06-17 20:13:01 +01:00
|
|
|
"--datadir=$doc/share/doc/ghc"
|
2017-01-24 23:00:54 +00:00
|
|
|
] ++ stdenv.lib.optional (! enableIntegerSimple) [
|
|
|
|
"--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib"
|
2015-12-16 18:18:29 +00:00
|
|
|
] ++ stdenv.lib.optional stdenv.isDarwin [
|
|
|
|
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
|
2014-12-18 16:31:37 +00:00
|
|
|
];
|
|
|
|
|
2010-09-28 14:48:22 +01:00
|
|
|
# required, because otherwise all symbols from HSffi.o are stripped, and
|
|
|
|
# that in turn causes GHCi to abort
|
2015-02-03 23:34:08 +00:00
|
|
|
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
|
2010-09-28 14:48:22 +01:00
|
|
|
|
2016-12-24 17:37:04 +00:00
|
|
|
checkTarget = "test";
|
|
|
|
|
2015-12-16 18:18:29 +00:00
|
|
|
postInstall = ''
|
2016-12-15 00:25:58 +00:00
|
|
|
paxmark m $out/lib/${name}/bin/{ghc,haddock}
|
|
|
|
|
2015-12-16 18:18:29 +00: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
|
2016-08-22 23:06:51 +01:00
|
|
|
sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ binutils coreutils ]}"' $i
|
2015-12-16 18:18:29 +00:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2017-06-22 19:52:35 +01:00
|
|
|
outputs = [ "out" "doc" ];
|
|
|
|
|
2016-02-21 18:15:04 +00:00
|
|
|
passthru = {
|
|
|
|
inherit bootPkgs;
|
2017-01-15 22:31:52 +00:00
|
|
|
} // stdenv.lib.optionalAttrs (targetPlatform != buildPlatform) {
|
2016-11-18 15:44:53 +00:00
|
|
|
crossCompiler = selfPkgs.ghc.override {
|
2017-01-15 22:31:52 +00:00
|
|
|
cross = targetPlatform;
|
2016-11-18 15:44:53 +00:00
|
|
|
bootPkgs = selfPkgs;
|
|
|
|
};
|
2016-02-21 18:15:04 +00:00
|
|
|
};
|
|
|
|
|
2010-09-28 14:48:22 +01:00
|
|
|
meta = {
|
2017-08-01 21:03:30 +01:00
|
|
|
homepage = http://haskell.org/ghc;
|
2010-09-28 14:48:22 +01:00
|
|
|
description = "The Glasgow Haskell Compiler";
|
2016-05-16 21:30:20 +01:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
|
2013-03-23 12:05:43 +00:00
|
|
|
inherit (ghc.meta) license platforms;
|
2010-09-28 14:48:22 +01:00
|
|
|
};
|
|
|
|
|
2016-11-15 21:59:09 +00:00
|
|
|
} // stdenv.lib.optionalAttrs (cross != null) {
|
|
|
|
name = "${cross.config}-ghc-${version}";
|
|
|
|
|
|
|
|
preConfigure = commonPreConfigure + ''
|
2017-01-23 23:37:15 +00:00
|
|
|
sed 's|#BuildFlavour = quick-cross|BuildFlavour = perf-cross|' mk/build.mk.sample > mk/build.mk
|
2016-11-15 21:59:09 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
configureFlags = [
|
2017-05-31 01:17:10 +01: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 21:59:09 +00:00
|
|
|
"--target=${cross.config}"
|
2016-11-18 15:44:53 +00:00
|
|
|
"--enable-bootstrap-with-devel-snapshot"
|
2017-02-25 22:45:40 +00: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 21:59:09 +00:00
|
|
|
|
2017-05-31 01:17:10 +01:00
|
|
|
buildInputs = commonBuildInputs;
|
2016-11-15 21:59:09 +00:00
|
|
|
|
2017-04-26 05:06:11 +01:00
|
|
|
configurePlatforms = [];
|
2016-11-18 15:44:53 +00:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit bootPkgs cross;
|
|
|
|
|
2017-05-31 01:17:10 +01:00
|
|
|
cc = "${stdenv.cc}/bin/${cross.config}-cc";
|
2016-11-18 15:44:53 +00:00
|
|
|
|
2017-05-31 01:17:10 +01:00
|
|
|
ld = "${stdenv.cc}/bin/${cross.config}-ld";
|
2016-11-18 15:44:53 +00:00
|
|
|
};
|
2016-11-15 21:59:09 +00:00
|
|
|
})
|