Skip to content

ghc.exactDeps/envDeps built with unpatched ghc #369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions builder/make-config-files.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let

# Every library component built with `comp-builder.nix` includes an `exactDep`
# and `envDep` directory with precomputed values used here.
# GHC derivations include `exactDep` and `envDep` derivations that have
# GHC derivations include `exactDep` and `envDep` directories that have
# the same information for each of the built in packages.

# exactDep will pass --exact-configuration to the `SETUP_HS confiugre` command.
Expand All @@ -38,9 +38,9 @@ let
'';

catGhcPkgExactDep = p: ''
if [ -e ${ghc.exactDeps}/${p} ]; then
cat ${ghc.exactDeps}/${p}/configure-flags >> $out/configure-flags
cat ${ghc.exactDeps}/${p}/cabal.config >> $out/cabal.config
if [ -e ${ghc}/exactDeps/${p} ]; then
cat ${ghc}/exactDeps/${p}/configure-flags >> $out/configure-flags
cat ${ghc}/exactDeps/${p}/cabal.config >> $out/cabal.config
fi
'';

Expand All @@ -49,8 +49,8 @@ let
'';

catGhcPkgEnvDep = p: ''
if [ -e ${ghc.envDeps}/${p} ]; then
cat ${ghc.envDeps}/${p} >> $out/ghc-environment
if [ -e ${ghc}/envDeps/${p} ]; then
cat ${ghc}/envDeps/${p} >> $out/ghc-environment
fi
'';

Expand Down
8 changes: 2 additions & 6 deletions compiler/ghc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

, libiconv ? null, ncurses

, exactDeps, envDeps
, installDeps

