{ lib, stdenv, bootstrapTools, hello, }: builtins.derivation { name = "test-bootstrap-tools"; inherit (stdenv.hostPlatform) system; builder = "${bootstrapTools}/bin/bash"; args = [ "-euo" "pipefail" "-c" "eval \"$buildCommand\"" ]; PATH = lib.makeBinPath [ bootstrapTools ]; tools = bootstrapTools; "${stdenv.cc.darwinMinVersionVariable}" = stdenv.cc.darwinMinVersion; # Create a pure environment where we use just what's in the bootstrap tools. buildCommand = '' mkdir -p $out/bin for exe in $tools/bin/*; do [[ $exe =~ bunzip2|codesign.*|false|install_name_tool|ld|lipo|pbzx|ranlib|rewrite-tbd|sigtool ]] && continue $exe --version > /dev/null || { echo $exe failed >&2; exit 1; } done # run all exes that don't take a --version flag bunzip2 -h codesign --help codesign_allocate -i $tools/bin/true -r -o true false || (($? == 1)) install_name_tool -id true true ld -v lipo -info true pbzx -v # ranlib gets tested bulding hello rewrite-tbd ' >> hello1.c echo '#include ' >> hello1.c echo '#include ' >> hello1.c echo 'int main() { printf("Hello World\n"); return 0; }' >> hello1.c $CC -o hello1 hello1.c cp hello1 $out/bin/ $out/bin/hello1 echo '#include ' >> hello3.cc echo 'int main() { std::cout << "Hello World\n"; }' >> hello3.cc $CXX -v -o hello3 hello3.cc cp hello3 $out/bin/ $out/bin/hello3 # test that libc++.dylib rpaths are correct so it can reference libc++abi.dylib when linked. # using -Wl,-flat_namespace is required to generate an error mkdir libtest/ ln -s $tools/lib/libc++.dylib libtest/ clang++ -Wl,-flat_namespace -idirafter $tools/include-Libsystem -isystem$tools/include/c++/v1 \ --sysroot=$tools -L./libtest -L$PWD/libSystem-boot hello3.cc tar xvf ${hello.src} cd hello-* # hello configure detects -liconv is needed but doesn't add to the link step LDFLAGS=-liconv ./configure --prefix=$out make make install $out/bin/hello ''; }