summary refs log tree commit diff
path: root/pkgs/build-support/gcc-wrapper-old/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/gcc-wrapper-old/default.nix')
-rw-r--r--pkgs/build-support/gcc-wrapper-old/default.nix37
1 files changed, 18 insertions, 19 deletions
diff --git a/pkgs/build-support/gcc-wrapper-old/default.nix b/pkgs/build-support/gcc-wrapper-old/default.nix
index a87c726e0a8b..ae17989d932b 100644
--- a/pkgs/build-support/gcc-wrapper-old/default.nix
+++ b/pkgs/build-support/gcc-wrapper-old/default.nix
@@ -6,8 +6,9 @@
 # variables so that the compiler and the linker just "work".
 
 { name ? "", stdenv, lib, nativeTools, nativeLibc, nativePrefix ? ""
-, gcc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? ""
+, gcc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell
 , zlib ? null
+, hostPlatform, targetPlatform
 }:
 
 assert nativeTools -> nativePrefix != "";
@@ -55,24 +56,17 @@ stdenv.mkDerivation {
   langAda = if nativeTools then false else gcc ? langAda && gcc.langAda;
   langVhdl = if nativeTools then false else gcc ? langVhdl && gcc.langVhdl;
   zlib = if gcc != null && gcc ? langVhdl then zlib else null;
-  shell = if shell == "" then stdenv.shell else
-    if builtins.isAttrs shell then (shell + shell.shellPath)
-    else shell;
+  shell = shell + shell.shellPath or "";
 
   crossAttrs = {
-    shell = shell.crossDrv + shell.crossDrv.shellPath;
-    libc = stdenv.ccCross.libc;
-    coreutils = coreutils.crossDrv;
-    binutils = binutils.crossDrv;
-    gcc = gcc.crossDrv;
     #
     # This is not the best way to do this. I think the reference should be
     # the style in the gcc-cross-wrapper, but to keep a stable stdenv now I
     # do this sufficient if/else.
     dynamicLinker =
-      (if stdenv.cross.arch == "arm" then "ld-linux.so.3" else
-       if stdenv.cross.arch == "mips" then "ld.so.1" else
-       if stdenv.lib.hasSuffix "pc-gnu" stdenv.cross.config then "ld.so.1" else
+      (if hostPlatform.arch == "arm" then "ld-linux.so.3" else
+       if hostPlatform.arch == "mips" then "ld.so.1" else
+       if stdenv.lib.hasSuffix "pc-gnu" hostPlatform.config then "ld.so.1" else
        abort "don't know the name of the dynamic linker for this platform");
   };
 
@@ -86,15 +80,20 @@ stdenv.mkDerivation {
         + " (wrapper script)";
     };
 
-  # The dynamic linker has different names on different Linux platforms.
+  # The dynamic linker has different names on different platforms.
   dynamicLinker =
     if !nativeLibc then
-      (if stdenv.system == "i686-linux" then "ld-linux.so.2" else
-       if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
+      (if targetPlatform.system == "i686-linux"     then "ld-linux.so.2" else
+       if targetPlatform.system == "x86_64-linux"   then "ld-linux-x86-64.so.2" else
        # ARM with a wildcard, which can be "" or "-armhf".
-       if stdenv.isArm then "ld-linux*.so.3" else
-       if stdenv.system == "powerpc-linux" then "ld.so.1" else
-       if stdenv.system == "mips64el-linux" then "ld.so.1" else
-       abort "don't know the name of the dynamic linker for this platform")
+       if targetPlatform.isArm                      then "ld-linux*.so.3" else
+       if targetPlatform.system == "aarch64-linux"  then "ld-linux-aarch64.so.1" else
+       if targetPlatform.system == "powerpc-linux"  then "ld.so.1" else
+       if targetPlatform.system == "mips64el-linux" then "ld.so.1" else
+       if targetPlatform.system == "x86_64-darwin"  then "/usr/lib/dyld" else
+       if stdenv.lib.hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1" else
+       builtins.trace
+         "Don't know the name of the dynamic linker for platform ${targetPlatform.config}, so guessing instead."
+         null)
     else "";
 }