Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 scons,
6 libconfig,
7 boost,
8 libyaml,
9 yaml-cpp,
10 ncurses,
11 gpm,
12 enableAccelergy ? true,
13 enableISL ? false,
14 accelergy,
15}:
16
17stdenv.mkDerivation rec {
18 pname = "timeloop";
19 version = "3.0.3";
20
21 src = fetchFromGitHub {
22 owner = "NVlabs";
23 repo = "timeloop";
24 rev = "v${version}";
25 hash = "sha256-CGPhrBNzFdERAA/Eym2v0+FvFUe+VkBLnwYEqEMHE9k=";
26 };
27
28 nativeBuildInputs = [ scons ];
29
30 buildInputs = [
31 libconfig
32 boost
33 libyaml
34 yaml-cpp
35 ncurses
36 accelergy
37 ]
38 ++ lib.optionals stdenv.hostPlatform.isLinux [ gpm ];
39
40 preConfigure = ''
41 cp -r ./pat-public/src/pat ./src/pat
42 '';
43
44 enableParallelBuilding = true;
45
46 postPatch = ''
47 # Fix gcc-13 build failure due to missing includes:
48 sed -e '1i #include <cstdint>' -i \
49 include/compound-config/compound-config.hpp
50
51 # use nix ar/ranlib
52 substituteInPlace ./SConstruct \
53 --replace-fail "env.Replace(AR = \"gcc-ar\")" "pass" \
54 --replace-fail "env.Replace(RANLIB = \"gcc-ranlib\")" "pass"
55 ''
56 + lib.optionalString stdenv.hostPlatform.isDarwin ''
57 # prevent clang from dying on errors that gcc is fine with
58 substituteInPlace ./src/SConscript --replace "-Werror" "-Wno-inconsistent-missing-override"
59
60 # disable LTO on macos
61 substituteInPlace ./src/SConscript --replace ", '-flto'" ""
62
63 # static builds on mac fail as no static libcrt is provided by apple
64 # see https://stackoverflow.com/questions/3801011/ld-library-not-found-for-lcrt0-o-on-osx-10-6-with-gcc-clang-static-flag
65 substituteInPlace ./src/SConscript \
66 --replace "'-static-libgcc', " "" \
67 --replace "'-static-libstdc++', " "" \
68 --replace "'-Wl,--whole-archive', '-static', " "" \
69 --replace ", '-Wl,--no-whole-archive'" ""
70
71 #remove hardcoding of gcc
72 sed -i '40i env.Replace(CC = "${stdenv.cc.targetPrefix}cc")' ./SConstruct
73 sed -i '40i env.Replace(CXX = "${stdenv.cc.targetPrefix}c++")' ./SConstruct
74
75 #gpm doesn't exist on darwin
76 substituteInPlace ./src/SConscript --replace ", 'gpm'" ""
77 '';
78
79 sconsFlags =
80 # will fail on clang/darwin on link without --static due to undefined extern
81 # however, will fail with static on linux as nixpkgs deps aren't static
82 lib.optional stdenv.hostPlatform.isDarwin "--static"
83 ++ lib.optional enableAccelergy "--accelergy"
84 ++ lib.optional enableISL "--with-isl";
85
86 installPhase = ''
87 cp -r ./bin ./lib $out
88 mkdir -p $out/share
89 cp -r ./doc $out/share
90 mkdir -p $out/data
91 cp -r ./problem-shapes ./configs $out/data
92 '';
93
94 meta = with lib; {
95 description = "Chip modeling/mapping benchmarking framework";
96 homepage = "https://timeloop.csail.mit.edu";
97 license = licenses.bsd3;
98 platforms = platforms.unix;
99 maintainers = with maintainers; [ gdinh ];
100 };
101}