summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2019-04-20 16:52:26 -0400
committerGitHub <noreply@github.com>2019-04-20 16:52:26 -0400
commitc351eb2842367845790fda0631ac9917ce6c832b (patch)
tree0d195fe4ad2eb8c25b3ef11573fdf0712e543b19
parentbfd9eaeb5379de060b4bed7aabe2e5383b7da96f (diff)
parent4224b034cc9cf415517f5779c7a6fc5fda2ff635 (diff)
downloadnixpkgs-c351eb2842367845790fda0631ac9917ce6c832b.tar
nixpkgs-c351eb2842367845790fda0631ac9917ce6c832b.tar.gz
nixpkgs-c351eb2842367845790fda0631ac9917ce6c832b.tar.bz2
nixpkgs-c351eb2842367845790fda0631ac9917ce6c832b.tar.lz
nixpkgs-c351eb2842367845790fda0631ac9917ce6c832b.tar.xz
nixpkgs-c351eb2842367845790fda0631ac9917ce6c832b.tar.zst
nixpkgs-c351eb2842367845790fda0631ac9917ce6c832b.zip
Merge pull request #59897 from matthewbauer/mb-cross-fixes2
Miscellaneous cross compilation fixes
-rw-r--r--lib/systems/default.nix14
-rw-r--r--lib/systems/parse.nix46
-rw-r--r--pkgs/development/interpreters/spidermonkey/52.nix8
-rw-r--r--pkgs/development/libraries/aws-c-common/default.nix4
-rw-r--r--pkgs/os-specific/linux/kernel-headers/default.nix2
-rw-r--r--pkgs/os-specific/linux/systemd/default.nix8
-rw-r--r--pkgs/stdenv/default.nix6
-rw-r--r--pkgs/stdenv/linux/default.nix14
-rw-r--r--pkgs/top-level/impure.nix4
9 files changed, 77 insertions, 29 deletions
diff --git a/lib/systems/default.nix b/lib/systems/default.nix
index 52b9bd46e60..b45a5fd8d2b 100644
--- a/lib/systems/default.nix
+++ b/lib/systems/default.nix
@@ -72,16 +72,22 @@ rec {
          release = null;
       };
 
+      kernelArch =
+        if final.isAarch32 then "arm"
+        else if final.isAarch64 then "arm64"
+        else if final.isx86_32 then "x86"
+        else if final.isx86_64 then "ia64"
+        else final.parsed.cpu.name;
+
       qemuArch =
         if final.isArm then "arm"
         else if final.isx86_64 then "x86_64"
         else if final.isx86 then "i386"
         else {
           "powerpc" = "ppc";
+          "powerpcle" = "ppc";
           "powerpc64" = "ppc64";
-          "powerpc64le" = "ppc64";
-          "mips64" = "mips";
-          "mipsel64" = "mipsel";
+          "powerpc64le" = "ppc64le";
         }.${final.parsed.cpu.name} or final.parsed.cpu.name;
 
       emulator = pkgs: let
