ghc: Clean up, and add passthru.targetPrefix, in preparation for cross

No hashes should be changed.
This commit is contained in:
John Ericson 2017-09-10 15:36:48 -04:00
parent e3993464d9
commit a5cc983c45
17 changed files with 187 additions and 66 deletions

View file

@ -4,6 +4,9 @@
, enableIntegerSimple ? false , enableIntegerSimple ? false
}: }:
# Prebuilt only does native
assert stdenv.targetPlatform == stdenv.hostPlatform;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
version = "6.10.2"; version = "6.10.2";
@ -93,6 +96,8 @@ stdenv.mkDerivation rec {
[ $(./main) == "yes" ] [ $(./main) == "yes" ]
''; '';
passthru = { targetPrefix = ""; };
meta = { meta = {
homepage = http://haskell.org/ghc; homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler"; description = "The Glasgow Haskell Compiler";

View file

@ -1,5 +1,8 @@
{stdenv, fetchurl, libedit, ghc, perl, gmp, ncurses}: {stdenv, fetchurl, libedit, ghc, perl, gmp, ncurses}:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
version = "6.10.4"; version = "6.10.4";
@ -22,6 +25,8 @@ stdenv.mkDerivation rec {
NIX_CFLAGS_COMPILE = "-fomit-frame-pointer"; NIX_CFLAGS_COMPILE = "-fomit-frame-pointer";
passthru = { targetPrefix = ""; };
meta = { meta = {
homepage = http://haskell.org/ghc; homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler"; description = "The Glasgow Haskell Compiler";

View file

@ -1,5 +1,8 @@
{stdenv, fetchurl, ghc, perl, gmp, ncurses}: {stdenv, fetchurl, ghc, perl, gmp, ncurses}:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
version = "6.12.3"; version = "6.12.3";
@ -33,6 +36,8 @@ stdenv.mkDerivation rec {
# that in turn causes GHCi to abort # that in turn causes GHCi to abort
stripDebugFlags=["-S" "--keep-file-symbols"]; stripDebugFlags=["-S" "--keep-file-symbols"];
passthru = { targetPrefix = ""; };
meta = { meta = {
homepage = http://haskell.org/ghc; homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler"; description = "The Glasgow Haskell Compiler";

View file

@ -3,6 +3,9 @@
, ncurses5, gmp, libiconv , ncurses5, gmp, libiconv
}: }:
# Prebuilt only does native
assert stdenv.targetPlatform == stdenv.hostPlatform;
let let
libPath = stdenv.lib.makeLibraryPath ([ libPath = stdenv.lib.makeLibraryPath ([
ncurses5 gmp ncurses5 gmp
@ -131,6 +134,8 @@ stdenv.mkDerivation rec {
[ $(./main) == "yes" ] [ $(./main) == "yes" ]
''; '';
passthru = { targetPrefix = ""; };
meta.license = stdenv.lib.licenses.bsd3; meta.license = stdenv.lib.licenses.bsd3;
meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"]; meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
} }

View file

@ -1,5 +1,8 @@
{ stdenv, fetchurl, ghc, perl, gmp, ncurses, libiconv }: { stdenv, fetchurl, ghc, perl, gmp, ncurses, libiconv }:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
version = "7.0.4"; version = "7.0.4";
name = "ghc-${version}"; name = "ghc-${version}";
@ -42,6 +45,8 @@ stdenv.mkDerivation rec {
# that in turn causes GHCi to abort # that in turn causes GHCi to abort
stripDebugFlags=["-S" "--keep-file-symbols"]; stripDebugFlags=["-S" "--keep-file-symbols"];
passthru = { targetPrefix = ""; };
meta = { meta = {
homepage = http://haskell.org/ghc; homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler"; description = "The Glasgow Haskell Compiler";

View file

@ -4,6 +4,9 @@
, gcc , gcc
}: }:
# Prebuilt only does native
assert stdenv.targetPlatform == stdenv.hostPlatform;
let let
libPath = stdenv.lib.makeLibraryPath ([ libPath = stdenv.lib.makeLibraryPath ([
ncurses5 gmp ncurses5 gmp
@ -148,6 +151,8 @@ stdenv.mkDerivation rec {
[ $(./main) == "yes" ] [ $(./main) == "yes" ]
''; '';
passthru = { targetPrefix = ""; };
meta.license = stdenv.lib.licenses.bsd3; meta.license = stdenv.lib.licenses.bsd3;
meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin" "armv7l-linux"]; meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin" "armv7l-linux"];
} }

View file

@ -1,14 +1,28 @@
{ stdenv, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, targetPackages, coreutils { stdenv, targetPackages
, libxml2, libxslt, docbook_xsl, docbook_xml_dtd_45, docbook_xml_dtd_42, hscolour , buildPlatform, hostPlatform, targetPlatform
# If enabled GHC will be build with the GPL-free but slower integer-simple # build-tools
, bootPkgs, hscolour
, coreutils, fetchurl, fetchpatch, perl
, docbook_xsl, docbook_xml_dtd_45, docbook_xml_dtd_42, libxml2, libxslt
, libiconv ? null, ncurses
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library. # library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp enableIntegerSimple ? false, gmp ? null
}: }:
assert !enableIntegerSimple -> gmp != null;
let let
inherit (bootPkgs) ghc; inherit (bootPkgs) ghc;
# TODO(@Ericson2314) Make unconditional
targetPrefix = stdenv.lib.optionalString
(targetPlatform != hostPlatform)
"${targetPlatform.config}-";
docFixes = fetchurl { docFixes = fetchurl {
url = "https://downloads.haskell.org/~ghc/7.10.3/ghc-7.10.3a.patch"; url = "https://downloads.haskell.org/~ghc/7.10.3/ghc-7.10.3a.patch";
sha256 = "1j45z4kcd3w1rzm4hapap2xc16bbh942qnzzdbdjcwqznsccznf0"; sha256 = "1j45z4kcd3w1rzm4hapap2xc16bbh942qnzzdbdjcwqznsccznf0";
@ -18,10 +32,10 @@ in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
version = "7.10.3"; version = "7.10.3";
name = "ghc-${version}"; name = "${targetPrefix}ghc-${version}";
src = fetchurl { src = fetchurl {
url = "https://downloads.haskell.org/~ghc/${version}/${name}-src.tar.xz"; url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz";
sha256 = "1vsgmic8csczl62ciz51iv8nhrkm72lyhbz7p7id13y2w7fcx46g"; sha256 = "1vsgmic8csczl62ciz51iv8nhrkm72lyhbz7p7id13y2w7fcx46g";
}; };
@ -62,7 +76,7 @@ stdenv.mkDerivation rec {
postInstall = '' postInstall = ''
# Install the bash completion file. # Install the bash completion file.
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/ghc install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
# Patch scripts to include "readelf" and "cat" in $PATH. # Patch scripts to include "readelf" and "cat" in $PATH.
for i in "$out/bin/"*; do for i in "$out/bin/"*; do
@ -73,7 +87,7 @@ stdenv.mkDerivation rec {
''; '';
passthru = { passthru = {
inherit bootPkgs; inherit bootPkgs targetPrefix;
}; };
meta = { meta = {

View file

@ -1,10 +1,14 @@
{ stdenv, fetchurl, ghc, perl, ncurses, libiconv { stdenv, fetchurl, ghc, perl, ncurses, libiconv
# If enabled GHC will be build with the GPL-free but slower integer-simple , # If enabled, GHC will be built with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library. # library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp enableIntegerSimple ? false, gmp ? null
}: }:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
assert !enableIntegerSimple -> gmp != null;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
version = "7.2.2"; version = "7.2.2";
name = "ghc-${version}"; name = "ghc-${version}";
@ -51,6 +55,8 @@ stdenv.mkDerivation rec {
# that in turn causes GHCi to abort # that in turn causes GHCi to abort
stripDebugFlags=["-S" "--keep-file-symbols"]; stripDebugFlags=["-S" "--keep-file-symbols"];
passthru = { targetPrefix = ""; };
meta = { meta = {
homepage = http://haskell.org/ghc; homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler"; description = "The Glasgow Haskell Compiler";

View file

@ -3,6 +3,9 @@
, ncurses5, gmp, libiconv , ncurses5, gmp, libiconv
}: }:
# Prebuilt only does native
assert stdenv.targetPlatform == stdenv.hostPlatform;
let let
libPath = stdenv.lib.makeLibraryPath ([ libPath = stdenv.lib.makeLibraryPath ([
ncurses5 gmp ncurses5 gmp
@ -133,6 +136,8 @@ stdenv.mkDerivation rec {
[ $(./main) == "yes" ] [ $(./main) == "yes" ]
''; '';
passthru = { targetPrefix = ""; };
meta.license = stdenv.lib.licenses.bsd3; meta.license = stdenv.lib.licenses.bsd3;
meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"]; meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
} }

View file

@ -1,10 +1,14 @@
{ stdenv, fetchurl, ghc, perl, ncurses, libiconv { stdenv, fetchurl, ghc, perl, ncurses, libiconv
# If enabled GHC will be build with the GPL-free but slower integer-simple , # If enabled, GHC will be built with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library. # library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp enableIntegerSimple ? false, gmp ? null
}: }:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
assert !enableIntegerSimple -> gmp != null;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
version = "7.4.2"; version = "7.4.2";
@ -52,6 +56,8 @@ stdenv.mkDerivation rec {
# that in turn causes GHCi to abort # that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols"; stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
passthru = { targetPrefix = ""; };
meta = { meta = {
homepage = http://haskell.org/ghc; homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler"; description = "The Glasgow Haskell Compiler";

View file

@ -1,10 +1,14 @@
{ stdenv, fetchurl, ghc, perl, ncurses, libiconv { stdenv, fetchurl, ghc, perl, ncurses, libiconv
# If enabled GHC will be build with the GPL-free but slower integer-simple , # If enabled, GHC will be built with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library. # library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp enableIntegerSimple ? false, gmp ? null
}: }:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
assert !enableIntegerSimple -> gmp != null;
let let
# The "-Wa,--noexecstack" options might be needed only with GNU ld (as opposed # The "-Wa,--noexecstack" options might be needed only with GNU ld (as opposed
# to the gold linker). It prevents binaries' stacks from being marked as # to the gold linker). It prevents binaries' stacks from being marked as
@ -78,6 +82,8 @@ in stdenv.mkDerivation rec {
# that in turn causes GHCi to abort # that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols"; stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
passthru = { targetPrefix = ""; };
meta = { meta = {
homepage = http://haskell.org/ghc; homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler"; description = "The Glasgow Haskell Compiler";

View file

@ -3,6 +3,9 @@
, ncurses5, gmp, libiconv , ncurses5, gmp, libiconv
}: }:
# Prebuilt only does native
assert stdenv.targetPlatform == stdenv.hostPlatform;
let let
libPath = stdenv.lib.makeLibraryPath ([ libPath = stdenv.lib.makeLibraryPath ([
ncurses5 gmp ncurses5 gmp
@ -146,6 +149,8 @@ stdenv.mkDerivation rec {
[ $(./main) == "yes" ] [ $(./main) == "yes" ]
''; '';
passthru = { targetPrefix = ""; };
meta.license = stdenv.lib.licenses.bsd3; meta.license = stdenv.lib.licenses.bsd3;
meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"]; meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
} }

View file

@ -1,10 +1,14 @@
{ stdenv, fetchurl, ghc, perl, ncurses, libiconv { stdenv, fetchurl, ghc, perl, ncurses, libiconv
# If enabled GHC will be build with the GPL-free but slower integer-simple , # If enabled, GHC will be built with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library. # library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp enableIntegerSimple ? false, gmp ? null
}: }:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
assert !enableIntegerSimple -> gmp != null;
stdenv.mkDerivation (rec { stdenv.mkDerivation (rec {
version = "7.8.4"; version = "7.8.4";
name = "ghc-${version}"; name = "ghc-${version}";
@ -49,6 +53,8 @@ stdenv.mkDerivation (rec {
# that in turn causes GHCi to abort # that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols"; stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
passthru = { targetPrefix = ""; };
meta = { meta = {
homepage = http://haskell.org/ghc; homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler"; description = "The Glasgow Haskell Compiler";

View file

@ -1,21 +1,33 @@
{ stdenv, lib, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, targetPackages, coreutils { stdenv, targetPackages
, hscolour, patchutils, sphinx , buildPlatform, hostPlatform, targetPlatform
# If enabled GHC will be build with the GPL-free but slower integer-simple # build-tools
, bootPkgs, hscolour
, coreutils, fetchurl, fetchpatch, patchutils, perl, sphinx
, libiconv ? null, ncurses
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library. # library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp enableIntegerSimple ? false, gmp ? null
, cross ? null
}: }:
assert !enableIntegerSimple -> gmp != null;
let let
inherit (bootPkgs) ghc; inherit (bootPkgs) ghc;
# TODO(@Ericson2314) Make unconditional
targetPrefix = stdenv.lib.optionalString
(targetPlatform != hostPlatform)
"${targetPlatform.config}-";
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
version = "8.0.2"; version = "8.0.2";
name = "ghc-${version}"; name = "${targetPrefix}ghc-${version}";
src = fetchurl { src = fetchurl {
url = "https://downloads.haskell.org/~ghc/8.0.2/${name}-src.tar.xz"; url = "https://downloads.haskell.org/~ghc/8.0.2/ghc-${version}-src.tar.xz";
sha256 = "1c8qc4fhkycynk4g1f9hvk53dj6a1vvqi6bklqznns6hw59m8qhi"; sha256 = "1c8qc4fhkycynk4g1f9hvk53dj6a1vvqi6bklqznns6hw59m8qhi";
}; };
@ -47,19 +59,20 @@ stdenv.mkDerivation rec {
"--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib"
] ++ stdenv.lib.optional stdenv.isDarwin [ ] ++ stdenv.lib.optional stdenv.isDarwin [
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
] ++ ] ++ stdenv.lib.optionals (targetPlatform.isDarwin && targetPlatform.isAarch64) [
# fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ # 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"; "--disable-large-address-space"
];
# required, because otherwise all symbols from HSffi.o are stripped, and # required, because otherwise all symbols from HSffi.o are stripped, and
# that in turn causes GHCi to abort # that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols"; stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
postInstall = '' postInstall = ''
paxmark m $out/lib/${name}/bin/{ghc,haddock} paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"}
# Install the bash completion file. # Install the bash completion file.
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/ghc install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
# Patch scripts to include "readelf" and "cat" in $PATH. # Patch scripts to include "readelf" and "cat" in $PATH.
for i in "$out/bin/"*; do for i in "$out/bin/"*; do
@ -70,7 +83,7 @@ stdenv.mkDerivation rec {
''; '';
passthru = { passthru = {
inherit bootPkgs; inherit bootPkgs targetPrefix;
}; };
meta = { meta = {

View file

@ -3,6 +3,9 @@
, ncurses5, gmp, libiconv , ncurses5, gmp, libiconv
}: }:
# Prebuilt only does native
assert stdenv.targetPlatform == stdenv.hostPlatform;
let let
libPath = stdenv.lib.makeLibraryPath ([ libPath = stdenv.lib.makeLibraryPath ([
ncurses5 gmp ncurses5 gmp
@ -151,6 +154,8 @@ stdenv.mkDerivation rec {
[ $(./main) == "yes" ] [ $(./main) == "yes" ]
''; '';
passthru = { targetPrefix = ""; };
meta.license = stdenv.lib.licenses.bsd3; meta.license = stdenv.lib.licenses.bsd3;
meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin" "armv7l-linux" "aarch64-linux"]; meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin" "armv7l-linux" "aarch64-linux"];
} }

View file

@ -1,16 +1,29 @@
{ stdenv, lib, fetchurl, bootPkgs, perl, ncurses, libiconv, binutils, coreutils { stdenv, targetPackages
, autoconf, automake, happy, alex, python3, sphinx, hscolour , buildPlatform, hostPlatform, targetPlatform
, buildPlatform, targetPlatform , selfPkgs, cross ? null , selfPkgs, cross ? null
# If enabled GHC will be build with the GPL-free but slower integer-simple # build-tools
, bootPkgs, alex, happy, hscolour
, autoconf, automake, coreutils, fetchurl, perl, python3, sphinx
, libiconv ? null, ncurses
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library. # library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp enableIntegerSimple ? false, gmp ? null
}: }:
assert !enableIntegerSimple -> gmp != null;
let let
inherit (bootPkgs) ghc; inherit (bootPkgs) ghc;
version = "8.2.2"; version = "8.2.2";
# TODO(@Ericson2314) Make unconditional
targetPrefix = stdenv.lib.optionalString
(targetPlatform != hostPlatform)
"${targetPlatform.config}-";
commonBuildInputs = [ alex autoconf automake ghc happy hscolour perl python3 sphinx ]; commonBuildInputs = [ alex autoconf automake ghc happy hscolour perl python3 sphinx ];
commonPreConfigure = '' commonPreConfigure = ''
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
@ -50,28 +63,28 @@ in stdenv.mkDerivation (rec {
# required, because otherwise all symbols from HSffi.o are stripped, and # required, because otherwise all symbols from HSffi.o are stripped, and
# that in turn causes GHCi to abort # that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols"; stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
checkTarget = "test"; checkTarget = "test";
postInstall = '' postInstall = ''
paxmark m $out/lib/${name}/bin/{ghc,haddock} paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"}
# Install the bash completion file. # Install the bash completion file.
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/ghc install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
# Patch scripts to include "readelf" and "cat" in $PATH. # Patch scripts to include "readelf" and "cat" in $PATH.
for i in "$out/bin/"*; do for i in "$out/bin/"*; do
test ! -h $i || continue test ! -h $i || continue
egrep --quiet '^#!' <(head -n 1 $i) || continue egrep --quiet '^#!' <(head -n 1 $i) || continue
sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ binutils coreutils ]}"' $i sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
done done
''; '';
outputs = [ "out" "doc" ]; outputs = [ "out" "doc" ];
passthru = { passthru = {
inherit bootPkgs; inherit bootPkgs targetPrefix;
} // stdenv.lib.optionalAttrs (targetPlatform != buildPlatform) { } // stdenv.lib.optionalAttrs (targetPlatform != buildPlatform) {
crossCompiler = selfPkgs.ghc.override { crossCompiler = selfPkgs.ghc.override {
cross = targetPlatform; cross = targetPlatform;
@ -94,24 +107,24 @@ in stdenv.mkDerivation (rec {
''; '';
configureFlags = [ configureFlags = [
"CC=${stdenv.ccCross}/bin/${cross.config}-cc" "CC=${stdenv.cc}/bin/${cross.config}-cc"
"LD=${stdenv.binutils}/bin/${cross.config}-ld" "LD=${stdenv.cc.bintools}/bin/${cross.config}-ld"
"AR=${stdenv.binutils}/bin/${cross.config}-ar" "AR=${stdenv.cc.bintools}/bin/${cross.config}-ar"
"NM=${stdenv.binutils}/bin/${cross.config}-nm" "NM=${stdenv.cc.bintools}/bin/${cross.config}-nm"
"RANLIB=${stdenv.binutils}/bin/${cross.config}-ranlib" "RANLIB=${stdenv.cc.bintools}/bin/${cross.config}-ranlib"
"--target=${cross.config}" "--target=${cross.config}"
"--enable-bootstrap-with-devel-snapshot" "--enable-bootstrap-with-devel-snapshot"
] ++ ] ++
# fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ # 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"; stdenv.lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space";
buildInputs = commonBuildInputs ++ [ stdenv.ccCross stdenv.binutils ]; buildInputs = commonBuildInputs;
dontSetConfigureCross = true; configurePlatforms = [];
passthru = { passthru = {
inherit bootPkgs cross; inherit bootPkgs cross;
cc = "${stdenv.ccCross}/bin/${cross.config}-cc"; cc = "${stdenv.cc}/bin/${cross.config}-cc";
ld = "${stdenv.binutils}/bin/${cross.config}-ld"; ld = "${stdenv.cc}/bin/${cross.config}-ld";
}; };
}) })

View file

@ -1,20 +1,33 @@
{ stdenv, lib, fetchgit, bootPkgs, perl, ncurses, libiconv, targetPackages, coreutils { stdenv, targetPackages
, autoconf, automake, happy, alex, python3, buildPlatform, targetPlatform , buildPlatform, hostPlatform, targetPlatform
, selfPkgs, cross ? null , selfPkgs, cross ? null
# If enabled GHC will be build with the GPL-free but slower integer-simple # build-tools
, bootPkgs, alex, happy
, autoconf, automake, coreutils, fetchgit, perl, python3
, libiconv ? null, ncurses
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library. # library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp enableIntegerSimple ? false, gmp ? null
, version ? "8.5.20171209" , version ? "8.5.20171209"
}: }:
assert !enableIntegerSimple -> gmp != null;
let let
inherit (bootPkgs) ghc; inherit (bootPkgs) ghc;
commonBuildInputs = [ ghc perl autoconf automake happy alex python3 ];
rev = "4335c07ca7e64624819b22644d7591853826bd75"; rev = "4335c07ca7e64624819b22644d7591853826bd75";
# TODO(@Ericson2314) Make unconditional
targetPrefix = stdenv.lib.optionalString
(targetPlatform != hostPlatform)
"${targetPlatform.config}-";
commonBuildInputs = [ ghc perl autoconf automake happy alex python3 ];
commonPreConfigure = '' commonPreConfigure = ''
echo ${version} >VERSION echo ${version} >VERSION
echo ${rev} >GIT_COMMIT_ID echo ${rev} >GIT_COMMIT_ID
@ -27,7 +40,8 @@ let
'' + stdenv.lib.optionalString enableIntegerSimple '' '' + stdenv.lib.optionalString enableIntegerSimple ''
echo "INTEGER_LIBRARY=integer-simple" > mk/build.mk echo "INTEGER_LIBRARY=integer-simple" > mk/build.mk
''; '';
in stdenv.mkDerivation (rec { in
stdenv.mkDerivation (rec {
inherit version rev; inherit version rev;
name = "ghc-${version}"; name = "ghc-${version}";
@ -57,15 +71,15 @@ in stdenv.mkDerivation (rec {
# required, because otherwise all symbols from HSffi.o are stripped, and # required, because otherwise all symbols from HSffi.o are stripped, and
# that in turn causes GHCi to abort # that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols"; stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
checkTarget = "test"; checkTarget = "test";
postInstall = '' postInstall = ''
paxmark m $out/lib/${name}/bin/{ghc,haddock} paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"}
# Install the bash completion file. # Install the bash completion file.
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/ghc install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
# Patch scripts to include "readelf" and "cat" in $PATH. # Patch scripts to include "readelf" and "cat" in $PATH.
for i in "$out/bin/"*; do for i in "$out/bin/"*; do
@ -78,7 +92,7 @@ in stdenv.mkDerivation (rec {
outputs = [ "out" "doc" ]; outputs = [ "out" "doc" ];
passthru = { passthru = {
inherit bootPkgs; inherit bootPkgs targetPrefix;
} // stdenv.lib.optionalAttrs (targetPlatform != buildPlatform) { } // stdenv.lib.optionalAttrs (targetPlatform != buildPlatform) {
crossCompiler = selfPkgs.ghc.override { crossCompiler = selfPkgs.ghc.override {
cross = targetPlatform; cross = targetPlatform;
@ -102,15 +116,15 @@ in stdenv.mkDerivation (rec {
configureFlags = [ configureFlags = [
"CC=${stdenv.cc}/bin/${cross.config}-cc" "CC=${stdenv.cc}/bin/${cross.config}-cc"
"LD=${stdenv.cc}/bin/${cross.config}-ld" "LD=${stdenv.cc.bintools}/bin/${cross.config}-ld"
"AR=${stdenv.cc}/bin/${cross.config}-ar" "AR=${stdenv.cc.bintools}/bin/${cross.config}-ar"
"NM=${stdenv.cc}/bin/${cross.config}-nm" "NM=${stdenv.cc.bintools}/bin/${cross.config}-nm"
"RANLIB=${stdenv.cc}/bin/${cross.config}-ranlib" "RANLIB=${stdenv.cc.bintools}/bin/${cross.config}-ranlib"
"--target=${cross.config}" "--target=${cross.config}"
"--enable-bootstrap-with-devel-snapshot" "--enable-bootstrap-with-devel-snapshot"
] ++ ] ++
# fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ # 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"; stdenv.lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space";
buildInputs = commonBuildInputs; buildInputs = commonBuildInputs;
@ -118,9 +132,7 @@ in stdenv.mkDerivation (rec {
passthru = { passthru = {
inherit bootPkgs cross; inherit bootPkgs cross;
cc = "${stdenv.cc}/bin/${cross.config}-cc"; cc = "${stdenv.cc}/bin/${cross.config}-cc";
ld = "${stdenv.cc}/bin/${cross.config}-ld"; ld = "${stdenv.cc}/bin/${cross.config}-ld";
}; };
}) })