9 name = "test-bootstrap-tools";
11 inherit (stdenv.hostPlatform) system;
13 builder = "${bootstrapTools}/bin/bash";
19 "eval \"$buildCommand\""
22 PATH = lib.makeBinPath [ bootstrapTools ];
24 tools = bootstrapTools;
26 "${stdenv.cc.darwinMinVersionVariable}" = stdenv.cc.darwinMinVersion;
28 # Create a pure environment where we use just what's in the bootstrap tools.
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; }
37 # run all exes that don't take a --version flag
40 codesign_allocate -i $tools/bin/true -r -o true
42 install_name_tool -id true true
46 # ranlib gets tested bulding hello
47 rewrite-tbd </dev/null
51 # The grep will return a nonzero exit code if there is no match, and we want to assert that we have
53 curl --version | grep SSL
55 # This approximates a bootstrap version of libSystem can that be
56 # assembled via fetchurl. Adapted from main libSystem expression.
59 ${stdenv.cc.libc_dev}/lib/libSystem.B.tbd \
60 ${stdenv.cc.libc_dev}/lib/system \
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
67 export flags="-idirafter $tools/include-Libsystem --sysroot=$tools -L$tools/lib -L$PWD/libSystem-boot"
69 export CPP="clang -E $flags"
70 export CC="clang $flags"
71 export CXX="clang++ $flags --stdlib=libc++ -isystem$tools/include/c++/v1"
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)
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`.)
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
88 echo '#include <iostream>' >> hello3.cc
89 echo 'int main() { std::cout << "Hello World\n"; }' >> hello3.cc
90 $CXX -v -o hello3 hello3.cc
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
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
103 # hello configure detects -liconv is needed but doesn't add to the link step
104 LDFLAGS=-liconv ./configure --prefix=$out