nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix

darwin/stdenv: tapi stub based bootstrap

Fixes bootstrapping on macOS Big Sur.

+61 -100
-41
pkgs/os-specific/darwin/apple-source-releases/Libsystem/reexported_libraries
··· 1 - # These are generated with otool -L /usr/lib/libSystem.dylib on a 10.11 machine 2 - /usr/lib/system/libcache.dylib 3 - /usr/lib/system/libcommonCrypto.dylib 4 - /usr/lib/system/libcompiler_rt.dylib 5 - /usr/lib/system/libcopyfile.dylib 6 - /usr/lib/system/libcorecrypto.dylib 7 - /usr/lib/system/libdispatch.dylib 8 - /usr/lib/system/libdyld.dylib 9 - /usr/lib/system/libkeymgr.dylib 10 - /usr/lib/system/liblaunch.dylib 11 - /usr/lib/system/libmacho.dylib 12 - /usr/lib/system/libquarantine.dylib 13 - /usr/lib/system/libremovefile.dylib 14 - /usr/lib/system/libsystem_asl.dylib 15 - /usr/lib/system/libsystem_blocks.dylib 16 - 17 - # We handle this specially in the expression 18 - # /usr/lib/system/libsystem_c.dylib 19 - 20 - /usr/lib/system/libsystem_configuration.dylib 21 - /usr/lib/system/libsystem_coreservices.dylib 22 - # /usr/lib/system/libsystem_coretls.dylib # Removed in 10.13 23 - /usr/lib/system/libsystem_dnssd.dylib 24 - /usr/lib/system/libsystem_info.dylib 25 - 26 - # We handle this specially in the expression 27 - # /usr/lib/system/libsystem_kernel.dylib 28 - 29 - /usr/lib/system/libsystem_m.dylib 30 - /usr/lib/system/libsystem_malloc.dylib 31 - # /usr/lib/system/libsystem_network.dylib # Removed in 10.14 32 - /usr/lib/system/libsystem_networkextension.dylib 33 - /usr/lib/system/libsystem_notify.dylib 34 - /usr/lib/system/libsystem_platform.dylib 35 - /usr/lib/system/libsystem_pthread.dylib 36 - /usr/lib/system/libsystem_sandbox.dylib 37 - /usr/lib/system/libsystem_secinit.dylib 38 - /usr/lib/system/libsystem_trace.dylib 39 - /usr/lib/system/libunc.dylib 40 - /usr/lib/system/libunwind.dylib 41 - /usr/lib/system/libxpc.dylib
+5 -7
pkgs/os-specific/darwin/darwin-stubs/default.nix
··· 1 - { stdenv, fetchFromGitHub }: 1 + { stdenv, fetchurl }: 2 2 3 3 stdenv.mkDerivation { 4 4 pname = "darwin-stubs"; 5 5 version = "10.12"; 6 6 7 - src = fetchFromGitHub { 8 - owner = "NixOS"; 9 - repo = "darwin-stubs"; 10 - rev = "80b3d4a57d3454c975eefd984c804dbd76f04ef2"; 11 - sha256 = "0sslg4rmskms8ixixv1gvnrvvvmn723vbfjj6mcn24fj2ncg38y7"; 7 + src = fetchurl { 8 + url = "https://github.com/NixOS/darwin-stubs/releases/download/v20201216/10.12.tar.gz"; 9 + sha256 = "1fyd3xig7brkzlzp0ql7vyfj5sp8iy56kgp548mvicqdyw92adgm"; 12 10 }; 13 11 14 12 dontBuild = true; 15 13 16 14 installPhase = '' 17 15 mkdir $out 18 - cp -vr stubs/$version/* $out 16 + mv * $out 19 17 ''; 20 18 }
+56 -14
pkgs/stdenv/darwin/default.nix
··· 54 54 args = [ ./unpack-bootstrap-tools.sh ]; 55 55 56 56 inherit (bootstrapFiles) mkdir bzip2 cpio tarball; 57 - reexportedLibrariesFile = 58 - ../../os-specific/darwin/apple-source-releases/Libsystem/reexported_libraries; 59 57 60 58 __impureHostDeps = commonImpureHostDeps; 61 59 }; ··· 165 167 166 168 stage0 = stageFun 0 null { 167 169 overrides = self: super: with stage0; { 168 - coreutils = { name = "bootstrap-stage0-coreutils"; outPath = bootstrapTools; }; 169 - gnugrep = { name = "bootstrap-stage0-gnugrep"; outPath = bootstrapTools; }; 170 + coreutils = stdenv.mkDerivation { 171 + name = "bootstrap-stage0-coreutils"; 172 + buildCommand = '' 173 + mkdir -p $out 174 + ln -s ${bootstrapTools}/bin $out/bin 175 + ''; 176 + }; 177 + 178 + gnugrep = stdenv.mkDerivation { 179 + name = "bootstrap-stage0-gnugrep"; 180 + buildCommand = '' 181 + mkdir -p $out 182 + ln -s ${bootstrapTools}/bin $out/bin 183 + ''; 184 + }; 170 185 171 186 darwin = super.darwin // { 172 187 Libsystem = stdenv.mkDerivation { 173 188 name = "bootstrap-stage0-Libsystem"; 174 189 buildCommand = '' 175 190 mkdir -p $out 176 - ln -s ${bootstrapTools}/lib $out/lib 191 + 192 + cp -r ${self.darwin.darwin-stubs}/usr/lib $out/lib 193 + chmod -R +w $out/lib 194 + substituteInPlace $out/lib/libSystem.B.tbd --replace /usr/lib/system $out/lib/system 195 + 196 + ln -s libSystem.B.tbd $out/lib/libSystem.tbd 197 + 198 + for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.10.4 gcc_s.10.5; do 199 + ln -s libSystem.tbd $out/lib/lib$name.tbd 200 + done 201 + 202 + ln -s ${bootstrapTools}/lib/*.o $out/lib 203 + 204 + ln -s ${bootstrapTools}/lib/libresolv.9.dylib $out/lib 205 + ln -s libresolv.9.dylib $out/lib/libresolv.dylib 206 + 177 207 ln -s ${bootstrapTools}/include-Libsystem $out/include 178 208 ''; 179 209 }; 180 - dyld = bootstrapTools; 210 + 211 + darwin-stubs = super.darwin.darwin-stubs.override { inherit (self) stdenv fetchurl; }; 212 + 213 + dyld = { 214 + name = "bootstrap-stage0-dyld"; 215 + buildCommand = '' 216 + mkdir -p $out 217 + ln -s ${bootstrapTools}/lib $out/lib 218 + ln -s ${bootstrapTools}/include $out/include 219 + ''; 220 + }; 181 221 182 222 binutils = lib.makeOverridable (import ../../build-support/bintools-wrapper) { 183 223 shell = "${bootstrapTools}/bin/bash"; ··· 230 194 }; 231 195 232 196 llvmPackages_7 = { 233 - clang-unwrapped = { 197 + clang-unwrapped = stdenv.mkDerivation { 234 198 name = "bootstrap-stage0-clang"; 235 - outPath = bootstrapTools; 236 199 version = bootstrapClangVersion; 200 + buildCommand = '' 201 + mkdir -p $out/lib 202 + ln -s ${bootstrapTools}/bin $out/bin 203 + ln -s ${bootstrapTools}/lib/clang $out/lib/clang 204 + ln -s ${bootstrapTools}/include $out/include 205 + ''; 237 206 }; 238 207 239 208 libcxx = stdenv.mkDerivation { ··· 297 256 298 257 darwin = super.darwin // { 299 258 binutils = darwin.binutils.override { 259 + coreutils = self.coreutils; 300 260 libc = self.darwin.Libsystem; 301 261 }; 302 262 }; ··· 310 268 311 269 allowedRequisites = 312 270 [ bootstrapTools ] ++ 313 - (with pkgs; [ libcxx libcxxabi llvmPackages_7.compiler-rt ]) ++ 314 - (with pkgs.darwin; [ Libsystem ]); 271 + (with pkgs; [ coreutils gnugrep libcxx libcxxabi llvmPackages_7.clang-unwrapped llvmPackages_7.compiler-rt ]) ++ 272 + (with pkgs.darwin; [ darwin-stubs Libsystem ]); 315 273 316 274 overrides = persistent; 317 275 }; ··· 360 318 [ bootstrapTools ] ++ 361 319 (with pkgs; [ 362 320 xz.bin xz.out libcxx libcxxabi llvmPackages_7.compiler-rt 363 - zlib libxml2.out curl.out openssl.out libssh2.out 364 - nghttp2.lib libkrb5 coreutils gnugrep pcre.out gmp libiconv 321 + llvmPackages_7.clang-unwrapped zlib libxml2.out curl.out openssl.out 322 + libssh2.out nghttp2.lib libkrb5 coreutils gnugrep pcre.out gmp libiconv 365 323 ]) ++ 366 324 (with pkgs.darwin; [ dyld Libsystem CF ICU locale ]); 367 325 ··· 412 370 [ bootstrapTools ] ++ 413 371 (with pkgs; [ 414 372 xz.bin xz.out bash libcxx libcxxabi llvmPackages_7.compiler-rt 415 - zlib libxml2.out curl.out openssl.out libssh2.out 416 - nghttp2.lib libkrb5 coreutils gnugrep pcre.out gmp libiconv 373 + llvmPackages_7.clang-unwrapped zlib libxml2.out curl.out openssl.out 374 + libssh2.out nghttp2.lib libkrb5 coreutils gnugrep pcre.out gmp libiconv 417 375 ]) ++ 418 376 (with pkgs.darwin; [ dyld ICU Libsystem locale ]); 419 377
-3
pkgs/stdenv/darwin/make-bootstrap-tools.nix
··· 180 180 unpack = stdenv.mkDerivation (bootstrapFiles // { 181 181 name = "unpack"; 182 182 183 - reexportedLibrariesFile = 184 - ../../os-specific/darwin/apple-source-releases/Libsystem/reexported_libraries; 185 - 186 183 # This is by necessity a near-duplicate of unpack-bootstrap-tools.sh. If we refer to it directly, 187 184 # we can't make any changes to it due to our testing stdenv depending on it. Think of this as the 188 185 # unpack-bootstrap-tools.sh for the next round of bootstrap tools.
-35
pkgs/stdenv/darwin/unpack-bootstrap-tools.sh
··· 17 17 fi 18 18 done 19 19 20 - install_name_tool \ 21 - -id $out/lib/system/libsystem_c.dylib \ 22 - $out/lib/system/libsystem_c.dylib 23 - 24 - install_name_tool \ 25 - -id $out/lib/system/libsystem_kernel.dylib \ 26 - $out/lib/system/libsystem_kernel.dylib 27 - 28 - # TODO: this logic basically duplicates similar logic in the Libsystem expression. Deduplicate them! 29 - libs=$(cat $reexportedLibrariesFile | grep -v '^#') 30 - 31 - for i in $libs; do 32 - if [ "$i" != "/usr/lib/system/libsystem_kernel.dylib" ] && [ "$i" != "/usr/lib/system/libsystem_c.dylib" ]; then 33 - args="$args -reexport_library $i" 34 - fi 35 - done 36 - 37 - ld -macosx_version_min 10.7 \ 38 - -arch x86_64 \ 39 - -dylib \ 40 - -o $out/lib/libSystem.B.dylib \ 41 - -compatibility_version 1.0 \ 42 - -current_version 1226.10.1 \ 43 - -reexport_library $out/lib/system/libsystem_c.dylib \ 44 - -reexport_library $out/lib/system/libsystem_kernel.dylib \ 45 - $args 46 - 47 - ln -s libSystem.B.dylib $out/lib/libSystem.dylib 48 - 49 - for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.10.4 gcc_s.10.5; do 50 - ln -s libSystem.dylib $out/lib/lib$name.dylib 51 - done 52 - 53 - ln -s libresolv.9.dylib $out/lib/libresolv.dylib 54 - 55 20 for i in $out/lib/*.dylib $out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation; do 56 21 if test ! -L "$i" -a "$i" != "$out/lib/libSystem*.dylib"; then 57 22 echo "Patching $i"