darwin/stdenv: tapi stub based bootstrap

Fixes bootstrapping on macOS Big Sur.
This commit is contained in:
Andrew Childs
2020-12-22 11:43:54 +09:00
parent 55868ac425
commit 34c8fae439
5 changed files with 61 additions and 100 deletions
+56 -14
View File
@@ -54,8 +54,6 @@ in rec {
args = [ ./unpack-bootstrap-tools.sh ];
inherit (bootstrapFiles) mkdir bzip2 cpio tarball;
reexportedLibrariesFile =
../../os-specific/darwin/apple-source-releases/Libsystem/reexported_libraries;
__impureHostDeps = commonImpureHostDeps;
};
@@ -167,19 +165,57 @@ in rec {
stage0 = stageFun 0 null {
overrides = self: super: with stage0; {
coreutils = { name = "bootstrap-stage0-coreutils"; outPath = bootstrapTools; };
gnugrep = { name = "bootstrap-stage0-gnugrep"; outPath = bootstrapTools; };
coreutils = stdenv.mkDerivation {
name = "bootstrap-stage0-coreutils";
buildCommand = ''
mkdir -p $out
ln -s ${bootstrapTools}/bin $out/bin
'';
};
gnugrep = stdenv.mkDerivation {
name = "bootstrap-stage0-gnugrep";
buildCommand = ''
mkdir -p $out
ln -s ${bootstrapTools}/bin $out/bin
'';
};
darwin = super.darwin // {
Libsystem = stdenv.mkDerivation {
name = "bootstrap-stage0-Libsystem";
buildCommand = ''
mkdir -p $out
ln -s ${bootstrapTools}/lib $out/lib
cp -r ${self.darwin.darwin-stubs}/usr/lib $out/lib
chmod -R +w $out/lib
substituteInPlace $out/lib/libSystem.B.tbd --replace /usr/lib/system $out/lib/system
ln -s libSystem.B.tbd $out/lib/libSystem.tbd
for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.10.4 gcc_s.10.5; do
ln -s libSystem.tbd $out/lib/lib$name.tbd
done
ln -s ${bootstrapTools}/lib/*.o $out/lib
ln -s ${bootstrapTools}/lib/libresolv.9.dylib $out/lib
ln -s libresolv.9.dylib $out/lib/libresolv.dylib
ln -s ${bootstrapTools}/include-Libsystem $out/include
'';
};
dyld = bootstrapTools;
darwin-stubs = super.darwin.darwin-stubs.override { inherit (self) stdenv fetchurl; };
dyld = {
name = "bootstrap-stage0-dyld";
buildCommand = ''
mkdir -p $out
ln -s ${bootstrapTools}/lib $out/lib
ln -s ${bootstrapTools}/include $out/include
'';
};
binutils = lib.makeOverridable (import ../../build-support/bintools-wrapper) {
shell = "${bootstrapTools}/bin/bash";
@@ -194,10 +230,15 @@ in rec {
};
llvmPackages_7 = {
clang-unwrapped = {
clang-unwrapped = stdenv.mkDerivation {
name = "bootstrap-stage0-clang";
outPath = bootstrapTools;
version = bootstrapClangVersion;
buildCommand = ''
mkdir -p $out/lib
ln -s ${bootstrapTools}/bin $out/bin
ln -s ${bootstrapTools}/lib/clang $out/lib/clang
ln -s ${bootstrapTools}/include $out/include
'';
};
libcxx = stdenv.mkDerivation {
@@ -256,6 +297,7 @@ in rec {
darwin = super.darwin // {
binutils = darwin.binutils.override {
coreutils = self.coreutils;
libc = self.darwin.Libsystem;
};
};
@@ -268,8 +310,8 @@ in rec {
allowedRequisites =
[ bootstrapTools ] ++
(with pkgs; [ libcxx libcxxabi llvmPackages_7.compiler-rt ]) ++
(with pkgs.darwin; [ Libsystem ]);
(with pkgs; [ coreutils gnugrep libcxx libcxxabi llvmPackages_7.clang-unwrapped llvmPackages_7.compiler-rt ]) ++
(with pkgs.darwin; [ darwin-stubs Libsystem ]);
overrides = persistent;
};
@@ -318,8 +360,8 @@ in rec {
[ bootstrapTools ] ++
(with pkgs; [
xz.bin xz.out libcxx libcxxabi llvmPackages_7.compiler-rt
zlib libxml2.out curl.out openssl.out libssh2.out
nghttp2.lib libkrb5 coreutils gnugrep pcre.out gmp libiconv
llvmPackages_7.clang-unwrapped zlib libxml2.out curl.out openssl.out
libssh2.out nghttp2.lib libkrb5 coreutils gnugrep pcre.out gmp libiconv
]) ++
(with pkgs.darwin; [ dyld Libsystem CF ICU locale ]);
@@ -370,8 +412,8 @@ in rec {
[ bootstrapTools ] ++
(with pkgs; [
xz.bin xz.out bash libcxx libcxxabi llvmPackages_7.compiler-rt
zlib libxml2.out curl.out openssl.out libssh2.out
nghttp2.lib libkrb5 coreutils gnugrep pcre.out gmp libiconv
llvmPackages_7.clang-unwrapped zlib libxml2.out curl.out openssl.out
libssh2.out nghttp2.lib libkrb5 coreutils gnugrep pcre.out gmp libiconv
]) ++
(with pkgs.darwin; [ dyld ICU Libsystem locale ]);