1 { lib, clangStdenv, clang-sierraHack-stdenv, stdenvNoCC }:
4 makeBigExe = stdenv: prefix: rec {
8 sillyLibs = lib.genList (i: stdenv.mkDerivation rec {
9 name = "${prefix}-fluff-${toString i}";
12 cat << 'EOF' > ${name}.c
13 unsigned int asdf_${toString i}(void) {
19 $CC -std=c99 -shared ${name}.c -o lib${name}.dylib -Wl,-install_name,$out/lib/lib${name}.dylib
23 mv lib${name}.dylib "$out/lib"
25 meta.platforms = lib.platforms.darwin;
28 finalExe = stdenv.mkDerivation {
29 name = "${prefix}-final-asdf";
32 cat << 'EOF' > main.cxx
37 ${toString (lib.genList (i: "extern \"C\" unsigned int asdf_${toString i}(void); ") count)}
39 unsigned int (*funs[])(void) = {
40 ${toString (lib.genList (i: "asdf_${toString i},") count)}
43 int main(int argc, char **argv) {
48 std::cerr << "Failed to get expected response from function #" << i << std::endl;
57 $CXX -std=c++11 main.cxx ${toString (map (x: "-l${x.name}") sillyLibs)} -o ${prefix}-asdf
59 buildInputs = sillyLibs;
62 mv ${prefix}-asdf "$out/bin"
64 meta.platforms = lib.platforms.darwin;
69 good = makeBigExe clang-sierraHack-stdenv "good";
71 bad = makeBigExe clangStdenv "bad";
73 in stdenvNoCC.mkDerivation {
74 name = "macos-sierra-shared-test";
75 buildInputs = [ good.finalExe bad.finalExe ];
76 # TODO(@Ericson2314): Be impure or require exact MacOS version of builder?
78 if bad-asdf &> /dev/null
79 then echo "WARNING: bad-asdf did not fail, not running on sierra?" >&2
80 else echo "bad-asdf should fail on sierra, OK" >&2
83 # Must succeed on all supported MacOS versions
85 echo "good-asdf should succeed on sierra, OK"
89 meta.platforms = lib.platforms.darwin;