summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2019-11-24 23:07:20 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2019-11-25 00:12:38 +0000
commitc739c420db5b9d56c335414be1696c57f2dbbb6a (patch)
tree448e9e0008592b80fa36e8a7edfee2d62fdcc119 /pkgs/stdenv
parent63bd851e9554cdb1bd703a461443723fd057933d (diff)
downloadnixpkgs-c739c420db5b9d56c335414be1696c57f2dbbb6a.tar
nixpkgs-c739c420db5b9d56c335414be1696c57f2dbbb6a.tar.gz
nixpkgs-c739c420db5b9d56c335414be1696c57f2dbbb6a.tar.bz2
nixpkgs-c739c420db5b9d56c335414be1696c57f2dbbb6a.tar.lz
nixpkgs-c739c420db5b9d56c335414be1696c57f2dbbb6a.tar.xz
nixpkgs-c739c420db5b9d56c335414be1696c57f2dbbb6a.tar.zst
nixpkgs-c739c420db5b9d56c335414be1696c57f2dbbb6a.zip
Add support for cross compiling to `js-ghcjs`
This platform doesn't have a C compiler, and so relies and the changes
in the previous commit to work.
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/booter.nix9
-rw-r--r--pkgs/stdenv/cross/default.nix8
2 files changed, 13 insertions, 4 deletions
diff --git a/pkgs/stdenv/booter.nix b/pkgs/stdenv/booter.nix
index 1df05099fbf..8a574652204 100644
--- a/pkgs/stdenv/booter.nix
+++ b/pkgs/stdenv/booter.nix
@@ -121,9 +121,12 @@ stageFuns: let
   postStage = buildPackages: {
     __raw = true;
     stdenv.cc =
-      if buildPackages.stdenv.cc.isClang or false
-      then buildPackages.clang
-      else buildPackages.gcc;
+      if buildPackages.stdenv.hasCC
+      then
+        if buildPackages.stdenv.cc.isClang or false
+        then buildPackages.clang
+        else buildPackages.gcc
+      else buildPackages.stdenv.cc;
   };
 
 in dfold folder postStage (_: {}) withAllowCustomOverrides
diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix
index 4e5c4cc2e83..44d412e041b 100644
--- a/pkgs/stdenv/cross/default.nix
+++ b/pkgs/stdenv/cross/default.nix
@@ -51,12 +51,18 @@ in lib.init bootStages ++ [
       extraBuildInputs = [ ]; # Old ones run on wrong platform
       allowedRequisites = null;
 
+      hasCC = !targetPlatform.isGhcjs;
+
       cc = if crossSystem.useiOSPrebuilt or false
              then buildPackages.darwin.iosSdkPkgs.clang
            else if crossSystem.useAndroidPrebuilt or false
              then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".clang
            else if targetPlatform.isGhcjs
-             then null
+             # Need to use `throw` so tryEval for splicing works, ugh.  Using
+             # `null` or skipping the attribute would cause an eval failure
+             # `tryEval` wouldn't catch, wrecking accessing previous stages
+             # when there is a C compiler and everything should be fine.
+             then throw "no C compile provided for this platform"
            else if crossSystem.useLLVM or false
              then buildPackages.llvmPackages_8.lldClang
            else buildPackages.gcc;