summary refs log tree commit diff
path: root/pkgs/stdenv/darwin
diff options
context:
space:
mode:
authorAndrew Childs <lorne@cons.org.nz>2020-07-31 23:03:51 +0900
committerAndrew Childs <lorne@cons.org.nz>2020-11-09 19:59:49 +0900
commit86ee107a15ac7197380d5b44697cd2b3af00bf2f (patch)
treec0047bd7a8b2cae46d4c0daab175e8dcfcb5383a /pkgs/stdenv/darwin
parent7f1a82d4761ecced506035ee175160c2f3b5fe39 (diff)
downloadnixpkgs-86ee107a15ac7197380d5b44697cd2b3af00bf2f.tar
nixpkgs-86ee107a15ac7197380d5b44697cd2b3af00bf2f.tar.gz
nixpkgs-86ee107a15ac7197380d5b44697cd2b3af00bf2f.tar.bz2
nixpkgs-86ee107a15ac7197380d5b44697cd2b3af00bf2f.tar.lz
nixpkgs-86ee107a15ac7197380d5b44697cd2b3af00bf2f.tar.xz
nixpkgs-86ee107a15ac7197380d5b44697cd2b3af00bf2f.tar.zst
nixpkgs-86ee107a15ac7197380d5b44697cd2b3af00bf2f.zip
darwin/stdenv: assemble full clang toolchain
Adapted from main expression for clang 7.
Diffstat (limited to 'pkgs/stdenv/darwin')
-rw-r--r--pkgs/stdenv/darwin/default.nix48
1 files changed, 42 insertions, 6 deletions
diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix
index 5540216b0d8..5386213f2ad 100644
--- a/pkgs/stdenv/darwin/default.nix
+++ b/pkgs/stdenv/darwin/default.nix
@@ -24,6 +24,8 @@ assert crossSystem == localSystem;
 let
   inherit (localSystem) system platform;
 
+  bootstrapClangVersion = "7.1.0";
+
   commonImpureHostDeps = [
     "/bin/sh"
     "/usr/lib/libSystem.B.dylib"
@@ -90,7 +92,18 @@ in rec {
         inherit shell;
         inherit (last) stdenvNoCC;
 
-        extraPackages = [];
+        extraPackages = [
+          # last.pkgs.llvmPackages_7.libcxxabi # TODO: is this required? if not, why not?
+          last.pkgs.llvmPackages_7.compiler-rt
+        ];
+
+        extraBuildCommands = ''
+          rsrc="$out/resource-root"
+          mkdir "$rsrc"
+          ln -s "${bootstrapTools}/lib/clang/${bootstrapClangVersion}/include" "$rsrc"
+          ln -s "${last.pkgs.llvmPackages_7.compiler-rt.out}/lib" "$rsrc/lib"
+          echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
+        '';
 
         nativeTools  = false;
         nativeLibc   = false;
@@ -180,6 +193,15 @@ in rec {
             ln -s ${bootstrapTools}/lib/libc++abi.dylib $out/lib/libc++abi.dylib
           '';
         };
+
+        compiler-rt = stdenv.mkDerivation {
+          name = "bootstrap-stage0-compiler-rt";
+          buildCommand = ''
+            mkdir -p $out/lib
+            ln -s ${bootstrapTools}/lib/libclang_rt* $out/lib
+            ln -s ${bootstrapTools}/lib/darwin       $out/lib/darwin
+          '';
+        };
       };
     };
 
@@ -195,6 +217,12 @@ in rec {
       python3 = super.python3Minimal;
 
       ninja = super.ninja.override { buildDocs = false; };
+
+      llvmPackages_7 = super.llvmPackages_7 // (let
+        libraries = super.llvmPackages_7.libraries.extend (_: _: {
+          inherit (llvmPackages_7) compiler-rt;
+        });
+      in { inherit libraries; } // libraries);
     };
   in with prevStage; stageFun 1 prevStage {
     extraPreHook = "export NIX_CFLAGS_COMPILE+=\" -F${bootstrapTools}/Library/Frameworks\"";
@@ -203,7 +231,9 @@ in rec {
     libcxx = pkgs.libcxx;
 
     allowedRequisites =
-      [ bootstrapTools ] ++ (with pkgs; [ libcxx libcxxabi ]) ++ [ pkgs.darwin.Libsystem ];
+      [ bootstrapTools ] ++
+      (with pkgs; [ libcxx libcxxabi llvmPackages_7.compiler-rt ]) ++
+      (with pkgs.darwin; [ Libsystem ]);
 
     overrides = persistent;
   };
@@ -217,6 +247,12 @@ in rec {
         findfreetype libssh curl cmake autoconf automake libtool ed cpio coreutils
         libssh2 nghttp2 libkrb5 ninja;
 
+      llvmPackages_7 = super.llvmPackages_7 // (let
+        libraries = super.llvmPackages_7.libraries.extend (_: _: {
+          inherit (llvmPackages_7) compiler-rt;
+        });
+      in { inherit libraries; } // libraries);
+
       darwin = super.darwin // {
         inherit (darwin)
           dyld Libsystem xnu configd ICU libdispatch libclosure launchd CF;
@@ -234,8 +270,8 @@ in rec {
     allowedRequisites =
       [ bootstrapTools ] ++
       (with pkgs; [
-        xz.bin xz.out libcxx libcxxabi zlib libxml2.out curl.out openssl.out libssh2.out
-        nghttp2.lib libkrb5
+        xz.bin xz.out libcxx libcxxabi llvmPackages_7.compiler-rt zlib
+        libxml2.out curl.out openssl.out libssh2.out nghttp2.lib libkrb5
       ]) ++
       (with pkgs.darwin; [ dyld Libsystem CF ICU locale ]);
 
@@ -284,8 +320,8 @@ in rec {
     allowedRequisites =
       [ bootstrapTools ] ++
       (with pkgs; [
-        xz.bin xz.out bash libcxx libcxxabi zlib libxml2.out curl.out openssl.out libssh2.out
-        nghttp2.lib libkrb5
+        xz.bin xz.out bash libcxx libcxxabi llvmPackages_7.compiler-rt zlib
+        libxml2.out curl.out openssl.out libssh2.out nghttp2.lib libkrb5
       ]) ++
       (with pkgs.darwin; [ dyld ICU Libsystem locale ]);