From 9a84eb7ec89bbb89e39183bf52393429033f9592 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Tue, 1 Jun 2021 23:52:19 +0200 Subject: [PATCH] haskell.compiler.*: pull in unwrapped bintools for darwin GHC calls otool on darwin which is contained in the stdenv.cc.bintools.bintools derivation and thus needs adding to the runtime PATH of GHC. Since this is toolchain specific technically, we check for cctools instead of darwin (although I don't know if GHC or nixpkgs work on macOS without cctools). This fixes usage of GHC in an environment where otool is not available and more specifically in stdenvNoCC which is used by writers.writeHaskell. Resolves #123228. (cherry picked from commit 118b28a127c79dbae8c513742fbb17f300407a4b) --- pkgs/development/compilers/ghc/8.10.4.nix | 11 ++++++++++- pkgs/development/compilers/ghc/8.8.4.nix | 11 ++++++++++- pkgs/development/compilers/ghc/9.0.1.nix | 11 ++++++++++- pkgs/development/compilers/ghc/head.nix | 11 ++++++++++- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.4.nix b/pkgs/development/compilers/ghc/8.10.4.nix index da957f93520..9c514efc282 100644 --- a/pkgs/development/compilers/ghc/8.10.4.nix +++ b/pkgs/development/compilers/ghc/8.10.4.nix @@ -93,6 +93,15 @@ let # see #84670 and #49071 for more background. useLdGold = targetPlatform.isLinux && !(targetPlatform.useLLVM or false) && !targetPlatform.isMusl; + runtimeDeps = [ + targetPackages.stdenv.cc.bintools + coreutils + ] + # On darwin, we need unwrapped bintools as well (for otool) + ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ + targetPackages.stdenv.cc.bintools.bintools + ]; + in stdenv.mkDerivation (rec { version = "8.10.4"; @@ -235,7 +244,7 @@ stdenv.mkDerivation (rec { for i in "$out/bin/"*; do test ! -h $i || continue egrep --quiet '^#!' <(head -n 1 $i) || continue - sed -i -e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i + sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i done ''; diff --git a/pkgs/development/compilers/ghc/8.8.4.nix b/pkgs/development/compilers/ghc/8.8.4.nix index b0336ad3992..fcb7db617d0 100644 --- a/pkgs/development/compilers/ghc/8.8.4.nix +++ b/pkgs/development/compilers/ghc/8.8.4.nix @@ -102,6 +102,15 @@ let # see #84670 and #49071 for more background. useLdGold = targetPlatform.isLinux && !(targetPlatform.useLLVM or false) && !targetPlatform.isMusl; + runtimeDeps = [ + targetPackages.stdenv.cc.bintools + coreutils + ] + # On darwin, we need unwrapped bintools as well (for otool) + ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ + targetPackages.stdenv.cc.bintools.bintools + ]; + in stdenv.mkDerivation (rec { version = "8.8.4"; @@ -242,7 +251,7 @@ stdenv.mkDerivation (rec { for i in "$out/bin/"*; do test ! -h $i || continue egrep --quiet '^#!' <(head -n 1 $i) || continue - sed -i -e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i + sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i done ''; diff --git a/pkgs/development/compilers/ghc/9.0.1.nix b/pkgs/development/compilers/ghc/9.0.1.nix index 58beef5d688..a110d587874 100644 --- a/pkgs/development/compilers/ghc/9.0.1.nix +++ b/pkgs/development/compilers/ghc/9.0.1.nix @@ -94,6 +94,15 @@ let # see #84670 and #49071 for more background. useLdGold = targetPlatform.isLinux && !(targetPlatform.useLLVM or false) && !targetPlatform.isMusl; + runtimeDeps = [ + targetPackages.stdenv.cc.bintools + coreutils + ] + # On darwin, we need unwrapped bintools as well (for otool) + ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ + targetPackages.stdenv.cc.bintools.bintools + ]; + in stdenv.mkDerivation (rec { version = "9.0.1"; @@ -225,7 +234,7 @@ stdenv.mkDerivation (rec { for i in "$out/bin/"*; do test ! -h $i || continue egrep --quiet '^#!' <(head -n 1 $i) || continue - sed -i -e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i + sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i done ''; diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index a0ca13270a2..e1c1cdf8dc5 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -104,6 +104,15 @@ let # see #84670 and #49071 for more background. useLdGold = targetPlatform.isLinux && !(targetPlatform.useLLVM or false) && !targetPlatform.isMusl; + runtimeDeps = [ + targetPackages.stdenv.cc.bintools + coreutils + ] + # On darwin, we need unwrapped bintools as well (for otool) + ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ + targetPackages.stdenv.cc.bintools.bintools + ]; + in stdenv.mkDerivation (rec { inherit version; @@ -242,7 +251,7 @@ stdenv.mkDerivation (rec { for i in "$out/bin/"*; do test ! -h $i || continue egrep --quiet '^#!' <(head -n 1 $i) || continue - sed -i -e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i + sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i done '';