haskell.compiler.ghc*Binary: add all missing runtimeDeps to PATH

This brings the binary GHCs on parity with the source built ones in
terms of the wrapper. The upshot of this is that compiling something
using the binary GHCs no longer depends on PATH being populated with
the tools included in stdenv at all. We can even test this by running
the installCheck with an empty environment (via `env -i`).
This commit is contained in:
sternenseemann 2021-11-25 13:52:57 +01:00
parent 579bc49e94
commit 5384a35a0c
3 changed files with 41 additions and 9 deletions

View file

@ -3,6 +3,8 @@
, ncurses5 , ncurses5
, ncurses6, gmp, libiconv, numactl , ncurses6, gmp, libiconv, numactl
, llvmPackages , llvmPackages
, coreutils
, targetPackages
# minimal = true; will remove files that aren't strictly necessary for # minimal = true; will remove files that aren't strictly necessary for
# regular builds and GHC bootstrapping. # regular builds and GHC bootstrapping.
@ -140,8 +142,17 @@ let
libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY" libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
+ "LD_LIBRARY_PATH"; + "LD_LIBRARY_PATH";
runtimeDeps = lib.optionals useLLVM [ runtimeDeps = [
targetPackages.stdenv.cc
targetPackages.stdenv.cc.bintools
coreutils # for cat
]
++ lib.optionals useLLVM [
(lib.getBin llvmPackages.llvm) (lib.getBin llvmPackages.llvm)
]
# On darwin, we need unwrapped bintools as well (for otool)
++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
targetPackages.stdenv.cc.bintools.bintools
]; ];
in in
@ -372,7 +383,6 @@ stdenv.mkDerivation rec {
doInstallCheck = true; doInstallCheck = true;
installCheckPhase = '' installCheckPhase = ''
unset ${libEnvVar}
# Sanity check, can ghc create executables? # Sanity check, can ghc create executables?
cd $TMP cd $TMP
mkdir test-ghc; cd test-ghc mkdir test-ghc; cd test-ghc
@ -381,6 +391,8 @@ stdenv.mkDerivation rec {
module Main where module Main where
main = putStrLn \$([|"yes"|]) main = putStrLn \$([|"yes"|])
EOF EOF
# can't use env -i here because otherwise we don't find -lgmp on musl
env ${libEnvVar}= PATH= \
$out/bin/ghc --make main.hs || exit 1 $out/bin/ghc --make main.hs || exit 1
echo compilation ok echo compilation ok
[ $(./main) == "yes" ] [ $(./main) == "yes" ]

View file

@ -3,6 +3,8 @@
, ncurses5 , ncurses5
, ncurses6, gmp, libiconv, numactl , ncurses6, gmp, libiconv, numactl
, llvmPackages , llvmPackages
, coreutils
, targetPackages
# minimal = true; will remove files that aren't strictly necessary for # minimal = true; will remove files that aren't strictly necessary for
# regular builds and GHC bootstrapping. # regular builds and GHC bootstrapping.
@ -155,8 +157,17 @@ let
libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY" libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
+ "LD_LIBRARY_PATH"; + "LD_LIBRARY_PATH";
runtimeDeps = lib.optionals useLLVM [ runtimeDeps = [
targetPackages.stdenv.cc
targetPackages.stdenv.cc.bintools
coreutils # for cat
]
++ lib.optionals useLLVM [
(lib.getBin llvmPackages.llvm) (lib.getBin llvmPackages.llvm)
]
# On darwin, we need unwrapped bintools as well (for otool)
++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
targetPackages.stdenv.cc.bintools.bintools
]; ];
in in
@ -370,7 +381,6 @@ stdenv.mkDerivation rec {
doInstallCheck = true; doInstallCheck = true;
installCheckPhase = '' installCheckPhase = ''
unset ${libEnvVar}
# Sanity check, can ghc create executables? # Sanity check, can ghc create executables?
cd $TMP cd $TMP
mkdir test-ghc; cd test-ghc mkdir test-ghc; cd test-ghc
@ -379,7 +389,7 @@ stdenv.mkDerivation rec {
module Main where module Main where
main = putStrLn \$([|"yes"|]) main = putStrLn \$([|"yes"|])
EOF EOF
$out/bin/ghc --make main.hs || exit 1 env -i $out/bin/ghc --make main.hs || exit 1
echo compilation ok echo compilation ok
[ $(./main) == "yes" ] [ $(./main) == "yes" ]
''; '';

View file

@ -2,6 +2,8 @@
, fetchurl, perl, gcc , fetchurl, perl, gcc
, ncurses5, ncurses6, gmp, glibc, libiconv , ncurses5, ncurses6, gmp, glibc, libiconv
, llvmPackages , llvmPackages
, coreutils
, targetPackages
}: }:
# Prebuilt only does native # Prebuilt only does native
@ -30,8 +32,17 @@ let
downloadsUrl = "https://downloads.haskell.org/ghc"; downloadsUrl = "https://downloads.haskell.org/ghc";
runtimeDeps = lib.optionals useLLVM [ runtimeDeps = [
targetPackages.stdenv.cc
targetPackages.stdenv.cc.bintools
coreutils # for cat
]
++ lib.optionals useLLVM [
(lib.getBin llvmPackages.llvm) (lib.getBin llvmPackages.llvm)
]
# On darwin, we need unwrapped bintools as well (for otool)
++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
targetPackages.stdenv.cc.bintools.bintools
]; ];
in in
@ -175,7 +186,6 @@ stdenv.mkDerivation rec {
doInstallCheck = true; doInstallCheck = true;
installCheckPhase = '' installCheckPhase = ''
unset ${libEnvVar}
# Sanity check, can ghc create executables? # Sanity check, can ghc create executables?
cd $TMP cd $TMP
mkdir test-ghc; cd test-ghc mkdir test-ghc; cd test-ghc
@ -184,7 +194,7 @@ stdenv.mkDerivation rec {
module Main where module Main where
main = putStrLn \$([|"yes"|]) main = putStrLn \$([|"yes"|])
EOF EOF
$out/bin/ghc --make main.hs || exit 1 env -i $out/bin/ghc --make main.hs || exit 1
echo compilation ok echo compilation ok
[ $(./main) == "yes" ] [ $(./main) == "yes" ]
''; '';