Skip to content

Commit 25c16f3

Browse files
stdenv/darwin: assemble full clang toolchain
Adapted from main expression for clang 7.
1 parent 6343fb9 commit 25c16f3

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

pkgs/stdenv/darwin/default.nix

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ assert crossSystem == localSystem;
2424
let
2525
inherit (localSystem) system platform;
2626

27+
bootstrapClangVersion = "7.1.0";
28+
2729
commonImpureHostDeps = [
2830
"/bin/sh"
2931
"/usr/lib/libSystem.B.dylib"
@@ -90,7 +92,18 @@ in rec {
9092
inherit shell;
9193
inherit (last) stdenvNoCC;
9294

93-
extraPackages = [];
95+
extraPackages = [
96+
# last.pkgs.llvmPackages_7.libcxxabi # TODO: is this required? if not, why not?
97+
last.pkgs.llvmPackages_7.compiler-rt
98+
];
99+
100+
extraBuildCommands = ''
101+
rsrc="$out/resource-root"
102+
mkdir "$rsrc"
103+
ln -s "${bootstrapTools}/lib/clang/${bootstrapClangVersion}/include" "$rsrc"
104+
ln -s "${last.pkgs.llvmPackages_7.compiler-rt.out}/lib" "$rsrc/lib"
105+
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
106+
'';
94107

95108
nativeTools = false;
96109
nativeLibc = false;
@@ -180,6 +193,15 @@ in rec {
180193
ln -s ${bootstrapTools}/lib/libc++abi.dylib $out/lib/libc++abi.dylib
181194
'';
182195
};
196+
197+
compiler-rt = stdenv.mkDerivation {
198+
name = "bootstrap-stage0-compiler-rt";
199+
buildCommand = ''
200+
mkdir -p $out/lib
201+
ln -s ${bootstrapTools}/lib/libclang_rt* $out/lib
202+
ln -s ${bootstrapTools}/lib/darwin $out/lib/darwin
203+
'';
204+
};
183205
};
184206
};
185207

@@ -198,6 +220,12 @@ in rec {
198220
python3 = super.python3Minimal;
199221

200222
ninja = super.ninja.override { buildDocs = false; };
223+
224+
llvmPackages_7 = super.llvmPackages_7 // (let
225+
libraries = super.llvmPackages_7.libraries.extend (_: _: {
226+
inherit (llvmPackages_7) compiler-rt;
227+
});
228+
in { inherit libraries; } // libraries);
201229
};
202230
in with prevStage; stageFun 1 prevStage {
203231
extraPreHook = "export NIX_CFLAGS_COMPILE+=\" -F${bootstrapTools}/Library/Frameworks\"";
@@ -206,7 +234,9 @@ in rec {
206234
libcxx = pkgs.libcxx;
207235

208236
allowedRequisites =
209-
[ bootstrapTools ] ++ (with pkgs; [ libcxx libcxxabi ]) ++ [ pkgs.darwin.Libsystem ];
237+
[ bootstrapTools ] ++
238+
(with pkgs; [ libcxx libcxxabi llvmPackages_7.compiler-rt ]) ++
239+
(with pkgs.darwin; [ Libsystem ]);
210240

211241
overrides = persistent;
212242
};
@@ -220,6 +250,12 @@ in rec {
220250
findfreetype libssh curl cmake autoconf automake libtool ed cpio coreutils
221251
libssh2 nghttp2 libkrb5 ninja;
222252

253+
llvmPackages_7 = super.llvmPackages_7 // (let
254+
libraries = super.llvmPackages_7.libraries.extend (_: _: {
255+
inherit (llvmPackages_7) compiler-rt;
256+
});
257+
in { inherit libraries; } // libraries);
258+
223259
darwin = super.darwin // {
224260
inherit (darwin)
225261
dyld Libsystem xnu configd ICU libdispatch libclosure launchd CF;
@@ -237,8 +273,8 @@ in rec {
237273
allowedRequisites =
238274
[ bootstrapTools ] ++
239275
(with pkgs; [
240-
xz.bin xz.out libcxx libcxxabi zlib libxml2.out curl.out openssl.out libssh2.out
241-
nghttp2.lib libkrb5
276+
xz.bin xz.out libcxx libcxxabi llvmPackages_7.compiler-rt zlib
277+
libxml2.out curl.out openssl.out libssh2.out nghttp2.lib libkrb5
242278
]) ++
243279
(with pkgs.darwin; [ dyld Libsystem CF ICU locale ]);
244280

@@ -287,8 +323,8 @@ in rec {
287323
allowedRequisites =
288324
[ bootstrapTools ] ++
289325
(with pkgs; [
290-
xz.bin xz.out bash libcxx libcxxabi zlib libxml2.out curl.out openssl.out libssh2.out
291-
nghttp2.lib libkrb5
326+
xz.bin xz.out bash libcxx libcxxabi llvmPackages_7.compiler-rt zlib
327+
libxml2.out curl.out openssl.out libssh2.out nghttp2.lib libkrb5
292328
]) ++
293329
(with pkgs.darwin; [ dyld ICU Libsystem locale ]);
294330

0 commit comments

Comments
 (0)