2017-08-01 01:02:20 +00:00
|
|
|
{ lib, clangStdenv, clang-sierraHack-stdenv, stdenvNoCC }:
|
2017-07-18 03:36:17 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
makeBigExe = stdenv: prefix: rec {
|
|
|
|
|
2018-01-05 22:18:51 +00:00
|
|
|
count = 320;
|
2017-07-27 03:28:36 +00:00
|
|
|
|
2017-07-18 03:36:17 +00:00
|
|
|
sillyLibs = lib.genList (i: stdenv.mkDerivation rec {
|
|
|
|
name = "${prefix}-fluff-${toString i}";
|
|
|
|
unpackPhase = ''
|
|
|
|
src=$PWD
|
2017-07-27 03:28:36 +00:00
|
|
|
cat << 'EOF' > ${name}.c
|
|
|
|
unsigned int asdf_${toString i}(void) {
|
|
|
|
return ${toString i};
|
|
|
|
}
|
|
|
|
EOF
|
2017-07-18 03:36:17 +00:00
|
|
|
'';
|
|
|
|
buildPhase = ''
|
2017-07-27 03:28:36 +00:00
|
|
|
$CC -std=c99 -shared ${name}.c -o lib${name}.dylib -Wl,-install_name,$out/lib/lib${name}.dylib
|
2017-07-18 03:36:17 +00:00
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out/lib"
|
|
|
|
mv lib${name}.dylib "$out/lib"
|
|
|
|
'';
|
2017-08-01 01:02:20 +00:00
|
|
|
meta.platforms = lib.platforms.darwin;
|
2017-07-27 03:28:36 +00:00
|
|
|
}) count;
|
2017-07-18 03:36:17 +00:00
|
|
|
|
2019-08-13 21:52:01 +00:00
|
|
|
finalExe = stdenv.mkDerivation {
|
2017-07-18 03:36:17 +00:00
|
|
|
name = "${prefix}-final-asdf";
|
|
|
|
unpackPhase = ''
|
|
|
|
src=$PWD
|
2017-07-27 03:28:36 +00:00
|
|
|
cat << 'EOF' > main.cxx
|
|
|
|
|
2017-07-27 18:37:24 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <iostream>
|
2017-07-27 03:28:36 +00:00
|
|
|
|
2017-07-27 18:15:10 +00:00
|
|
|
${toString (lib.genList (i: "extern \"C\" unsigned int asdf_${toString i}(void); ") count)}
|
2017-07-27 03:28:36 +00:00
|
|
|
|
|
|
|
unsigned int (*funs[])(void) = {
|
|
|
|
${toString (lib.genList (i: "asdf_${toString i},") count)}
|
|
|
|
};
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
2017-07-27 18:37:24 +00:00
|
|
|
bool ret;
|
2017-07-27 03:28:36 +00:00
|
|
|
unsigned int i = 0;
|
|
|
|
for (auto f : funs) {
|
2017-07-27 18:37:24 +00:00
|
|
|
if (f() != i++) {
|
|
|
|
std::cerr << "Failed to get expected response from function #" << i << std::endl;
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2017-07-27 03:28:36 +00:00
|
|
|
}
|
2017-07-27 18:37:24 +00:00
|
|
|
return EXIT_SUCCESS;
|
2017-07-27 03:28:36 +00:00
|
|
|
}
|
|
|
|
EOF
|
2017-07-18 03:36:17 +00:00
|
|
|
'';
|
|
|
|
buildPhase = ''
|
2017-08-01 01:02:20 +00:00
|
|
|
$CXX -std=c++11 main.cxx ${toString (map (x: "-l${x.name}") sillyLibs)} -o ${prefix}-asdf
|
2017-07-18 03:36:17 +00:00
|
|
|
'';
|
|
|
|
buildInputs = sillyLibs;
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out/bin"
|
2017-08-01 01:02:20 +00:00
|
|
|
mv ${prefix}-asdf "$out/bin"
|
2017-07-18 03:36:17 +00:00
|
|
|
'';
|
2017-08-01 01:02:20 +00:00
|
|
|
meta.platforms = lib.platforms.darwin;
|
2017-07-18 03:36:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
good = makeBigExe clang-sierraHack-stdenv "good";
|
2017-08-01 01:02:20 +00:00
|
|
|
|
2017-07-18 03:36:17 +00:00
|
|
|
bad = makeBigExe clangStdenv "bad";
|
2017-08-01 01:02:20 +00:00
|
|
|
|
|
|
|
in stdenvNoCC.mkDerivation {
|
|
|
|
name = "macos-sierra-shared-test";
|
|
|
|
buildInputs = [ good.finalExe bad.finalExe ];
|
|
|
|
# TODO(@Ericson2314): Be impure or require exact MacOS version of builder?
|
|
|
|
buildCommand = ''
|
2018-01-05 22:18:51 +00:00
|
|
|
if bad-asdf &> /dev/null
|
|
|
|
then echo "WARNING: bad-asdf did not fail, not running on sierra?" >&2
|
2017-08-01 01:02:20 +00:00
|
|
|
else echo "bad-asdf should fail on sierra, OK" >&2
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Must succeed on all supported MacOS versions
|
|
|
|
good-asdf
|
2018-01-05 22:18:51 +00:00
|
|
|
echo "good-asdf should succeed on sierra, OK"
|
2017-08-01 01:02:20 +00:00
|
|
|
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
meta.platforms = lib.platforms.darwin;
|
2017-07-18 03:36:17 +00:00
|
|
|
}
|