@@ -103,7 +109,7 @@ rec {
       in
         if final.parsed.kernel.name == pkgs.stdenv.hostPlatform.parsed.kernel.name &&
            pkgs.stdenv.hostPlatform.isCompatible final
-        then "${pkgs.runtimeShell} -c"
+        then "${pkgs.runtimeShell} -c '\"$@\"' --"
         else if final.isWindows
         then "${wine}/bin/${wine-name}"
         else if final.isLinux && pkgs.stdenv.hostPlatform.isLinux
diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix
index 8cc7d3ae271..3e23a721f0d 100644
--- a/lib/systems/parse.nix
+++ b/lib/systems/parse.nix
@@ -127,22 +127,42 @@ rec {
     (b == i386 && isCompatible a i486)
     (b == i486 && isCompatible a i586)
     (b == i586 && isCompatible a i686)
-    # NOTE: Not true in some cases. Like in WSL mode.
+
+    # XXX: Not true in some cases. Like in WSL mode.
     (b == i686 && isCompatible a x86_64)
 
-    # ARM
+    # ARMv4
     (b == arm && isCompatible a armv5tel)
-    (b == armv5tel && isCompatible a armv6m)
-    (b == armv6m && isCompatible a armv6l)
-    (b == armv6l && isCompatible a armv7a)
-    (b == armv7a && isCompatible a armv7r)
-    (b == armv7r && isCompatible a armv7m)
-    (b == armv7m && isCompatible a armv7l)
-    (b == armv7l && isCompatible a armv8a)
-    (b == armv8a && isCompatible a armv8r)
-    (b == armv8r && isCompatible a armv8m)
-    # NOTE: not always true! Some arm64 cpus don’t support arm32 mode.
-    (b == armv8m && isCompatible a aarch64)
+
+    # ARMv5
+    (b == armv5tel && isCompatible a armv6l)
+
+    # ARMv6
+    (b == armv6l && isCompatible a armv6m)
+    (b == armv6m && isCompatible a armv7l)
+
+    # ARMv7
+    (b == armv7l && isCompatible a armv7a)
+    (b == armv7l && isCompatible a armv7r)
+    (b == armv7l && isCompatible a armv7m)
+    (b == armv7a && isCompatible a armv8a)
+    (b == armv7r && isCompatible a armv8a)
+    (b == armv7m && isCompatible a armv8a)
+    (b == armv7a && isCompatible a armv8r)
+    (b == armv7r && isCompatible a armv8r)
+    (b == armv7m && isCompatible a armv8r)
+    (b == armv7a && isCompatible a armv8m)
+    (b == armv7r && isCompatible a armv8m)
+    (b == armv7m && isCompatible a armv8m)
+
+    # ARMv8
+    (b == armv8r && isCompatible a armv8a)
+    (b == armv8m && isCompatible a armv8a)
+
+    # XXX: not always true! Some arm64 cpus don’t support arm32 mode.
+    (b == aarch64 && a == armv8a)
+    (b == armv8a && isCompatible a aarch64)
+
     (b == aarch64 && a == aarch64_be)
     (b == aarch64_be && isCompatible a aarch64)
 
diff --git a/pkgs/development/interpreters/spidermonkey/52.nix b/pkgs/development/interpreters/spidermonkey/52.nix
index 1d7a11df5a4..feac99b2d8e 100644
--- a/pkgs/development/interpreters/spidermonkey/52.nix
+++ b/pkgs/development/interpreters/spidermonkey/52.nix
@@ -31,7 +31,7 @@ in stdenv.mkDerivation rec {
     })
   ];
 
-  configurePlatforms = [ "host" "target" ];
+  configurePlatforms = [ ];
 
   preConfigure = ''
     export CXXFLAGS="-fpermissive"
@@ -51,7 +51,11 @@ in stdenv.mkDerivation rec {
     "--with-intl-api"
     "--enable-readline"
     "--enable-shared-js"
-  ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-jemalloc";
+  ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-jemalloc"
+    ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+    "--host=${stdenv.buildPlatform.config}"
+    "--target=${stdenv.hostPlatform.config}"
+  ];
 
   makeFlags = [
     "HOST_CC=${buildPackages.stdenv.cc}/bin/cc"
diff --git a/pkgs/development/libraries/aws-c-common/default.nix b/pkgs/development/libraries/aws-c-common/default.nix
index 682a74593fd..5404c0a1fdf 100644
--- a/pkgs/development/libraries/aws-c-common/default.nix
+++ b/pkgs/development/libraries/aws-c-common/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchFromGitHub, cmake }:
+{ lib, stdenv, fetchFromGitHub, cmake, libexecinfo }:
 
 stdenv.mkDerivation rec {
   pname = "aws-c-common";
@@ -13,6 +13,8 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake ];
 
+  buildInputs = lib.optional stdenv.hostPlatform.isMusl libexecinfo;
+
   NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [
     "-Wno-nullability-extension"
     "-Wno-typedef-redefinition"
diff --git a/pkgs/os-specific/linux/kernel-headers/default.nix b/pkgs/os-specific/linux/kernel-headers/default.nix
index c00fc1761d5..ea4e041d43a 100644
--- a/pkgs/os-specific/linux/kernel-headers/default.nix
+++ b/pkgs/os-specific/linux/kernel-headers/default.nix
@@ -12,7 +12,7 @@ let
       inherit sha256;
     };
 
-    ARCH = stdenvNoCC.hostPlatform.platform.kernelArch or (throw "missing kernelArch");
+    ARCH = stdenvNoCC.hostPlatform.platform.kernelArch or stdenvNoCC.hostPlatform.kernelArch;
 
     # It may look odd that we use `stdenvNoCC`, and yet explicit depend on a cc.
     # We do this so we have a build->build, not build->host, C compiler.
diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix
index d54972c055b..bc071d21ce4 100644
--- a/pkgs/os-specific/linux/systemd/default.nix
+++ b/pkgs/os-specific/linux/systemd/default.nix
@@ -129,12 +129,12 @@ in stdenv.mkDerivation rec {
       test -e $i
       substituteInPlace $i \
         --replace /usr/bin/getent ${getent}/bin/getent \
-        --replace /sbin/swapon ${utillinux.bin}/sbin/swapon \
-        --replace /sbin/swapoff ${utillinux.bin}/sbin/swapoff \
-        --replace /sbin/fsck ${utillinux.bin}/sbin/fsck \
+        --replace /sbin/swapon ${lib.getBin utillinux}/sbin/swapon \
+        --replace /sbin/swapoff ${lib.getBin utillinux}/sbin/swapoff \
+        --replace /sbin/fsck ${lib.getBin utillinux}/sbin/fsck \
         --replace /bin/echo ${coreutils}/bin/echo \
         --replace /bin/cat ${coreutils}/bin/cat \
-        --replace /sbin/sulogin ${utillinux.bin}/sbin/sulogin \
+        --replace /sbin/sulogin ${lib.getBin utillinux}/sbin/sulogin \
         --replace /usr/lib/systemd/systemd-fsck $out/lib/systemd/systemd-fsck \
         --replace /bin/plymouth /run/current-system/sw/bin/plymouth # To avoid dependency
     done
diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix
index 4313a617f78..1f752f02152 100644
--- a/pkgs/stdenv/default.nix
+++ b/pkgs/stdenv/default.nix
@@ -43,8 +43,14 @@ in
     "x86_64-linux" = stagesLinux;
     "armv5tel-linux" = stagesLinux;
     "armv6l-linux" = stagesLinux;
+    "armv6m-linux" = stagesLinux;
     "armv7a-linux" = stagesLinux;
     "armv7l-linux" = stagesLinux;
+    "armv7r-linux" = stagesLinux;
+    "armv7m-linux" = stagesLinux;
+    "armv8a-linux" = stagesLinux;
+    "armv8r-linux" = stagesLinux;
+    "armv8m-linux" = stagesLinux;
     "aarch64-linux" = stagesLinux;
     "mipsel-linux" = stagesLinux;
     "powerpc-linux" = /* stagesLinux */ stagesNative;
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index 457e1671e26..2bccd620436 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -13,7 +13,6 @@
       "x86_64-linux" = import ./bootstrap-files/x86_64.nix;
       "armv5tel-linux" = import ./bootstrap-files/armv5tel.nix;
       "armv6l-linux" = import ./bootstrap-files/armv6l.nix;
-      "armv7a-linux" = import ./bootstrap-files/armv7l.nix;
       "armv7l-linux" = import ./bootstrap-files/armv7l.nix;
       "aarch64-linux" = import ./bootstrap-files/aarch64.nix;
       "mipsel-linux" = import ./bootstrap-files/loongson2f.nix;
@@ -26,10 +25,19 @@
       "powerpc64le-linux" = import ./bootstrap-files/ppc64le-musl.nix;
     };
   };
+
+  # Try to find an architecture compatible with our current system. We
+  # just try every bootstrap we’ve got and test to see if it is
+  # compatible with or current architecture.
+  getCompatibleTools = lib.foldl (v: system:
+    if v != null then v
+    else if localSystem.isCompatible (lib.systems.elaborate { inherit system; }) then archLookupTable.${system}
+    else null) null (lib.attrNames archLookupTable);
+
   archLookupTable = table.${localSystem.libc}
     or (abort "unsupported libc for the pure Linux stdenv");
-  files = archLookupTable.${localSystem.system}
-    or (abort "unsupported platform for the pure Linux stdenv");
+  files = archLookupTable.${localSystem.system} or (if getCompatibleTools != null then getCompatibleTools
+    else (abort "unsupported platform for the pure Linux stdenv"));
   in files
 }:
 
diff --git a/pkgs/top-level/impure.nix b/pkgs/top-level/impure.nix
index b0532ceb5db..da288f15d2e 100644
--- a/pkgs/top-level/impure.nix
+++ b/pkgs/top-level/impure.nix
@@ -72,6 +72,8 @@ in
         else overlays homeOverlaysDir
       else []
 
+, crossOverlays ? []
+
 , ...
 } @ args:
 
@@ -80,7 +82,7 @@ in
 assert args ? localSystem -> !(args ? system || args ? platform);
 
 import ./. (builtins.removeAttrs args [ "system" "platform" ] // {
-  inherit config overlays crossSystem;
+  inherit config overlays crossSystem crossOverlays;
   # Fallback: Assume we are building packages on the current (build, in GNU
   # Autotools parlance) system.
   localSystem = (if args ? localSystem then {}