freshBootstrapTools.bootstrapTools: update for new SDK pattern

- Drop libSystem. It’s no longer needed. The SDK can be downloaded and
built with existing tools.
- Add jq and tapi. Adding these allows the stdenv bootstrap to stop
special-casing stage 0.
- Update tests for updated ld64. It handles code-signing properly, so
the signatures aren’t broken.

+22 -47
+13 -20
pkgs/stdenv/darwin/stdenv-bootstrap-tools.nix
··· 18 18 gnused, 19 19 gnutar, 20 20 gzip, 21 + jq, 21 22 ld64, 22 23 libffi, 23 24 libiconv, 25 + libtapi, 24 26 libxml2, 25 - libyaml, 26 27 llvmPackages, 27 28 ncurses, 28 29 nukeReferences, 30 + oniguruma, 29 31 openssl, 30 32 patch, 31 33 pbzx, 32 34 runCommand, 33 35 writeText, 34 - xar, 36 + xarMinimal, 35 37 xz, 36 38 zlib, 37 39 }: ··· 113 115 114 116 in 115 117 '' 116 - mkdir -p $out/bin $out/lib $out/lib/darwin 117 - 118 - ${lib.optionalString stdenv.targetPlatform.isx86_64 '' 119 - # Copy libSystem's .o files for various low-level boot stuff. 120 - cp -d ${getLib darwin.Libsystem}/lib/*.o $out/lib 118 + mkdir -p $out/bin $out/include $out/lib $out/lib/darwin 121 119 122 - # Resolv is actually a link to another package, so let's copy it properly 123 - cp -L ${getLib darwin.Libsystem}/lib/libresolv.9.dylib $out/lib 124 - ''} 125 - 126 - cp -rL ${getDev darwin.Libsystem}/include $out 127 120 chmod -R u+w $out/include 128 121 cp -rL ${getDev libiconv}/include/* $out/include 129 122 cp -rL ${getDev gnugrep.pcre2}/include/* $out/include 130 - mv $out/include $out/include-Libsystem 131 123 132 124 # Copy binutils. 133 125 for i in as ld ar ranlib nm strip otool install_name_tool lipo codesign_allocate; do ··· 163 155 cp ${getBin xz}/bin/xz $out/bin 164 156 cp -d ${getLib bzip2}/lib/libbz2*.dylib $out/lib 165 157 cp -d ${getLib gmpxx}/lib/libgmp*.dylib $out/lib 166 - cp -d ${getLib xar}/lib/libxar*.dylib $out/lib 158 + cp -d ${getLib xarMinimal}/lib/libxar*.dylib $out/lib 167 159 cp -d ${getLib xz}/lib/liblzma*.dylib $out/lib 168 160 cp -d ${getLib zlib}/lib/libz*.dylib $out/lib 169 161 ··· 185 177 cp -d ${getLib llvmPackages.llvm}/lib/libLLVM.dylib $out/lib 186 178 cp -d ${getLib libffi}/lib/libffi*.dylib $out/lib 187 179 188 - mkdir $out/include 189 180 cp -rd ${getDev llvmPackages.libcxx}/include/c++ $out/include 190 181 191 - # copy .tbd assembly utils 192 - cp ${getBin darwin.rewrite-tbd}/bin/rewrite-tbd $out/bin 193 - cp -d ${getLib libyaml}/lib/libyaml*.dylib $out/lib 182 + # Copy tools needed to build the SDK 183 + cp -d ${getBin jq}/bin/* $out/bin 184 + cp -d ${getBin libtapi}/bin/* $out/bin 185 + 186 + cp -d ${getLib jq}/lib/lib*.dylib $out/lib 187 + cp -d ${getLib oniguruma}/lib/lib*.dylib $out/lib 188 + cp -d ${getLib libtapi}/lib/libtapi*.dylib $out/lib 194 189 195 190 # copy sigtool 196 191 cp -d ${getBin darwin.sigtool}/bin/{codesign,sigtool} $out/bin 197 - 198 - cp -d ${getLib darwin.libtapi}/lib/libtapi*.dylib $out/lib 199 192 200 193 # tools needed to unpack bootstrap archive 201 194 mkdir -p unpack/bin unpack/lib
+9 -27
pkgs/stdenv/darwin/test-bootstrap-tools.nix
··· 1 1 { 2 2 lib, 3 3 stdenv, 4 + apple-sdk, 4 5 bootstrapTools, 5 6 hello, 6 7 }: ··· 30 31 mkdir -p $out/bin 31 32 32 33 for exe in $tools/bin/*; do 33 - [[ $exe =~ bunzip2|codesign.*|false|install_name_tool|ld|lipo|pbzx|ranlib|rewrite-tbd|sigtool ]] && continue 34 + [[ $exe =~ bunzip2|codesign.*|false|install_name_tool|ld|lipo|pbzx|ranlib|sigtool ]] && continue 34 35 $exe --version > /dev/null || { echo $exe failed >&2; exit 1; } 35 36 done 36 37 ··· 44 45 lipo -info true 45 46 pbzx -v 46 47 # ranlib gets tested bulding hello 47 - rewrite-tbd </dev/null 48 48 sigtool -h 49 49 rm true 50 50 ··· 52 52 # an SSL-capable curl 53 53 curl --version | grep SSL 54 54 55 - # This approximates a bootstrap version of libSystem can that be 56 - # assembled via fetchurl. Adapted from main libSystem expression. 57 - mkdir libSystem-boot 58 - cp -vr \ 59 - ${stdenv.cc.libc_dev}/lib/libSystem.B.tbd \ 60 - ${stdenv.cc.libc_dev}/lib/system \ 61 - libSystem-boot 55 + # The stdenv bootstrap builds the SDK in the bootstrap. Use an existing SDK to test the tools. 56 + export SDKROOT='${apple-sdk.sdkroot}' 62 57 63 - sed -i "s|/usr/lib/system/|$PWD/libSystem-boot/system/|g" libSystem-boot/libSystem.B.tbd 64 - ln -s libSystem.B.tbd libSystem-boot/libSystem.tbd 65 - # End of bootstrap libSystem 66 - 67 - export flags="-idirafter $tools/include-Libsystem --sysroot=$tools -L$tools/lib -L$PWD/libSystem-boot" 58 + export flags="-idirafter $SDKROOT/usr/include --sysroot=$SDKROOT -L$SDKROOT/usr/lib -L$tools/lib -DTARGET_OS_IPHONE=0" 68 59 69 60 export CPP="clang -E $flags" 70 61 export CC="clang $flags" 71 62 export CXX="clang++ $flags --stdlib=libc++ -isystem$tools/include/c++/v1" 72 63 73 - # NOTE: These tests do a separate 'install' step (using cp), because 74 - # having clang write directly to the final location apparently will make 75 - # running the executable fail signature verification. (SIGKILL'd) 76 - # 77 - # Suspect this is creating a corrupt entry in the kernel cache, but it is 78 - # unique to cctools ld. (The problem goes away with `-fuse-ld=lld`.) 79 - 80 64 echo '#include <stdio.h>' >> hello1.c 81 65 echo '#include <float.h>' >> hello1.c 82 66 echo '#include <limits.h>' >> hello1.c 83 67 echo 'int main() { printf("Hello World\n"); return 0; }' >> hello1.c 84 - $CC -o hello1 hello1.c 85 - cp hello1 $out/bin/ 68 + $CC -o $out/bin/hello1 hello1.c 86 69 $out/bin/hello1 87 70 88 71 echo '#include <iostream>' >> hello3.cc 89 72 echo 'int main() { std::cout << "Hello World\n"; }' >> hello3.cc 90 - $CXX -v -o hello3 hello3.cc 91 - cp hello3 $out/bin/ 73 + $CXX -v -o $out/bin/hello3 hello3.cc 92 74 $out/bin/hello3 93 75 94 76 # test that libc++.dylib rpaths are correct so it can reference libc++abi.dylib when linked. 95 77 # using -Wl,-flat_namespace is required to generate an error 96 78 mkdir libtest/ 97 79 ln -s $tools/lib/libc++.dylib libtest/ 98 - clang++ -Wl,-flat_namespace -idirafter $tools/include-Libsystem -isystem$tools/include/c++/v1 \ 99 - --sysroot=$tools -L./libtest -L$PWD/libSystem-boot hello3.cc 80 + clang++ -Wl,-flat_namespace -idirafter $SDKROOT/usr/include -isystem$tools/include/c++/v1 \ 81 + --sysroot=$SDKROOT -L$SDKROOT/usr/lib -L./libtest -L$PWD/libSystem-boot hello3.cc 100 82 101 83 tar xvf ${hello.src} 102 84 cd hello-*