diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libsystem/reexported_libraries b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/reexported_libraries deleted file mode 100644 index edc2e759a29e..000000000000 --- a/pkgs/os-specific/darwin/apple-source-releases/Libsystem/reexported_libraries +++ /dev/null @@ -1,41 +0,0 @@ -# These are generated with otool -L /usr/lib/libSystem.dylib on a 10.11 machine -/usr/lib/system/libcache.dylib -/usr/lib/system/libcommonCrypto.dylib -/usr/lib/system/libcompiler_rt.dylib -/usr/lib/system/libcopyfile.dylib -/usr/lib/system/libcorecrypto.dylib -/usr/lib/system/libdispatch.dylib -/usr/lib/system/libdyld.dylib -/usr/lib/system/libkeymgr.dylib -/usr/lib/system/liblaunch.dylib -/usr/lib/system/libmacho.dylib -/usr/lib/system/libquarantine.dylib -/usr/lib/system/libremovefile.dylib -/usr/lib/system/libsystem_asl.dylib -/usr/lib/system/libsystem_blocks.dylib - -# We handle this specially in the expression -# /usr/lib/system/libsystem_c.dylib - -/usr/lib/system/libsystem_configuration.dylib -/usr/lib/system/libsystem_coreservices.dylib -# /usr/lib/system/libsystem_coretls.dylib # Removed in 10.13 -/usr/lib/system/libsystem_dnssd.dylib -/usr/lib/system/libsystem_info.dylib - -# We handle this specially in the expression -# /usr/lib/system/libsystem_kernel.dylib - -/usr/lib/system/libsystem_m.dylib -/usr/lib/system/libsystem_malloc.dylib -# /usr/lib/system/libsystem_network.dylib # Removed in 10.14 -/usr/lib/system/libsystem_networkextension.dylib -/usr/lib/system/libsystem_notify.dylib -/usr/lib/system/libsystem_platform.dylib -/usr/lib/system/libsystem_pthread.dylib -/usr/lib/system/libsystem_sandbox.dylib -/usr/lib/system/libsystem_secinit.dylib -/usr/lib/system/libsystem_trace.dylib -/usr/lib/system/libunc.dylib -/usr/lib/system/libunwind.dylib -/usr/lib/system/libxpc.dylib diff --git a/pkgs/os-specific/darwin/darwin-stubs/default.nix b/pkgs/os-specific/darwin/darwin-stubs/default.nix index f7f083e32f43..aa946eb5bf0a 100644 --- a/pkgs/os-specific/darwin/darwin-stubs/default.nix +++ b/pkgs/os-specific/darwin/darwin-stubs/default.nix @@ -1,20 +1,18 @@ -{ stdenv, fetchFromGitHub }: +{ stdenv, fetchurl }: stdenv.mkDerivation { pname = "darwin-stubs"; version = "10.12"; - src = fetchFromGitHub { - owner = "NixOS"; - repo = "darwin-stubs"; - rev = "80b3d4a57d3454c975eefd984c804dbd76f04ef2"; - sha256 = "0sslg4rmskms8ixixv1gvnrvvvmn723vbfjj6mcn24fj2ncg38y7"; + src = fetchurl { + url = "https://github.com/NixOS/darwin-stubs/releases/download/v20201216/10.12.tar.gz"; + sha256 = "1fyd3xig7brkzlzp0ql7vyfj5sp8iy56kgp548mvicqdyw92adgm"; }; dontBuild = true; installPhase = '' mkdir $out - cp -vr stubs/$version/* $out + mv * $out ''; } diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index f07b1ee73b87..ecec2903b5f7 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -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 ]); diff --git a/pkgs/stdenv/darwin/make-bootstrap-tools.nix b/pkgs/stdenv/darwin/make-bootstrap-tools.nix index 1243b96e5051..9824d57dff86 100644 --- a/pkgs/stdenv/darwin/make-bootstrap-tools.nix +++ b/pkgs/stdenv/darwin/make-bootstrap-tools.nix @@ -180,9 +180,6 @@ in rec { unpack = stdenv.mkDerivation (bootstrapFiles // { name = "unpack"; - reexportedLibrariesFile = - ../../os-specific/darwin/apple-source-releases/Libsystem/reexported_libraries; - # This is by necessity a near-duplicate of unpack-bootstrap-tools.sh. If we refer to it directly, # we can't make any changes to it due to our testing stdenv depending on it. Think of this as the # unpack-bootstrap-tools.sh for the next round of bootstrap tools. diff --git a/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh b/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh index 0da80ec5ce56..37beeaf28f94 100644 --- a/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh +++ b/pkgs/stdenv/darwin/unpack-bootstrap-tools.sh @@ -17,41 +17,6 @@ for i in $out/bin/*; do fi done -install_name_tool \ - -id $out/lib/system/libsystem_c.dylib \ - $out/lib/system/libsystem_c.dylib - -install_name_tool \ - -id $out/lib/system/libsystem_kernel.dylib \ - $out/lib/system/libsystem_kernel.dylib - -# TODO: this logic basically duplicates similar logic in the Libsystem expression. Deduplicate them! -libs=$(cat $reexportedLibrariesFile | grep -v '^#') - -for i in $libs; do - if [ "$i" != "/usr/lib/system/libsystem_kernel.dylib" ] && [ "$i" != "/usr/lib/system/libsystem_c.dylib" ]; then - args="$args -reexport_library $i" - fi -done - -ld -macosx_version_min 10.7 \ - -arch x86_64 \ - -dylib \ - -o $out/lib/libSystem.B.dylib \ - -compatibility_version 1.0 \ - -current_version 1226.10.1 \ - -reexport_library $out/lib/system/libsystem_c.dylib \ - -reexport_library $out/lib/system/libsystem_kernel.dylib \ - $args - -ln -s libSystem.B.dylib $out/lib/libSystem.dylib - -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.dylib $out/lib/lib$name.dylib -done - -ln -s libresolv.9.dylib $out/lib/libresolv.dylib - for i in $out/lib/*.dylib $out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation; do if test ! -L "$i" -a "$i" != "$out/lib/libSystem*.dylib"; then echo "Patching $i"