11 , enableAccelergy ? true
16 stdenv.mkDerivation rec {
20 src = fetchFromGitHub {
24 hash = "sha256-CGPhrBNzFdERAA/Eym2v0+FvFUe+VkBLnwYEqEMHE9k=";
27 nativeBuildInputs = [ scons ];
36 ] ++ lib.optionals stdenv.hostPlatform.isLinux [ gpm ];
39 cp -r ./pat-public/src/pat ./src/pat
42 enableParallelBuilding = true;
45 # Fix gcc-13 build failure due to missing includes:
46 sed -e '1i #include <cstdint>' -i \
47 include/compound-config/compound-config.hpp
50 substituteInPlace ./SConstruct \
51 --replace-fail "env.Replace(AR = \"gcc-ar\")" "pass" \
52 --replace-fail "env.Replace(RANLIB = \"gcc-ranlib\")" "pass"
53 '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
54 # prevent clang from dying on errors that gcc is fine with
55 substituteInPlace ./src/SConscript --replace "-Werror" "-Wno-inconsistent-missing-override"
57 # disable LTO on macos
58 substituteInPlace ./src/SConscript --replace ", '-flto'" ""
60 # static builds on mac fail as no static libcrt is provided by apple
61 # see https://stackoverflow.com/questions/3801011/ld-library-not-found-for-lcrt0-o-on-osx-10-6-with-gcc-clang-static-flag
62 substituteInPlace ./src/SConscript \
63 --replace "'-static-libgcc', " "" \
64 --replace "'-static-libstdc++', " "" \
65 --replace "'-Wl,--whole-archive', '-static', " "" \
66 --replace ", '-Wl,--no-whole-archive'" ""
68 #remove hardcoding of gcc
69 sed -i '40i env.Replace(CC = "${stdenv.cc.targetPrefix}cc")' ./SConstruct
70 sed -i '40i env.Replace(CXX = "${stdenv.cc.targetPrefix}c++")' ./SConstruct
72 #gpm doesn't exist on darwin
73 substituteInPlace ./src/SConscript --replace ", 'gpm'" ""
77 # will fail on clang/darwin on link without --static due to undefined extern
78 # however, will fail with static on linux as nixpkgs deps aren't static
79 lib.optional stdenv.hostPlatform.isDarwin "--static"
80 ++ lib.optional enableAccelergy "--accelergy"
81 ++ lib.optional enableISL "--with-isl";
85 cp -r ./bin ./lib $out
87 cp -r ./doc $out/share
89 cp -r ./problem-shapes ./configs $out/data
93 description = "Chip modeling/mapping benchmarking framework";
94 homepage = "https://timeloop.csail.mit.edu";
95 license = licenses.bsd3;
96 platforms = platforms.unix;
97 maintainers = with maintainers; [ gdinh ];