diff options
author | John Ericson <git@JohnEricson.me> | 2019-12-30 16:40:43 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-30 16:40:43 -0800 |
commit | cfd013813e97f9bdef009a7d0f891872275e4da2 (patch) | |
tree | 35770778be2b98841be7fac886e182b1ff4de22d /pkgs/stdenv | |
parent | 66bf75415f4e7a1571d41a2fed11838eb530376b (diff) | |
parent | c1fb358a78862c7ffb90f6f7a319935fb73039b4 (diff) |
Merge pull request #74090 from obsidiansystems/ghcjs-cross-without-cc
stdenv, haskell: bonafied GHCJS cross compilation without stdenv.cc
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r-- | pkgs/stdenv/booter.nix | 13 | ||||
-rw-r--r-- | pkgs/stdenv/cross/default.nix | 8 | ||||
-rw-r--r-- | pkgs/stdenv/generic/default.nix | 16 |
3 files changed, 30 insertions, 7 deletions
diff --git a/pkgs/stdenv/booter.nix b/pkgs/stdenv/booter.nix index 1df05099fbf5e..51d617354e869 100644 --- a/pkgs/stdenv/booter.nix +++ b/pkgs/stdenv/booter.nix @@ -121,9 +121,16 @@ 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 + # This will blow up if anything uses it, but that's OK. The `if + # buildPackages.stdenv.cc.isClang then ... else ...` would blow up + # everything, so we make sure to avoid that. + buildPackages.stdenv.cc; }; in dfold folder postStage (_: {}) withAllowCustomOverrides diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix index 4e5c4cc2e8333..cc49af7de3b58 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 compiler provided for this platform" else if crossSystem.useLLVM or false then buildPackages.llvmPackages_8.lldClang else buildPackages.gcc; diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 2f43db9cfc24b..befeb45099732 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -1,6 +1,15 @@ let lib = import ../../../lib; in lib.makeOverridable ( -{ name ? "stdenv", preHook ? "", initialPath, cc, shell +{ name ? "stdenv", preHook ? "", initialPath + +, # If we don't have a C compiler, we might either have `cc = null` or `cc = + # throw ...`, but if we do have a C compiler we should definiely have `cc != + # null`. + # + # TODO(@Ericson2314): Add assert without creating infinite recursion + hasCC ? cc != null, cc + +, shell , allowedRequisites ? null, extraAttrs ? {}, overrides ? (self: super: {}), config , # The `fetchurl' to use for downloading curl and its dependencies @@ -57,7 +66,8 @@ let ../../build-support/setup-hooks/move-sbin.sh ../../build-support/setup-hooks/move-lib64.sh ../../build-support/setup-hooks/set-source-date-epoch-to-latest.sh - cc + # TODO use lib.optional instead + (if hasCC then cc else null) ]; defaultBuildInputs = extraBuildInputs; @@ -145,7 +155,7 @@ let inherit overrides; - inherit cc; + inherit cc hasCC; } # Propagate any extra attributes. For instance, we use this to |