Add haskell packages set for cross ghc

This commit is contained in:
Shea Levy 2016-11-18 10:44:53 -05:00
parent 247d7c88d2
commit 64ec4dd87b
4 changed files with 53 additions and 20 deletions

View File

@ -1,5 +1,5 @@
{ stdenv, fetchgit, bootPkgs, perl, gmp, ncurses, libiconv, binutils, coreutils
, autoconf, automake, happy, alex, cross ? null
, autoconf, automake, happy, alex, crossSystem, selfPkgs, cross ? null
}:
let
@ -70,6 +70,11 @@ in stdenv.mkDerivation (rec {
passthru = {
inherit bootPkgs;
} // stdenv.lib.optionalAttrs (crossSystem != null) {
crossCompiler = selfPkgs.ghc.override {
cross = crossSystem;
bootPkgs = selfPkgs;
};
};
meta = {
@ -90,11 +95,24 @@ in stdenv.mkDerivation (rec {
'';
configureFlags = [
"CC=${cross.config}-cc"
"CC=${stdenv.ccCross}/bin/${cross.config}-cc"
"LD=${stdenv.binutilsCross}/bin/${cross.config}-ld"
"AR=${stdenv.binutilsCross}/bin/${cross.config}-ar"
"NM=${stdenv.binutilsCross}/bin/${cross.config}-nm"
"RANLIB=${stdenv.binutilsCross}/bin/${cross.config}-ranlib"
"--target=${cross.config}"
"--enable-bootstrap-with-devel-snapshot"
];
buildInputs = commonBuildInputs ++ [ stdenv.ccCross stdenv.binutilsCross ];
dontSetConfigureCross = true;
passthru = {
inherit bootPkgs cross;
cc = "${stdenv.ccCross}/bin/${cross.config}-cc";
ld = "${stdenv.binutilsCross}/bin/${cross.config}-ld";
};
})

View File

@ -1,6 +1,6 @@
{ stdenv, fetchurl, ghc, pkgconfig, glibcLocales, coreutils, gnugrep, gnused
, jailbreak-cabal, hscolour, cpphs, nodePackages
}:
}: let isCross = (ghc.cross or null) != null; in
{ pname
, dontStrip ? (ghc.isGhcjs or false)
@ -12,13 +12,14 @@
, buildTools ? [], libraryToolDepends ? [], executableToolDepends ? [], testToolDepends ? []
, configureFlags ? []
, description ? ""
, doCheck ? stdenv.lib.versionOlder "7.4" ghc.version
, doCheck ? !isCross && (stdenv.lib.versionOlder "7.4" ghc.version)
, doHoogle ? true
, editedCabalFile ? null
, enableLibraryProfiling ? false
, enableExecutableProfiling ? false
, enableSharedExecutables ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version)
, enableSharedLibraries ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version)
# TODO enable shared libs for cross-compiling
, enableSharedExecutables ? !isCross && (((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version))
, enableSharedLibraries ? !isCross && (((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version))
, enableSplitObjs ? !stdenv.isDarwin # http://hackage.haskell.org/trac/ghc/ticket/4013
, enableStaticLibraries ? true
, extraLibraries ? [], librarySystemDepends ? [], executableSystemDepends ? []
@ -30,7 +31,8 @@
, jailbreak ? false
, license
, maintainers ? []
, doHaddock ? !stdenv.isDarwin || stdenv.lib.versionAtLeast ghc.version "7.8"
# TODO Do we care about haddock when cross-compiling?
, doHaddock ? !isCross && (!stdenv.isDarwin || stdenv.lib.versionAtLeast ghc.version "7.8")
, passthru ? {}
, pkgconfigDepends ? [], libraryPkgconfigDepends ? [], executablePkgconfigDepends ? [], testPkgconfigDepends ? []
, testDepends ? [], testHaskellDepends ? [], testSystemDepends ? []
@ -57,14 +59,12 @@ let
inherit (stdenv.lib) optional optionals optionalString versionOlder
concatStringsSep enableFeature optionalAttrs toUpper;
isCross = ghc.isCross or false;
isGhcjs = ghc.isGhcjs or false;
packageDbFlag = if isGhcjs || versionOlder "7.6" ghc.version
then "package-db"
else "package-conf";
nativeGhc = if isCross then ghc.bootPkgs.ghc else ghc;
nativeIsCross = nativeGhc.isCross or false;
nativeGhc = if isCross || isGhcjs then ghc.bootPkgs.ghc else ghc;
nativePackageDbFlag = if versionOlder "7.6" nativeGhc.version
then "package-db"
else "package-conf";
@ -88,6 +88,17 @@ let
# details are at <https://github.com/peti/ghc-library-id-bug>.
enableParallelBuilding = versionOlder "7.8" ghc.version && !hasActiveLibrary;
crossCabalFlags = [
"--with-ghc=${ghc.cross.config}-ghc"
"--with-ghc-pkg=${ghc.cross.config}-ghc-pkg"
"--with-gcc=${ghc.cc}"
"--with-ld=${ghc.ld}"
"--hsc2hs-options=--cross-compile"
];
crossCabalFlagsString =
stdenv.lib.optionalString isCross (" " + stdenv.lib.concatStringsSep " " crossCabalFlags);
defaultConfigureFlags = [
"--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid"
"--with-gcc=$CC" # Clang won't work without that extra information.
@ -106,7 +117,9 @@ let
] ++ optionals isGhcjs [
"--with-hsc2hs=${nativeGhc}/bin/hsc2hs"
"--ghcjs"
];
] ++ optionals isCross ([
"--configure-option=--host=${ghc.cross.config}"
] ++ crossCabalFlags);
setupCompileFlags = [
(optionalString (!coreSetup) "-${packageDbFlag}=$packageConfDir")
@ -132,9 +145,9 @@ let
ghcEnv = ghc.withPackages (p: haskellBuildInputs);
setupBuilder = if isCross then "${nativeGhc}/bin/ghc" else ghcCommand;
setupBuilder = if isCross || isGhcjs then "${nativeGhc}/bin/ghc" else ghcCommand;
setupCommand = "./Setup";
ghcCommand = if isGhcjs then "ghcjs" else "ghc";
ghcCommand = if isGhcjs then "ghcjs" else if isCross then "${ghc.cross.config}-ghc" else "ghc";
ghcCommandCaps = toUpper ghcCommand;
in
@ -236,7 +249,7 @@ stdenv.mkDerivation ({
buildPhase = ''
runHook preBuild
${setupCommand} build ${buildTarget}
${setupCommand} build ${buildTarget}${crossCabalFlagsString}
runHook postBuild
'';

View File

@ -26,7 +26,7 @@
echo "-target ${prefix} -arch ${arch} -idirafter ${sdk}/usr/include ${if simulator then "-mios-simulator-version-min=7.0" else "-miphoneos-version-min=7.0"}" >> $out/nix-support/cc-cflags
# Purposefully overwrite libc-ldflags-before, cctools ld doesn't know dynamic-linker and cc-wrapper doesn't do cross-compilation well enough to adjust
echo "-arch ${arch} -L${sdk}/usr/lib -L${sdk}/usr/lib/system" > $out/nix-support/libc-ldflags-before
echo "-arch ${arch} -L${sdk}/usr/lib -iphoneos_version_min 7.0.0" > $out/nix-support/libc-ldflags-before
'';
};
in {

View File

@ -49,10 +49,8 @@ rec {
ghcHEAD = callPackage ../development/compilers/ghc/head.nix rec {
bootPkgs = packages.ghc7103;
inherit (bootPkgs) alex happy;
};
# TODO: how should we support multiple versions of this?
ghcCross = compiler.ghcHEAD.override {
cross = crossSystem;
inherit crossSystem;
selfPkgs = packages.ghcHEAD;
};
ghcNokinds = callPackage ../development/compilers/ghc/nokinds.nix rec {
bootPkgs = packages.ghc784;
@ -125,7 +123,11 @@ rec {
ghc = compiler.ghcHEAD;
compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-head.nix { };
};
# TODO Support for ghcCross here
# TODO Support for multiple variants here
ghcCross = callPackage ../development/haskell-modules {
ghc = compiler.ghcHEAD.crossCompiler;
compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-head.nix { };
};
ghcNokinds = callPackage ../development/haskell-modules {
ghc = compiler.ghcNokinds;
compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-nokinds.nix { };