Add function to build a ghc standalone archive (OSX/iOS only)

This commit is contained in:
Shea Levy 2017-01-23 18:35:03 -05:00
parent e026568e6c
commit 4f9f00fcc9
3 changed files with 28 additions and 1 deletions

View File

@ -85,8 +85,17 @@ in stdenv.mkDerivation (rec {
} // stdenv.lib.optionalAttrs (cross != null) {
name = "${cross.config}-ghc-${version}";
patches = [ ./ios-linker.patch ];
preConfigure = commonPreConfigure + ''
sed 's|#BuildFlavour = quick-cross|BuildFlavour = perf-cross|' mk/build.mk.sample > mk/build.mk
sed 's|#BuildFlavour = quick-cross|BuildFlavour = quick-cross|' mk/build.mk.sample > mk/build.mk
echo "GhcRtsCcOpts = -glldb -Og" >> mk/build.mk
'';
postUnpack = ''
mkdir -p $out/nix-support
mv $sourceRoot $out/nix-support/source
sourceRoot=$out/nix-support/source
'';
configureFlags = [
@ -103,6 +112,8 @@ in stdenv.mkDerivation (rec {
dontSetConfigureCross = true;
dontStrip = true;
passthru = {
inherit bootPkgs cross;

View File

@ -0,0 +1,14 @@
{ runCommand, cctools }:
{ haskellPackages, src, deps ? p : [], name }: let
inherit (haskellPackages) ghc ghcWithPackages;
with-env = ghcWithPackages deps;
crossPrefix = if (ghc.cross or null) != null then "${ghc.cross.config}-" else "";
ghcName = "${crossPrefix}ghc";
in runCommand name { buildInputs = [ with-env cctools ]; } ''
mkdir -p $out/lib
mkdir -p $out/include
${ghcName} ${src} -staticlib -outputdir . -o $out/lib/${name}.a -stubdir $out/include
for file in ${ghc}/lib/${ghcName}-${ghc.version}/include/*; do
ln -sv $file $out/include
done
''

View File

@ -18042,4 +18042,6 @@ in
simplenote = callPackage ../applications/misc/simplenote { };
hy = callPackage ../development/interpreters/hy {};
ghc-standalone-archive = callPackage ../os-specific/darwin/ghc-standalone-archive { inherit (darwin) cctools; };
}