2017-07-18 05:36:17 +02:00
|
|
|
{ lib, clangStdenv, clang-sierraHack-stdenv }:
|
|
|
|
|
|
|
|
let
|
|
|
|
makeBigExe = stdenv: prefix: rec {
|
|
|
|
|
2017-07-27 05:28:36 +02:00
|
|
|
count = 500;
|
|
|
|
|
2017-07-18 05:36:17 +02:00
|
|
|
sillyLibs = lib.genList (i: stdenv.mkDerivation rec {
|
|
|
|
name = "${prefix}-fluff-${toString i}";
|
|
|
|
unpackPhase = ''
|
|
|
|
src=$PWD
|
2017-07-27 05:28:36 +02:00
|
|
|
cat << 'EOF' > ${name}.c
|
|
|
|
unsigned int asdf_${toString i}(void) {
|
|
|
|
return ${toString i};
|
|
|
|
}
|
|
|
|
EOF
|
2017-07-18 05:36:17 +02:00
|
|
|
'';
|
|
|
|
buildPhase = ''
|
2017-07-27 05:28:36 +02:00
|
|
|
$CC -std=c99 -shared ${name}.c -o lib${name}.dylib -Wl,-install_name,$out/lib/lib${name}.dylib
|
2017-07-18 05:36:17 +02:00
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out/lib"
|
|
|
|
mv lib${name}.dylib "$out/lib"
|
|
|
|
'';
|
2017-07-27 05:28:36 +02:00
|
|
|
}) count;
|
2017-07-18 05:36:17 +02:00
|
|
|
|
|
|
|
finalExe = stdenv.mkDerivation rec {
|
|
|
|
name = "${prefix}-final-asdf";
|
|
|
|
unpackPhase = ''
|
|
|
|
src=$PWD
|
2017-07-27 05:28:36 +02:00
|
|
|
cat << 'EOF' > main.cxx
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
2017-07-27 20:15:10 +02:00
|
|
|
${toString (lib.genList (i: "extern \"C\" unsigned int asdf_${toString i}(void); ") count)}
|
2017-07-27 05:28:36 +02:00
|
|
|
|
|
|
|
unsigned int (*funs[])(void) = {
|
|
|
|
${toString (lib.genList (i: "asdf_${toString i},") count)}
|
|
|
|
};
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
unsigned int i = 0;
|
|
|
|
for (auto f : funs) {
|
|
|
|
assert(f() == i++);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2017-07-18 05:36:17 +02:00
|
|
|
'';
|
|
|
|
buildPhase = ''
|
2017-07-27 05:28:36 +02:00
|
|
|
$CC -std=c++11 main.cxx ${toString (map (x: "-l${x.name}") sillyLibs)} -o asdf
|
2017-07-18 05:36:17 +02:00
|
|
|
'';
|
|
|
|
buildInputs = sillyLibs;
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out/bin"
|
|
|
|
mv asdf "$out/bin"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
in {
|
|
|
|
good = makeBigExe clang-sierraHack-stdenv "good";
|
|
|
|
bad = makeBigExe clangStdenv "bad";
|
|
|
|
}
|