From 5384a35a0c5198e224435b7295b3d273e645243d Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Thu, 25 Nov 2021 13:52:57 +0100 Subject: [PATCH] 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`). --- .../compilers/ghc/8.10.2-binary.nix | 18 +++++++++++++++--- .../compilers/ghc/8.10.7-binary.nix | 16 +++++++++++++--- .../development/compilers/ghc/8.6.5-binary.nix | 16 +++++++++++++--- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.2-binary.nix b/pkgs/development/compilers/ghc/8.10.2-binary.nix index d610e4bcd8cb..a29a5b0b5ab6 100644 --- a/pkgs/development/compilers/ghc/8.10.2-binary.nix +++ b/pkgs/development/compilers/ghc/8.10.2-binary.nix @@ -3,6 +3,8 @@ , ncurses5 , ncurses6, gmp, libiconv, numactl , llvmPackages +, coreutils +, targetPackages # minimal = true; will remove files that aren't strictly necessary for # regular builds and GHC bootstrapping. @@ -140,8 +142,17 @@ let libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY" + "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) + ] + # On darwin, we need unwrapped bintools as well (for otool) + ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ + targetPackages.stdenv.cc.bintools.bintools ]; in @@ -372,7 +383,6 @@ stdenv.mkDerivation rec { doInstallCheck = true; installCheckPhase = '' - unset ${libEnvVar} # Sanity check, can ghc create executables? cd $TMP mkdir test-ghc; cd test-ghc @@ -381,7 +391,9 @@ stdenv.mkDerivation rec { module Main where main = putStrLn \$([|"yes"|]) EOF - $out/bin/ghc --make main.hs || exit 1 + # 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 echo compilation ok [ $(./main) == "yes" ] ''; diff --git a/pkgs/development/compilers/ghc/8.10.7-binary.nix b/pkgs/development/compilers/ghc/8.10.7-binary.nix index b8164ae9f6f3..7b10f60affda 100644 --- a/pkgs/development/compilers/ghc/8.10.7-binary.nix +++ b/pkgs/development/compilers/ghc/8.10.7-binary.nix @@ -3,6 +3,8 @@ , ncurses5 , ncurses6, gmp, libiconv, numactl , llvmPackages +, coreutils +, targetPackages # minimal = true; will remove files that aren't strictly necessary for # regular builds and GHC bootstrapping. @@ -155,8 +157,17 @@ let libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY" + "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) + ] + # On darwin, we need unwrapped bintools as well (for otool) + ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ + targetPackages.stdenv.cc.bintools.bintools ]; in @@ -370,7 +381,6 @@ stdenv.mkDerivation rec { doInstallCheck = true; installCheckPhase = '' - unset ${libEnvVar} # Sanity check, can ghc create executables? cd $TMP mkdir test-ghc; cd test-ghc @@ -379,7 +389,7 @@ stdenv.mkDerivation rec { module Main where main = putStrLn \$([|"yes"|]) EOF - $out/bin/ghc --make main.hs || exit 1 + env -i $out/bin/ghc --make main.hs || exit 1 echo compilation ok [ $(./main) == "yes" ] ''; diff --git a/pkgs/development/compilers/ghc/8.6.5-binary.nix b/pkgs/development/compilers/ghc/8.6.5-binary.nix index 95b381b955fd..22bfae79c0ce 100644 --- a/pkgs/development/compilers/ghc/8.6.5-binary.nix +++ b/pkgs/development/compilers/ghc/8.6.5-binary.nix @@ -2,6 +2,8 @@ , fetchurl, perl, gcc , ncurses5, ncurses6, gmp, glibc, libiconv , llvmPackages +, coreutils +, targetPackages }: # Prebuilt only does native @@ -30,8 +32,17 @@ let 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) + ] + # On darwin, we need unwrapped bintools as well (for otool) + ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ + targetPackages.stdenv.cc.bintools.bintools ]; in @@ -175,7 +186,6 @@ stdenv.mkDerivation rec { doInstallCheck = true; installCheckPhase = '' - unset ${libEnvVar} # Sanity check, can ghc create executables? cd $TMP mkdir test-ghc; cd test-ghc @@ -184,7 +194,7 @@ stdenv.mkDerivation rec { module Main where main = putStrLn \$([|"yes"|]) EOF - $out/bin/ghc --make main.hs || exit 1 + env -i $out/bin/ghc --make main.hs || exit 1 echo compilation ok [ $(./main) == "yes" ] '';