summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2020-09-30 23:44:18 +0200
committerGitHub <noreply@github.com>2020-09-30 23:44:18 +0200
commit4aabac8d88f2020e7522edcfddd08a0dfcf4b23c (patch)
treef6ec1ce121adde114bb16b5180044054fff30d00 /pkgs
parent4bd0e5603db190620ff49caa328a23e12ebf3682 (diff)
parent0de6275003170cb82e5f9a3bdfb649ff22b8b12a (diff)
Merge pull request #86223 from pikajude/darwin-static-eval
pkgsStatic: use clang for C compiler on Darwin
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/stdenv/adapters.nix4
-rw-r--r--pkgs/stdenv/cross/default.nix2
-rw-r--r--pkgs/top-level/static.nix9
3 files changed, 10 insertions, 5 deletions
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix
index 8b23d3dadd2cc..03ae3cb8f0e83 100644
--- a/pkgs/stdenv/adapters.nix
+++ b/pkgs/stdenv/adapters.nix
@@ -15,7 +15,7 @@ rec {
   # Used to override packages in stdenv like Make.  Should not be used
   # for other dependencies.
   overrideInStdenv = stdenv: pkgs:
-    stdenv.override (prev: { allowedRequisites = null; extraBuildInputs = prev.extraBuildInputs or [] ++ pkgs; });
+    stdenv.override (prev: { allowedRequisites = null; extraBuildInputs = (prev.extraBuildInputs or []) ++ pkgs; });
 
 
   # Override the setup script of stdenv.  Useful for testing new
@@ -34,7 +34,7 @@ rec {
   makeStaticBinaries = stdenv:
     let stdenv' = if stdenv.hostPlatform.libc != "glibc" then stdenv else
       stdenv.override (prev: {
-          extraBuildInputs = prev.extraBuildInputs or [] ++ [
+          extraBuildInputs = (prev.extraBuildInputs or []) ++ [
               stdenv.glibc.static
             ];
         });
diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix
index 6ac03b7908fec..064e1836b17c9 100644
--- a/pkgs/stdenv/cross/default.nix
+++ b/pkgs/stdenv/cross/default.nix
@@ -63,6 +63,8 @@ in lib.init bootStages ++ [
              # `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.isDarwin
+             then buildPackages.llvmPackages.clang
            else if crossSystem.useLLVM or false
              then buildPackages.llvmPackages_8.lldClang
            else buildPackages.gcc;
diff --git a/pkgs/top-level/static.nix b/pkgs/top-level/static.nix
index 4fa5b92e951d0..865e5cf2900eb 100644
--- a/pkgs/top-level/static.nix
+++ b/pkgs/top-level/static.nix
@@ -14,15 +14,18 @@ self: super: let
   inherit (super.stdenvAdapters) makeStaticBinaries
                                  makeStaticLibraries
                                  propagateBuildInputs;
-  inherit (super.lib) foldl optional flip id composeExtensions optionalAttrs;
+  inherit (super.lib) foldl optional flip id composeExtensions optionalAttrs optionalString;
   inherit (super) makeSetupHook;
 
   # Best effort static binaries. Will still be linked to libSystem,
   # but more portable than Nix store binaries.
-  makeStaticDarwin = stdenv: stdenv // {
+  makeStaticDarwin = stdenv_: let stdenv = stdenv_.override {
+    # extraBuildInputs are dropped in cross.nix, but darwin still needs them
+    extraBuildInputs = [ self.buildPackages.darwin.CF ];
+  }; in stdenv // {
     mkDerivation = args: stdenv.mkDerivation (args // {
       NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "")
-                      + " -static-libgcc";
+                      + optionalString stdenv.cc.isGNU " -static-libgcc";
       nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ (makeSetupHook {
         substitutions = {
           libsystem = "${stdenv.cc.libc}/lib/libSystem.B.dylib";