about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/ghc/head.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/ghc/head.nix')
-rw-r--r--nixpkgs/pkgs/development/compilers/ghc/head.nix16
1 files changed, 13 insertions, 3 deletions
diff --git a/nixpkgs/pkgs/development/compilers/ghc/head.nix b/nixpkgs/pkgs/development/compilers/ghc/head.nix
index a0ca13270a24..ec236731afd7 100644
--- a/nixpkgs/pkgs/development/compilers/ghc/head.nix
+++ b/nixpkgs/pkgs/development/compilers/ghc/head.nix
@@ -100,9 +100,19 @@ let
 
   targetCC = builtins.head toolsForTarget;
 
-  # ld.gold is disabled for musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
+  # Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
+  # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
   # see #84670 and #49071 for more background.
-  useLdGold = targetPlatform.isLinux && !(targetPlatform.useLLVM or false) && !targetPlatform.isMusl;
+  useLdGold = targetPlatform.linker == "gold" || (targetPlatform.linker == "bfd" && !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 {
@@ -242,7 +252,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
   '';