, # GHC can be built with system libffi or a bundled one.
libffi ? null
Expand Down Expand Up @@ -300,7 +300,7 @@ in let configured-src = stdenv.mkDerivation (rec {
egrep --quiet '^#!' <(head -n 1 $i) || continue
sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
done
'';
'' + installDeps targetPrefix;

passthru = {
inherit bootPkgs targetPrefix;
Expand All @@ -315,10 +315,6 @@ in let configured-src = stdenv.mkDerivation (rec {

# Used to detect non haskell-nix compilers (accedental use of nixpkgs compilers can lead to unexpected errors)
isHaskellNixCompiler = true;

# These are used in make-config-files.nix
exactDeps = exactDeps drv;
envDeps = envDeps drv;
} // extra-passthru;

meta = {
Expand Down
58 changes: 28 additions & 30 deletions overlays/bootstrap.nix
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
self: super:
let
exactDeps = ghc: self.runCommand "ghc-exactdep-${ghc.version}" { nativeBuildInputs = [ ghc ]; } ''
for P in $(${ghc.targetPrefix}ghc-pkg list --simple-output | sed 's/-[0-9][0-9.]*//g'); do
mkdir -p $out/$P
touch $out/$P/configure-flags
touch $out/$P/cabal.config

if id=$(${ghc.targetPrefix}ghc-pkg field $P id --simple-output); then
echo "--dependency=$P=$id" >> $out/$P/configure-flags
elif id=$(${ghc.targetPrefix}ghc-pkg field "z-$P-z-*" id --simple-output); then
name=$(${ghc.targetPrefix}ghc-pkg field "z-$P-z-*" name --simple-output)
installDeps = targetPrefix: ''
for P in $($out/bin/${targetPrefix}ghc-pkg list --simple-output | sed 's/-[0-9][0-9.]*//g'); do
mkdir -p $out/exactDeps/$P
touch $out/exactDeps/$P/configure-flags
touch $out/exactDeps/$P/cabal.config

if id=$($out/bin/${targetPrefix}ghc-pkg field $P id --simple-output); then
echo "--dependency=$P=$id" >> $out/exactDeps/$P/configure-flags
elif id=$($out/bin/${targetPrefix}ghc-pkg field "z-$P-z-*" id --simple-output); then
name=$($out/bin/${targetPrefix}ghc-pkg field "z-$P-z-*" name --simple-output)
# so we are dealing with a sublib. As we build sublibs separately, the above
# query should be safe.
echo "--dependency=''${name#z-$P-z-}=$id" >> $out/$P/configure-flags
echo "--dependency=''${name#z-$P-z-}=$id" >> $out/exactDeps/$P/configure-flags
fi
if ver=$(${ghc.targetPrefix}ghc-pkg field $P version --simple-output); then
echo "constraint: $P == $ver" >> $out/$P/cabal.config
echo "constraint: $P installed" >> $out/$P/cabal.config
if ver=$($out/bin/${targetPrefix}ghc-pkg field $P version --simple-output); then
echo "constraint: $P == $ver" >> $out/exactDeps/$P/cabal.config
echo "constraint: $P installed" >> $out/exactDeps/$P/cabal.config
fi
done
'';

envDeps = ghc: self.runCommand "ghc-envdep-${ghc.version}" { nativeBuildInputs = [ ghc ]; } ''
mkdir -p $out
for P in $(${ghc.targetPrefix}ghc-pkg list --simple-output | sed 's/-[0-9.]*//g'); do
touch $out/$P
if id=$(${ghc.targetPrefix}ghc-pkg field $P id --simple-output); then
echo "package-id $id" >> $out/$P
mkdir -p $out/evalDeps
for P in $($out/bin/${targetPrefix}ghc-pkg list --simple-output | sed 's/-[0-9.]*//g'); do
touch $out/evalDeps/$P
if id=$($out/bin/${targetPrefix}ghc-pkg field $P id --simple-output); then
echo "package-id $id" >> $out/evalDeps/$P
fi
done
'';
Expand Down Expand Up @@ -105,7 +103,7 @@ in {
ghc844 = self.callPackage ../compiler/ghc {
extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc844; };

inherit bootPkgs sphinx exactDeps envDeps;
inherit bootPkgs sphinx installDeps;

buildLlvmPackages = self.buildPackages.llvmPackages_5;
llvmPackages = self.llvmPackages_5;
Expand All @@ -123,7 +121,7 @@ in {
ghc861 = self.callPackage ../compiler/ghc {
extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc861; };

inherit bootPkgs sphinx exactDeps envDeps;
inherit bootPkgs sphinx installDeps;

buildLlvmPackages = self.buildPackages.llvmPackages_5;
llvmPackages = self.llvmPackages_5;
Expand All @@ -139,7 +137,7 @@ in {
ghc862 = self.callPackage ../compiler/ghc {
extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc862; };

inherit bootPkgs sphinx exactDeps envDeps;
inherit bootPkgs sphinx installDeps;

buildLlvmPackages = self.buildPackages.llvmPackages_5;
llvmPackages = self.llvmPackages_5;
Expand All @@ -156,7 +154,7 @@ in {
ghc863 = self.callPackage ../compiler/ghc {
extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc863; };

inherit bootPkgs sphinx exactDeps envDeps;
inherit bootPkgs sphinx installDeps;

buildLlvmPackages = self.buildPackages.llvmPackages_5;
llvmPackages = self.llvmPackages_5;
Expand All @@ -173,7 +171,7 @@ in {
ghc864 = self.callPackage ../compiler/ghc {
extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc864; };

inherit bootPkgs sphinx exactDeps envDeps;
inherit bootPkgs sphinx installDeps;

buildLlvmPackages = self.buildPackages.llvmPackages_5;
llvmPackages = self.llvmPackages_5;
Expand All @@ -190,7 +188,7 @@ in {
ghc865 = self.callPackage ../compiler/ghc {
extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc865; };

inherit bootPkgs sphinx exactDeps envDeps;
inherit bootPkgs sphinx installDeps;

buildLlvmPackages = self.buildPackages.llvmPackages_5;
llvmPackages = self.llvmPackages_5;
Expand Down Expand Up @@ -264,10 +262,10 @@ in {
# We mark these compilers as boot compilers to make sure they are only used
# where a boot compiler is expected.
compiler = builtins.mapAttrs (_: v:
v // {
v.overrideAttrs (drv: {
postInstall = (drv.postInstall or "") + installDeps "";
}) // {
isHaskellNixBootCompiler = true;
exactDeps = exactDeps v;
envDeps = envDeps v;
}
)
(import ../compiler/old-ghc-nix { pkgs = self; });
Expand Down