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 gnused, 19 gnutar, 20 gzip, 21 ld64, 22 libffi, 23 libiconv, 24 libxml2, 25 - libyaml, 26 llvmPackages, 27 ncurses, 28 nukeReferences, 29 openssl, 30 patch, 31 pbzx, 32 runCommand, 33 writeText, 34 - xar, 35 xz, 36 zlib, 37 }: ··· 113 114 in 115 '' 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 121 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 chmod -R u+w $out/include 128 cp -rL ${getDev libiconv}/include/* $out/include 129 cp -rL ${getDev gnugrep.pcre2}/include/* $out/include 130 - mv $out/include $out/include-Libsystem 131 132 # Copy binutils. 133 for i in as ld ar ranlib nm strip otool install_name_tool lipo codesign_allocate; do ··· 163 cp ${getBin xz}/bin/xz $out/bin 164 cp -d ${getLib bzip2}/lib/libbz2*.dylib $out/lib 165 cp -d ${getLib gmpxx}/lib/libgmp*.dylib $out/lib 166 - cp -d ${getLib xar}/lib/libxar*.dylib $out/lib 167 cp -d ${getLib xz}/lib/liblzma*.dylib $out/lib 168 cp -d ${getLib zlib}/lib/libz*.dylib $out/lib 169 ··· 185 cp -d ${getLib llvmPackages.llvm}/lib/libLLVM.dylib $out/lib 186 cp -d ${getLib libffi}/lib/libffi*.dylib $out/lib 187 188 - mkdir $out/include 189 cp -rd ${getDev llvmPackages.libcxx}/include/c++ $out/include 190 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 194 195 # copy sigtool 196 cp -d ${getBin darwin.sigtool}/bin/{codesign,sigtool} $out/bin 197 - 198 - cp -d ${getLib darwin.libtapi}/lib/libtapi*.dylib $out/lib 199 200 # tools needed to unpack bootstrap archive 201 mkdir -p unpack/bin unpack/lib
··· 18 gnused, 19 gnutar, 20 gzip, 21 + jq, 22 ld64, 23 libffi, 24 libiconv, 25 + libtapi, 26 libxml2, 27 llvmPackages, 28 ncurses, 29 nukeReferences, 30 + oniguruma, 31 openssl, 32 patch, 33 pbzx, 34 runCommand, 35 writeText, 36 + xarMinimal, 37 xz, 38 zlib, 39 }: ··· 115 116 in 117 '' 118 + mkdir -p $out/bin $out/include $out/lib $out/lib/darwin 119 120 chmod -R u+w $out/include 121 cp -rL ${getDev libiconv}/include/* $out/include 122 cp -rL ${getDev gnugrep.pcre2}/include/* $out/include 123 124 # Copy binutils. 125 for i in as ld ar ranlib nm strip otool install_name_tool lipo codesign_allocate; do ··· 155 cp ${getBin xz}/bin/xz $out/bin 156 cp -d ${getLib bzip2}/lib/libbz2*.dylib $out/lib 157 cp -d ${getLib gmpxx}/lib/libgmp*.dylib $out/lib 158 + cp -d ${getLib xarMinimal}/lib/libxar*.dylib $out/lib 159 cp -d ${getLib xz}/lib/liblzma*.dylib $out/lib 160 cp -d ${getLib zlib}/lib/libz*.dylib $out/lib 161 ··· 177 cp -d ${getLib llvmPackages.llvm}/lib/libLLVM.dylib $out/lib 178 cp -d ${getLib libffi}/lib/libffi*.dylib $out/lib 179 180 cp -rd ${getDev llvmPackages.libcxx}/include/c++ $out/include 181 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 189 190 # copy sigtool 191 cp -d ${getBin darwin.sigtool}/bin/{codesign,sigtool} $out/bin 192 193 # tools needed to unpack bootstrap archive 194 mkdir -p unpack/bin unpack/lib
+9 -27
pkgs/stdenv/darwin/test-bootstrap-tools.nix
··· 1 { 2 lib, 3 stdenv, 4 bootstrapTools, 5 hello, 6 }: ··· 30 mkdir -p $out/bin 31 32 for exe in $tools/bin/*; do 33 - [[ $exe =~ bunzip2|codesign.*|false|install_name_tool|ld|lipo|pbzx|ranlib|rewrite-tbd|sigtool ]] && continue 34 $exe --version > /dev/null || { echo $exe failed >&2; exit 1; } 35 done 36 ··· 44 lipo -info true 45 pbzx -v 46 # ranlib gets tested bulding hello 47 - rewrite-tbd </dev/null 48 sigtool -h 49 rm true 50 ··· 52 # an SSL-capable curl 53 curl --version | grep SSL 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 62 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" 68 69 export CPP="clang -E $flags" 70 export CC="clang $flags" 71 export CXX="clang++ $flags --stdlib=libc++ -isystem$tools/include/c++/v1" 72 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 echo '#include <stdio.h>' >> hello1.c 81 echo '#include <float.h>' >> hello1.c 82 echo '#include <limits.h>' >> hello1.c 83 echo 'int main() { printf("Hello World\n"); return 0; }' >> hello1.c 84 - $CC -o hello1 hello1.c 85 - cp hello1 $out/bin/ 86 $out/bin/hello1 87 88 echo '#include <iostream>' >> hello3.cc 89 echo 'int main() { std::cout << "Hello World\n"; }' >> hello3.cc 90 - $CXX -v -o hello3 hello3.cc 91 - cp hello3 $out/bin/ 92 $out/bin/hello3 93 94 # test that libc++.dylib rpaths are correct so it can reference libc++abi.dylib when linked. 95 # using -Wl,-flat_namespace is required to generate an error 96 mkdir libtest/ 97 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 100 101 tar xvf ${hello.src} 102 cd hello-*
··· 1 { 2 lib, 3 stdenv, 4 + apple-sdk, 5 bootstrapTools, 6 hello, 7 }: ··· 31 mkdir -p $out/bin 32 33 for exe in $tools/bin/*; do 34 + [[ $exe =~ bunzip2|codesign.*|false|install_name_tool|ld|lipo|pbzx|ranlib|sigtool ]] && continue 35 $exe --version > /dev/null || { echo $exe failed >&2; exit 1; } 36 done 37 ··· 45 lipo -info true 46 pbzx -v 47 # ranlib gets tested bulding hello 48 sigtool -h 49 rm true 50 ··· 52 # an SSL-capable curl 53 curl --version | grep SSL 54 55 + # The stdenv bootstrap builds the SDK in the bootstrap. Use an existing SDK to test the tools. 56 + export SDKROOT='${apple-sdk.sdkroot}' 57 58 + export flags="-idirafter $SDKROOT/usr/include --sysroot=$SDKROOT -L$SDKROOT/usr/lib -L$tools/lib -DTARGET_OS_IPHONE=0" 59 60 export CPP="clang -E $flags" 61 export CC="clang $flags" 62 export CXX="clang++ $flags --stdlib=libc++ -isystem$tools/include/c++/v1" 63 64 echo '#include <stdio.h>' >> hello1.c 65 echo '#include <float.h>' >> hello1.c 66 echo '#include <limits.h>' >> hello1.c 67 echo 'int main() { printf("Hello World\n"); return 0; }' >> hello1.c 68 + $CC -o $out/bin/hello1 hello1.c 69 $out/bin/hello1 70 71 echo '#include <iostream>' >> hello3.cc 72 echo 'int main() { std::cout << "Hello World\n"; }' >> hello3.cc 73 + $CXX -v -o $out/bin/hello3 hello3.cc 74 $out/bin/hello3 75 76 # test that libc++.dylib rpaths are correct so it can reference libc++abi.dylib when linked. 77 # using -Wl,-flat_namespace is required to generate an error 78 mkdir libtest/ 79 ln -s $tools/lib/libc++.dylib libtest/ 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 82 83 tar xvf ${hello.src} 84 cd hello-*